Merge branch 'master' of https://github.com/highfidelity/hifi into cmake-quotes

This commit is contained in:
Stephen Birarda 2014-03-03 16:31:25 -08:00
commit bb3a8677be
42 changed files with 258 additions and 172 deletions

View file

@ -36,7 +36,7 @@ AvatarMixer::AvatarMixer(const QByteArray& packet) :
} }
void attachAvatarDataToNode(Node* newNode) { void attachAvatarDataToNode(Node* newNode) {
if (newNode->getLinkedData() == NULL) { if (!newNode->getLinkedData()) {
newNode->setLinkedData(new AvatarMixerClientData()); newNode->setLinkedData(new AvatarMixerClientData());
} }
} }

View file

@ -26,7 +26,7 @@ SimpleMovingAverage OctreeServer::_averageTreeWaitTime(10000);
SimpleMovingAverage OctreeServer::_averageNodeWaitTime(10000); SimpleMovingAverage OctreeServer::_averageNodeWaitTime(10000);
void OctreeServer::attachQueryNodeToNode(Node* newNode) { void OctreeServer::attachQueryNodeToNode(Node* newNode) {
if (newNode->getLinkedData() == NULL) { if (!newNode->getLinkedData()) {
OctreeQueryNode* newQueryNodeData = _instance->createOctreeQueryNode(); OctreeQueryNode* newQueryNodeData = _instance->createOctreeQueryNode();
newQueryNodeData->resetOctreePacket(true); // don't bump sequence newQueryNodeData->resetOctreePacket(true); // don't bump sequence
newNode->setLinkedData(newQueryNodeData); newNode->setLinkedData(newQueryNodeData);
@ -716,7 +716,7 @@ void OctreeServer::run() {
strftime(localBuffer, MAX_TIME_LENGTH, "%m/%d/%Y %X", localtm); strftime(localBuffer, MAX_TIME_LENGTH, "%m/%d/%Y %X", localtm);
// Convert now to tm struct for UTC // Convert now to tm struct for UTC
tm* gmtm = gmtime(&_started); tm* gmtm = gmtime(&_started);
if (gmtm != NULL) { if (gmtm) {
strftime(utcBuffer, MAX_TIME_LENGTH, " [%m/%d/%Y %X UTC]", gmtm); strftime(utcBuffer, MAX_TIME_LENGTH, " [%m/%d/%Y %X UTC]", gmtm);
} }
qDebug() << "Now running... started at: " << localBuffer << utcBuffer; qDebug() << "Now running... started at: " << localBuffer << utcBuffer;

View file

@ -3,7 +3,7 @@
// hifi // hifi
// //
// Created by Stephen Birarda on 2/20/14. // Created by Stephen Birarda on 2/20/14.
// Modified by Philip on 2/26/14 // Modified by Philip on 3/3/14
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. // Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
// //
// This is an example script that demonstrates an NPC avatar. // This is an example script that demonstrates an NPC avatar.
@ -27,76 +27,32 @@ var isMoving = false;
var isTurningHead = false; var isTurningHead = false;
var isPlayingAudio = false; var isPlayingAudio = false;
var STARTING_RANGE = 18.0; var X_MIN = 0.0;
var MAX_RANGE = 25.0; var X_MAX = 5.0;
var Z_MIN = 0.0;
var Z_MAX = 5.0;
var MOVE_RANGE_SMALL = 0.5; var MOVE_RANGE_SMALL = 0.5;
var MOVE_RANGE_BIG = 5.0; var MOVE_RANGE_BIG = Math.max(X_MAX - X_MIN, Z_MAX - Z_MIN) / 2.0;
var TURN_RANGE = 45.0; var TURN_RANGE = 70.0;
var STOP_TOLERANCE = 0.05; var STOP_TOLERANCE = 0.05;
var MOVE_RATE = 0.05; var MOVE_RATE = 0.05;
var TURN_RATE = 0.15; var TURN_RATE = 0.15;
var PITCH_RATE = 0.20; var PITCH_RATE = 0.20;
var PITCH_RANGE = 30.0; var PITCH_RANGE = 30.0;
var firstPosition = { x: getRandomFloat(X_MIN, X_MAX), y: 0, z: getRandomFloat(Z_MIN, Z_MAX) };
var firstPosition = { x: getRandomFloat(0, STARTING_RANGE), y: 0, z: getRandomFloat(0, STARTING_RANGE) };
var targetPosition = { x: 0, y: 0, z: 0 }; var targetPosition = { x: 0, y: 0, z: 0 };
var targetDirection = { x: 0, y: 0, z: 0, w: 0 }; var targetDirection = { x: 0, y: 0, z: 0, w: 0 };
var currentDirection = { x: 0, y: 0, z: 0, w: 0 }; var currentDirection = { x: 0, y: 0, z: 0, w: 0 };
var targetHeadPitch = 0.0; var targetHeadPitch = 0.0;
var sounds = []; var sounds = [];
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/AB1.raw")); loadSounds();
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Anchorman2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/B1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/B1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Bale1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Bandcamp.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Big1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Big2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Brian1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Buster1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/CES1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/CES2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/CES3.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/CES4.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Carrie1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Carrie3.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Charlotte1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/EN1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/EN2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/EN3.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Eugene1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Francesco1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Italian1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Japanese1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Leigh1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Lucille1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Lucille2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/MeanGirls.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Murray2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Nigel1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/PennyLane.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Pitt1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Ricardo.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/SN.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Sake1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Samantha1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Samantha2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Spicoli1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Supernatural.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Swearengen1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/TheDude.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Tony.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Triumph1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Uma1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Walken1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Walken2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Z1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Z2.raw"));
function clamp(val, min, max){
return Math.max(min, Math.min(max, val))
}
// Play a random sound from a list of conversational audio clips // Play a random sound from a list of conversational audio clips
function audioDone() { function audioDone() {
@ -152,6 +108,10 @@ function updateBehavior() {
playRandomSound(Avatar.position); playRandomSound(Avatar.position);
} }
if (isPlayingAudio) {
Avatar.handPosition = Vec3.sum(Avatar.position, Quat.getFront(Avatar.orientation));
}
if (!isTurningHead && (Math.random() < CHANCE_OF_HEAD_TURNING)) { if (!isTurningHead && (Math.random() < CHANCE_OF_HEAD_TURNING)) {
targetHeadPitch = getRandomFloat(-PITCH_RANGE, PITCH_RANGE); targetHeadPitch = getRandomFloat(-PITCH_RANGE, PITCH_RANGE);
isTurningHead = true; isTurningHead = true;
@ -170,6 +130,9 @@ function updateBehavior() {
} else { } else {
targetPosition = Vec3.sum(Avatar.position, Vec3.multiply(front, getRandomFloat(0.0, MOVE_RANGE_SMALL))); targetPosition = Vec3.sum(Avatar.position, Vec3.multiply(front, getRandomFloat(0.0, MOVE_RANGE_SMALL)));
} }
targetPosition.x = clamp(targetPosition.x, X_MIN, X_MAX);
targetPosition.z = clamp(targetPosition.z, Z_MIN, Z_MAX);
isMoving = true; isMoving = true;
} else { } else {
Avatar.position = Vec3.sum(Avatar.position, Vec3.multiply(Vec3.subtract(targetPosition, Avatar.position), MOVE_RATE)); Avatar.position = Vec3.sum(Avatar.position, Vec3.multiply(Vec3.subtract(targetPosition, Avatar.position), MOVE_RATE));
@ -178,10 +141,56 @@ function updateBehavior() {
isMoving = false; isMoving = false;
} }
} }
if (Vec3.length(Avatar.position) > MAX_RANGE) {
// Don't let our happy little person get out of the cage
isMoving = false;
Avatar.position = { x: 0, y: 0, z: 0 };
}
} }
Script.willSendVisualDataCallback.connect(updateBehavior); Script.willSendVisualDataCallback.connect(updateBehavior);
function loadSounds() {
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/AB1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Anchorman2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/B1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/B1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Bale1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Bandcamp.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Big1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Big2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Brian1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Buster1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/CES1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/CES2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/CES3.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/CES4.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Carrie1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Carrie3.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Charlotte1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/EN1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/EN2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/EN3.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Eugene1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Francesco1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Italian1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Japanese1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Leigh1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Lucille1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Lucille2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/MeanGirls.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Murray2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Nigel1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/PennyLane.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Pitt1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Ricardo.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/SN.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Sake1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Samantha1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Samantha2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Spicoli1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Supernatural.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Swearengen1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/TheDude.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Tony.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Triumph1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Uma1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Walken1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Walken2.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Z1.raw"));
sounds.push(new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Cocktail+Party+Snippets/Raws/Z2.raw"));
}

View file

@ -945,19 +945,32 @@ function setupMenus() {
// hook up menus // hook up menus
Menu.menuItemEvent.connect(menuItemEvent); Menu.menuItemEvent.connect(menuItemEvent);
// delete the standard application menu item // add our menuitems
Menu.addSeparator("Edit", "Voxels"); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Voxels", isSeparator: true, beforeItem: "Physics" });
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Cut", shortcutKey: "CTRL+X", afterItem: "Voxels" }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Cut", shortcutKey: "CTRL+X", afterItem: "Voxels" });
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Copy", shortcutKey: "CTRL+C", afterItem: "Cut" }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Copy", shortcutKey: "CTRL+C", afterItem: "Cut" });
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Paste", shortcutKey: "CTRL+V", afterItem: "Copy" }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Paste", shortcutKey: "CTRL+V", afterItem: "Copy" });
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Nudge", shortcutKey: "CTRL+N", afterItem: "Paste" }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Nudge", shortcutKey: "CTRL+N", afterItem: "Paste" });
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Delete", shortcutKeyEvent: { text: "backspace" }, afterItem: "Nudge" }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Delete", shortcutKeyEvent: { text: "backspace" }, afterItem: "Nudge" });
Menu.addSeparator("File", "Voxels"); Menu.addMenuItem({ menuName: "File", menuItemName: "Voxels", isSeparator: true, beforeItem: "Settings" });
Menu.addMenuItem({ menuName: "File", menuItemName: "Export Voxels", shortcutKey: "CTRL+E", afterItem: "Voxels" }); Menu.addMenuItem({ menuName: "File", menuItemName: "Export Voxels", shortcutKey: "CTRL+E", afterItem: "Voxels" });
Menu.addMenuItem({ menuName: "File", menuItemName: "Import Voxels", shortcutKey: "CTRL+I", afterItem: "Export Voxels" }); Menu.addMenuItem({ menuName: "File", menuItemName: "Import Voxels", shortcutKey: "CTRL+I", afterItem: "Export Voxels" });
} }
function cleanupMenus() {
// delete our menuitems
Menu.removeSeparator("Edit", "Voxels");
Menu.removeMenuItem("Edit", "Cut");
Menu.removeMenuItem("Edit", "Copy");
Menu.removeMenuItem("Edit", "Paste");
Menu.removeMenuItem("Edit", "Nudge");
Menu.removeMenuItem("Edit", "Delete");
Menu.removeSeparator("File", "Voxels");
Menu.removeMenuItem("File", "Export Voxels");
Menu.removeMenuItem("File", "Import Voxels");
}
function menuItemEvent(menuItem) { function menuItemEvent(menuItem) {
// handle clipboard items // handle clipboard items
@ -1382,6 +1395,7 @@ function scriptEnding() {
Overlays.deleteOverlay(thumb); Overlays.deleteOverlay(thumb);
Controller.releaseKeyEvents({ text: "+" }); Controller.releaseKeyEvents({ text: "+" });
Controller.releaseKeyEvents({ text: "-" }); Controller.releaseKeyEvents({ text: "-" });
cleanupMenus();
} }
Script.scriptEnding.connect(scriptEnding); Script.scriptEnding.connect(scriptEnding);

View file

@ -358,6 +358,8 @@ Application::~Application() {
_myAvatar = NULL; _myAvatar = NULL;
delete _glWidget; delete _glWidget;
AccountManager::getInstance().destroy();
} }
void Application::restoreSizeAndPosition() { void Application::restoreSizeAndPosition() {
@ -1146,7 +1148,7 @@ void Application::dropEvent(QDropEvent *event) {
} }
SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath); SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);
if (snapshotData != NULL) { if (snapshotData) {
if (!snapshotData->getDomain().isEmpty()) { if (!snapshotData->getDomain().isEmpty()) {
Menu::getInstance()->goToDomain(snapshotData->getDomain()); Menu::getInstance()->goToDomain(snapshotData->getDomain());
} }
@ -1940,7 +1942,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
// only send to the NodeTypes that are serverType // only send to the NodeTypes that are serverType
if (node->getActiveSocket() != NULL && node->getType() == serverType) { if (node->getActiveSocket() && node->getType() == serverType) {
totalServers++; totalServers++;
// get the server bounds for this server // get the server bounds for this server
@ -2000,7 +2002,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
// only send to the NodeTypes that are serverType // only send to the NodeTypes that are serverType
if (node->getActiveSocket() != NULL && node->getType() == serverType) { if (node->getActiveSocket() && node->getType() == serverType) {
// get the server bounds for this server // get the server bounds for this server

View file

@ -509,9 +509,24 @@ void Menu::handleViewFrustumOffsetKeyModifier(int key) {
} }
} }
void Menu::addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName) { void Menu::addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName, int menuItemLocation) {
destinationMenu->addSeparator(); QAction* actionBefore = NULL;
(destinationMenu->addAction(actionName))->setEnabled(false); if (menuItemLocation >= 0 && destinationMenu->actions().size() > menuItemLocation) {
actionBefore = destinationMenu->actions()[menuItemLocation];
}
if (actionBefore) {
QAction* separator = new QAction("",destinationMenu);
destinationMenu->insertAction(actionBefore, separator);
separator->setSeparator(true);
QAction* separatorText = new QAction(actionName,destinationMenu);
separatorText->setEnabled(false);
destinationMenu->insertAction(actionBefore, separatorText);
} else {
destinationMenu->addSeparator();
(destinationMenu->addAction(actionName))->setEnabled(false);
}
} }
QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu, QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu,
@ -572,7 +587,10 @@ void Menu::removeAction(QMenu* menu, const QString& actionName) {
} }
void Menu::setIsOptionChecked(const QString& menuOption, bool isChecked) { void Menu::setIsOptionChecked(const QString& menuOption, bool isChecked) {
return _actionHash.value(menuOption)->setChecked(isChecked); QAction* menu = _actionHash.value(menuOption);
if (menu) {
menu->setChecked(isChecked);
}
} }
bool Menu::isOptionChecked(const QString& menuOption) { bool Menu::isOptionChecked(const QString& menuOption) {
@ -1243,6 +1261,18 @@ int Menu::findPositionOfMenuItem(QMenu* menu, const QString& searchMenuItem) {
return UNSPECIFIED_POSITION; // not found return UNSPECIFIED_POSITION; // not found
} }
int Menu::positionBeforeSeparatorIfNeeded(QMenu* menu, int requestedPosition) {
QList<QAction*> menuActions = menu->actions();
if (requestedPosition > 1 && requestedPosition < menuActions.size()) {
QAction* beforeRequested = menuActions[requestedPosition - 1];
if (beforeRequested->isSeparator()) {
requestedPosition--;
}
}
return requestedPosition;
}
QMenu* Menu::addMenu(const QString& menuName) { QMenu* Menu::addMenu(const QString& menuName) {
QStringList menuTree = menuName.split(">"); QStringList menuTree = menuName.split(">");
QMenu* addTo = NULL; QMenu* addTo = NULL;
@ -1288,6 +1318,21 @@ void Menu::addSeparator(const QString& menuName, const QString& separatorName) {
} }
} }
void Menu::removeSeparator(const QString& menuName, const QString& separatorName) {
QMenu* menu = getMenu(menuName);
if (menu) {
int textAt = findPositionOfMenuItem(menu, separatorName);
QList<QAction*> menuActions = menu->actions();
QAction* separatorText = menuActions[textAt];
QAction* separatorLine = menuActions[textAt - 1];
if (separatorLine->isSeparator()) {
menu->removeAction(separatorText);
menu->removeAction(separatorLine);
}
}
QMenuBar::repaint();
}
void Menu::addMenuItem(const MenuItemProperties& properties) { void Menu::addMenuItem(const MenuItemProperties& properties) {
QMenu* menuObj = getMenu(properties.menuName); QMenu* menuObj = getMenu(properties.menuName);
if (menuObj) { if (menuObj) {
@ -1300,6 +1345,8 @@ void Menu::addMenuItem(const MenuItemProperties& properties) {
int requestedPosition = properties.position; int requestedPosition = properties.position;
if (requestedPosition == UNSPECIFIED_POSITION && !properties.beforeItem.isEmpty()) { if (requestedPosition == UNSPECIFIED_POSITION && !properties.beforeItem.isEmpty()) {
requestedPosition = findPositionOfMenuItem(menuObj, properties.beforeItem); requestedPosition = findPositionOfMenuItem(menuObj, properties.beforeItem);
// double check that the requested location wasn't a separator label
requestedPosition = positionBeforeSeparatorIfNeeded(menuObj, requestedPosition);
} }
if (requestedPosition == UNSPECIFIED_POSITION && !properties.afterItem.isEmpty()) { if (requestedPosition == UNSPECIFIED_POSITION && !properties.afterItem.isEmpty()) {
int afterPosition = findPositionOfMenuItem(menuObj, properties.afterItem); int afterPosition = findPositionOfMenuItem(menuObj, properties.afterItem);
@ -1308,9 +1355,11 @@ void Menu::addMenuItem(const MenuItemProperties& properties) {
} }
} }
QAction* menuItemAction; QAction* menuItemAction = NULL;
if (properties.isCheckable) { if (properties.isSeparator) {
menuItemAction = addCheckableActionToQMenuAndActionHash(menuObj, properties.menuItemName, addDisabledActionAndSeparator(menuObj, properties.menuItemName, requestedPosition);
} else if (properties.isCheckable) {
menuItemAction = addCheckableActionToQMenuAndActionHash(menuObj, properties.menuItemName,
properties.shortcutKeySequence, properties.isChecked, properties.shortcutKeySequence, properties.isChecked,
MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), requestedPosition); MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), requestedPosition);
} else { } else {
@ -1318,7 +1367,7 @@ void Menu::addMenuItem(const MenuItemProperties& properties) {
MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()), MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()),
QAction::NoRole, requestedPosition); QAction::NoRole, requestedPosition);
} }
if (shortcut) { if (shortcut && menuItemAction) {
connect(shortcut, SIGNAL(activated()), menuItemAction, SLOT(trigger())); connect(shortcut, SIGNAL(activated()), menuItemAction, SLOT(trigger()));
} }
QMenuBar::repaint(); QMenuBar::repaint();

View file

@ -124,6 +124,7 @@ public slots:
QMenu* addMenu(const QString& menuName); QMenu* addMenu(const QString& menuName);
void removeMenu(const QString& menuName); void removeMenu(const QString& menuName);
void addSeparator(const QString& menuName, const QString& separatorName); void addSeparator(const QString& menuName, const QString& separatorName);
void removeSeparator(const QString& menuName, const QString& separatorName);
void addMenuItem(const MenuItemProperties& properties); void addMenuItem(const MenuItemProperties& properties);
void removeMenuItem(const QString& menuName, const QString& menuitem); void removeMenuItem(const QString& menuName, const QString& menuitem);
@ -152,7 +153,8 @@ private:
void scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set); void scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set);
/// helper method to have separators with labels that are also compatible with OS X /// helper method to have separators with labels that are also compatible with OS X
void addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName); void addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName,
int menuItemLocation = UNSPECIFIED_POSITION);
QAction* addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu, QAction* addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu,
const QString& actionName, const QString& actionName,
@ -172,6 +174,7 @@ private:
QAction* getMenuAction(const QString& menuName); QAction* getMenuAction(const QString& menuName);
int findPositionOfMenuItem(QMenu* menu, const QString& searchMenuItem); int findPositionOfMenuItem(QMenu* menu, const QString& searchMenuItem);
int positionBeforeSeparatorIfNeeded(QMenu* menu, int requestedPosition);
QMenu* getMenu(const QString& menuName); QMenu* getMenu(const QString& menuName);

View file

@ -38,6 +38,12 @@ void MenuScriptingInterface::addSeparator(const QString& menuName, const QString
Q_ARG(const QString&, separatorName)); Q_ARG(const QString&, separatorName));
} }
void MenuScriptingInterface::removeSeparator(const QString& menuName, const QString& separatorName) {
QMetaObject::invokeMethod(Menu::getInstance(), "removeSeparator",
Q_ARG(const QString&, menuName),
Q_ARG(const QString&, separatorName));
}
void MenuScriptingInterface::addMenuItem(const MenuItemProperties& properties) { void MenuScriptingInterface::addMenuItem(const MenuItemProperties& properties) {
QMetaObject::invokeMethod(Menu::getInstance(), "addMenuItem", Q_ARG(const MenuItemProperties&, properties)); QMetaObject::invokeMethod(Menu::getInstance(), "addMenuItem", Q_ARG(const MenuItemProperties&, properties));
} }

View file

@ -32,6 +32,7 @@ public slots:
void removeMenu(const QString& menuName); void removeMenu(const QString& menuName);
void addSeparator(const QString& menuName, const QString& separatorName); void addSeparator(const QString& menuName, const QString& separatorName);
void removeSeparator(const QString& menuName, const QString& separatorName);
void addMenuItem(const MenuItemProperties& properties); void addMenuItem(const MenuItemProperties& properties);
void addMenuItem(const QString& menuName, const QString& menuitem, const QString& shortcutKey); void addMenuItem(const QString& menuName, const QString& menuitem, const QString& shortcutKey);

View file

@ -33,10 +33,7 @@ void ParticleTreeRenderer::init() {
void ParticleTreeRenderer::update() { void ParticleTreeRenderer::update() {
if (_tree) { if (_tree) {
ParticleTree* tree = static_cast<ParticleTree*>(_tree); ParticleTree* tree = static_cast<ParticleTree*>(_tree);
if (tree->tryLockForWrite()) { tree->update();
tree->update();
tree->unlock();
}
} }
} }

View file

@ -135,10 +135,10 @@ void Avatar::simulate(float deltaTime) {
getHand()->simulate(deltaTime, false); getHand()->simulate(deltaTime, false);
_skeletonModel.setLODDistance(getLODDistance()); _skeletonModel.setLODDistance(getLODDistance());
_skeletonModel.simulate(deltaTime, _shouldRenderBillboard); glm::vec3 headPosition = _position;
glm::vec3 headPosition; if (!_shouldRenderBillboard) {
if (!_skeletonModel.getHeadPosition(headPosition)) { _skeletonModel.simulate(deltaTime);
headPosition = _position; _skeletonModel.getHeadPosition(headPosition);
} }
Head* head = getHead(); Head* head = getHead();
head->setPosition(headPosition); head->setPosition(headPosition);

View file

@ -58,7 +58,7 @@ void Head::reset() {
void Head::simulate(float deltaTime, bool isMine, bool delayLoad) { void Head::simulate(float deltaTime, bool isMine, bool billboard) {
// Update audio trailing average for rendering facial animations // Update audio trailing average for rendering facial animations
Faceshift* faceshift = Application::getInstance()->getFaceshift(); Faceshift* faceshift = Application::getInstance()->getFaceshift();
@ -75,7 +75,7 @@ void Head::simulate(float deltaTime, bool isMine, bool delayLoad) {
} }
} }
if (!_isFaceshiftConnected) { if (!(_isFaceshiftConnected || billboard)) {
// Update eye saccades // Update eye saccades
const float AVERAGE_MICROSACCADE_INTERVAL = 0.50f; const float AVERAGE_MICROSACCADE_INTERVAL = 0.50f;
const float AVERAGE_SACCADE_INTERVAL = 4.0f; const float AVERAGE_SACCADE_INTERVAL = 4.0f;
@ -161,11 +161,10 @@ void Head::simulate(float deltaTime, bool isMine, bool delayLoad) {
if (!isMine) { if (!isMine) {
_faceModel.setLODDistance(static_cast<Avatar*>(_owningAvatar)->getLODDistance()); _faceModel.setLODDistance(static_cast<Avatar*>(_owningAvatar)->getLODDistance());
} }
_faceModel.simulate(deltaTime, delayLoad); _leftEyePosition = _rightEyePosition = getPosition();
if (!billboard) {
// the blend face may have custom eye meshes _faceModel.simulate(deltaTime);
if (!_faceModel.getEyePositions(_leftEyePosition, _rightEyePosition)) { _faceModel.getEyePositions(_leftEyePosition, _rightEyePosition);
_leftEyePosition = _rightEyePosition = getPosition();
} }
_eyePosition = calculateAverageEyePosition(); _eyePosition = calculateAverageEyePosition();
} }

View file

@ -36,7 +36,7 @@ public:
void init(); void init();
void reset(); void reset();
void simulate(float deltaTime, bool isMine, bool delayLoad = false); void simulate(float deltaTime, bool isMine, bool billboard = false);
void render(float alpha); void render(float alpha);
void setScale(float scale); void setScale(float scale);
void setPosition(glm::vec3 position) { _position = position; } void setPosition(glm::vec3 position) { _position = position; }

View file

@ -105,13 +105,13 @@ void GlowEffect::end() {
} }
static void maybeBind(QOpenGLFramebufferObject* fbo) { static void maybeBind(QOpenGLFramebufferObject* fbo) {
if (fbo != NULL) { if (fbo) {
fbo->bind(); fbo->bind();
} }
} }
static void maybeRelease(QOpenGLFramebufferObject* fbo) { static void maybeRelease(QOpenGLFramebufferObject* fbo) {
if (fbo != NULL) { if (fbo) {
fbo->release(); fbo->release();
} }
} }

View file

@ -996,18 +996,18 @@ void Model::renderMeshes(float alpha, bool translucent) {
Texture* diffuseMap = networkPart.diffuseTexture.data(); Texture* diffuseMap = networkPart.diffuseTexture.data();
if (mesh.isEye) { if (mesh.isEye) {
if (diffuseMap != NULL) { if (diffuseMap) {
diffuseMap = (_dilatedTextures[i][j] = diffuseMap = (_dilatedTextures[i][j] =
static_cast<DilatableNetworkTexture*>(diffuseMap)->getDilatedTexture(_pupilDilation)).data(); static_cast<DilatableNetworkTexture*>(diffuseMap)->getDilatedTexture(_pupilDilation)).data();
} }
} }
glBindTexture(GL_TEXTURE_2D, diffuseMap == NULL ? glBindTexture(GL_TEXTURE_2D, !diffuseMap ?
Application::getInstance()->getTextureCache()->getWhiteTextureID() : diffuseMap->getID()); Application::getInstance()->getTextureCache()->getWhiteTextureID() : diffuseMap->getID());
if (!mesh.tangents.isEmpty()) { if (!mesh.tangents.isEmpty()) {
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
Texture* normalMap = networkPart.normalTexture.data(); Texture* normalMap = networkPart.normalTexture.data();
glBindTexture(GL_TEXTURE_2D, normalMap == NULL ? glBindTexture(GL_TEXTURE_2D, !normalMap ?
Application::getInstance()->getTextureCache()->getBlueTextureID() : normalMap->getID()); Application::getInstance()->getTextureCache()->getBlueTextureID() : normalMap->getID());
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
} }

View file

@ -40,14 +40,14 @@ TextureCache::~TextureCache() {
foreach (GLuint id, _fileTextureIDs) { foreach (GLuint id, _fileTextureIDs) {
glDeleteTextures(1, &id); glDeleteTextures(1, &id);
} }
if (_primaryFramebufferObject != NULL) { if (_primaryFramebufferObject) {
delete _primaryFramebufferObject; delete _primaryFramebufferObject;
glDeleteTextures(1, &_primaryDepthTextureID); glDeleteTextures(1, &_primaryDepthTextureID);
} }
if (_secondaryFramebufferObject != NULL) { if (_secondaryFramebufferObject) {
delete _secondaryFramebufferObject; delete _secondaryFramebufferObject;
} }
if (_tertiaryFramebufferObject != NULL) { if (_tertiaryFramebufferObject) {
delete _tertiaryFramebufferObject; delete _tertiaryFramebufferObject;
} }
} }
@ -138,7 +138,7 @@ QSharedPointer<NetworkTexture> TextureCache::getTexture(const QUrl& url, bool no
} }
QOpenGLFramebufferObject* TextureCache::getPrimaryFramebufferObject() { QOpenGLFramebufferObject* TextureCache::getPrimaryFramebufferObject() {
if (_primaryFramebufferObject == NULL) { if (!_primaryFramebufferObject) {
_primaryFramebufferObject = createFramebufferObject(); _primaryFramebufferObject = createFramebufferObject();
glGenTextures(1, &_primaryDepthTextureID); glGenTextures(1, &_primaryDepthTextureID);
@ -164,21 +164,21 @@ GLuint TextureCache::getPrimaryDepthTextureID() {
} }
QOpenGLFramebufferObject* TextureCache::getSecondaryFramebufferObject() { QOpenGLFramebufferObject* TextureCache::getSecondaryFramebufferObject() {
if (_secondaryFramebufferObject == NULL) { if (!_secondaryFramebufferObject) {
_secondaryFramebufferObject = createFramebufferObject(); _secondaryFramebufferObject = createFramebufferObject();
} }
return _secondaryFramebufferObject; return _secondaryFramebufferObject;
} }
QOpenGLFramebufferObject* TextureCache::getTertiaryFramebufferObject() { QOpenGLFramebufferObject* TextureCache::getTertiaryFramebufferObject() {
if (_tertiaryFramebufferObject == NULL) { if (!_tertiaryFramebufferObject) {
_tertiaryFramebufferObject = createFramebufferObject(); _tertiaryFramebufferObject = createFramebufferObject();
} }
return _tertiaryFramebufferObject; return _tertiaryFramebufferObject;
} }
QOpenGLFramebufferObject* TextureCache::getShadowFramebufferObject() { QOpenGLFramebufferObject* TextureCache::getShadowFramebufferObject() {
if (_shadowFramebufferObject == NULL) { if (!_shadowFramebufferObject) {
const int SHADOW_MAP_SIZE = 2048; const int SHADOW_MAP_SIZE = 2048;
_shadowFramebufferObject = new QOpenGLFramebufferObject(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, _shadowFramebufferObject = new QOpenGLFramebufferObject(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE,
QOpenGLFramebufferObject::NoAttachment, GL_TEXTURE_2D, GL_RGB); QOpenGLFramebufferObject::NoAttachment, GL_TEXTURE_2D, GL_RGB);
@ -212,16 +212,16 @@ GLuint TextureCache::getShadowDepthTextureID() {
bool TextureCache::eventFilter(QObject* watched, QEvent* event) { bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
if (event->type() == QEvent::Resize) { if (event->type() == QEvent::Resize) {
QSize size = static_cast<QResizeEvent*>(event)->size(); QSize size = static_cast<QResizeEvent*>(event)->size();
if (_primaryFramebufferObject != NULL && _primaryFramebufferObject->size() != size) { if (_primaryFramebufferObject && _primaryFramebufferObject->size() != size) {
delete _primaryFramebufferObject; delete _primaryFramebufferObject;
_primaryFramebufferObject = NULL; _primaryFramebufferObject = NULL;
glDeleteTextures(1, &_primaryDepthTextureID); glDeleteTextures(1, &_primaryDepthTextureID);
} }
if (_secondaryFramebufferObject != NULL && _secondaryFramebufferObject->size() != size) { if (_secondaryFramebufferObject && _secondaryFramebufferObject->size() != size) {
delete _secondaryFramebufferObject; delete _secondaryFramebufferObject;
_secondaryFramebufferObject = NULL; _secondaryFramebufferObject = NULL;
} }
if (_tertiaryFramebufferObject != NULL && _tertiaryFramebufferObject->size() != size) { if (_tertiaryFramebufferObject && _tertiaryFramebufferObject->size() != size) {
delete _tertiaryFramebufferObject; delete _tertiaryFramebufferObject;
_tertiaryFramebufferObject = NULL; _tertiaryFramebufferObject = NULL;
} }

View file

@ -51,7 +51,7 @@ void AudioInjector::injectAudio() {
packetStream << QUuid::createUuid(); packetStream << QUuid::createUuid();
// pack the flag for loopback // pack the flag for loopback
uchar loopbackFlag = (uchar) (_options.getLoopbackAudioInterface() == NULL); uchar loopbackFlag = (uchar) (!_options.getLoopbackAudioInterface());
packetStream << loopbackFlag; packetStream << loopbackFlag;
// pack the position for injected audio // pack the position for injected audio

View file

@ -69,7 +69,7 @@ int Bitstream::registerMetaObject(const char* className, const QMetaObject* meta
getMetaObjects().insert(className, metaObject); getMetaObjects().insert(className, metaObject);
// register it as a subclass of itself and all of its superclasses // register it as a subclass of itself and all of its superclasses
for (const QMetaObject* superClass = metaObject; superClass != NULL; superClass = superClass->superClass()) { for (const QMetaObject* superClass = metaObject; superClass; superClass = superClass->superClass()) {
getMetaObjectSubClasses().insert(superClass, metaObject); getMetaObjectSubClasses().insert(superClass, metaObject);
} }
return 0; return 0;

View file

@ -784,7 +784,7 @@ void ScriptedMetavoxelGuide::setURL(const ParameterizedURL& url) {
bool MetavoxelVisitation::allInputNodesLeaves() const { bool MetavoxelVisitation::allInputNodesLeaves() const {
foreach (MetavoxelNode* node, inputNodes) { foreach (MetavoxelNode* node, inputNodes) {
if (node != NULL && !node->isLeaf()) { if (node && !node->isLeaf()) {
return false; return false;
} }
} }
@ -792,7 +792,7 @@ bool MetavoxelVisitation::allInputNodesLeaves() const {
} }
AttributeValue MetavoxelVisitation::getInheritedOutputValue(int index) const { AttributeValue MetavoxelVisitation::getInheritedOutputValue(int index) const {
for (const MetavoxelVisitation* visitation = previous; visitation != NULL; visitation = visitation->previous) { for (const MetavoxelVisitation* visitation = previous; visitation; visitation = visitation->previous) {
MetavoxelNode* node = visitation->outputNodes.at(index); MetavoxelNode* node = visitation->outputNodes.at(index);
if (node) { if (node) {
return node->getAttributeValue(visitor.getOutputs().at(index)); return node->getAttributeValue(visitor.getOutputs().at(index));

View file

@ -62,7 +62,7 @@ DelegatingItemEditorFactory::DelegatingItemEditorFactory() :
QWidget* DelegatingItemEditorFactory::createEditor(int userType, QWidget* parent) const { QWidget* DelegatingItemEditorFactory::createEditor(int userType, QWidget* parent) const {
QWidget* editor = QItemEditorFactory::createEditor(userType, parent); QWidget* editor = QItemEditorFactory::createEditor(userType, parent);
return (editor == NULL) ? _parentFactory->createEditor(userType, parent) : editor; return (!editor) ? _parentFactory->createEditor(userType, parent) : editor;
} }
QByteArray DelegatingItemEditorFactory::valuePropertyName(int userType) const { QByteArray DelegatingItemEditorFactory::valuePropertyName(int userType) const {

View file

@ -163,7 +163,7 @@ void SharedObjectEditor::updateType() {
oldObject->disconnect(this); oldObject->disconnect(this);
} }
const QMetaObject* metaObject = _type->itemData(_type->currentIndex()).value<const QMetaObject*>(); const QMetaObject* metaObject = _type->itemData(_type->currentIndex()).value<const QMetaObject*>();
if (metaObject == NULL) { if (!metaObject) {
_object.reset(); _object.reset();
return; return;
} }

View file

@ -62,7 +62,7 @@ bool JurisdictionSender::process() {
_nodesRequestingJurisdictions.pop(); _nodesRequestingJurisdictions.pop();
SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID); SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID);
if (node && node->getActiveSocket() != NULL) { if (node && node->getActiveSocket()) {
_packetSender.queuePacketForSending(node, QByteArray(reinterpret_cast<char *>(bufferOut), sizeOut)); _packetSender.queuePacketForSending(node, QByteArray(reinterpret_cast<char *>(bufferOut), sizeOut));
nodeCount++; nodeCount++;
} }

View file

@ -41,7 +41,8 @@ float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeSc
Octree::Octree(bool shouldReaverage) : Octree::Octree(bool shouldReaverage) :
_isDirty(true), _isDirty(true),
_shouldReaverage(shouldReaverage), _shouldReaverage(shouldReaverage),
_stopImport(false) { _stopImport(false),
_lock(QReadWriteLock::Recursive) {
_rootNode = NULL; _rootNode = NULL;
_isViewing = false; _isViewing = false;
} }
@ -150,7 +151,7 @@ void Octree::recurseNodeWithOperationDistanceSorted(OctreeElement* node, Recurse
OctreeElement* Octree::nodeForOctalCode(OctreeElement* ancestorNode, OctreeElement* Octree::nodeForOctalCode(OctreeElement* ancestorNode,
const unsigned char* needleCode, OctreeElement** parentOfFoundNode) const { const unsigned char* needleCode, OctreeElement** parentOfFoundNode) const {
// special case for NULL octcode // special case for NULL octcode
if (needleCode == NULL) { if (!needleCode) {
return _rootNode; return _rootNode;
} }
@ -499,7 +500,7 @@ void Octree::processRemoveOctreeElementsBitstream(const unsigned char* bitstream
// Note: this is an expensive call. Don't call it unless you really need to reaverage the entire tree (from startNode) // Note: this is an expensive call. Don't call it unless you really need to reaverage the entire tree (from startNode)
void Octree::reaverageOctreeElements(OctreeElement* startNode) { void Octree::reaverageOctreeElements(OctreeElement* startNode) {
if (startNode == NULL) { if (!startNode) {
startNode = getRoot(); startNode = getRoot();
} }
// if our tree is a reaveraging tree, then we do this, otherwise we don't do anything // if our tree is a reaveraging tree, then we do this, otherwise we don't do anything
@ -551,7 +552,10 @@ OctreeElement* Octree::getOctreeElementAt(float x, float y, float z, float s) co
OctreeElement* Octree::getOrCreateChildElementAt(float x, float y, float z, float s) { OctreeElement* Octree::getOrCreateChildElementAt(float x, float y, float z, float s) {
return getRoot()->getOrCreateChildElementAt(x, y, z, s); lockForWrite();
OctreeElement* result = getRoot()->getOrCreateChildElementAt(x, y, z, s);
unlock();
return result;
} }

View file

@ -240,11 +240,11 @@ public:
bool readFromSVOFile(const char* filename); bool readFromSVOFile(const char* filename);
// Octree does not currently handle its own locking, caller must use these to lock/unlock // Octree does not currently handle its own locking, caller must use these to lock/unlock
void lockForRead() { lock.lockForRead(); } void lockForRead() { _lock.lockForRead(); }
bool tryLockForRead() { return lock.tryLockForRead(); } bool tryLockForRead() { return _lock.tryLockForRead(); }
void lockForWrite() { lock.lockForWrite(); } void lockForWrite() { _lock.lockForWrite(); }
bool tryLockForWrite() { return lock.tryLockForWrite(); } bool tryLockForWrite() { return _lock.tryLockForWrite(); }
void unlock() { lock.unlock(); } void unlock() { _lock.unlock(); }
unsigned long getOctreeElementsCount(); unsigned long getOctreeElementsCount();
@ -329,7 +329,7 @@ protected:
/// flushes out any Octal Codes that had to be queued /// flushes out any Octal Codes that had to be queued
void emptyDeleteQueue(); void emptyDeleteQueue();
QReadWriteLock lock; QReadWriteLock _lock;
/// This tree is receiving inbound viewer datagrams. /// This tree is receiving inbound viewer datagrams.
bool _isViewing; bool _isViewing;

View file

@ -177,7 +177,7 @@ void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t l
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
// only send to the NodeTypes that are getMyNodeType() // only send to the NodeTypes that are getMyNodeType()
if (node->getActiveSocket() != NULL && node->getType() == getMyNodeType()) { if (node->getActiveSocket() && node->getType() == getMyNodeType()) {
QUuid nodeUUID = node->getUUID(); QUuid nodeUUID = node->getUUID();
bool isMyJurisdiction = true; bool isMyJurisdiction = true;
// we need to get the jurisdiction for this // we need to get the jurisdiction for this
@ -226,7 +226,7 @@ void OctreeEditPacketSender::queueOctreeEditMessage(PacketType type, unsigned ch
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
// only send to the NodeTypes that are getMyNodeType() // only send to the NodeTypes that are getMyNodeType()
if (node->getActiveSocket() != NULL && node->getType() == getMyNodeType()) { if (node->getActiveSocket() && node->getType() == getMyNodeType()) {
QUuid nodeUUID = node->getUUID(); QUuid nodeUUID = node->getUUID();
bool isMyJurisdiction = true; bool isMyJurisdiction = true;

View file

@ -739,7 +739,7 @@ void OctreeElement::setChildAtIndex(int childIndex, OctreeElement* child) {
_externalChildrenMemoryUsage += NUMBER_OF_CHILDREN * sizeof(OctreeElement*); _externalChildrenMemoryUsage += NUMBER_OF_CHILDREN * sizeof(OctreeElement*);
} else if (previousChildCount == 2 && newChildCount == 1) { } else if (previousChildCount == 2 && newChildCount == 1) {
assert(child == NULL); // we are removing a child, so this must be true! assert(!child); // we are removing a child, so this must be true!
OctreeElement* previousFirstChild = _children.external[firstIndex]; OctreeElement* previousFirstChild = _children.external[firstIndex];
OctreeElement* previousSecondChild = _children.external[secondIndex]; OctreeElement* previousSecondChild = _children.external[secondIndex];
delete[] _children.external; delete[] _children.external;

View file

@ -75,7 +75,7 @@ void OctreeHeadlessViewer::queryOctree() {
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
// only send to the NodeTypes that are serverType // only send to the NodeTypes that are serverType
if (node->getActiveSocket() != NULL && node->getType() == serverType) { if (node->getActiveSocket() && node->getType() == serverType) {
totalServers++; totalServers++;
// get the server bounds for this server // get the server bounds for this server
@ -135,7 +135,7 @@ void OctreeHeadlessViewer::queryOctree() {
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
// only send to the NodeTypes that are serverType // only send to the NodeTypes that are serverType
if (node->getActiveSocket() != NULL && node->getType() == serverType) { if (node->getActiveSocket() && node->getType() == serverType) {
// get the server bounds for this server // get the server bounds for this server

View file

@ -385,7 +385,7 @@ Particle Particle::fromEditPacket(const unsigned char* data, int length, int& pr
} else { } else {
// look up the existing particle // look up the existing particle
const Particle* existingParticle = tree->findParticleByID(editID, true); const Particle* existingParticle = tree->findParticleByID(editID);
// copy existing properties before over-writing with new properties // copy existing properties before over-writing with new properties
if (existingParticle) { if (existingParticle) {

View file

@ -99,8 +99,8 @@ void ParticleTree::storeParticle(const Particle& particle, const SharedNodePoint
if (!args.found) { if (!args.found) {
glm::vec3 position = particle.getPosition(); glm::vec3 position = particle.getPosition();
float size = std::max(MINIMUM_PARTICLE_ELEMENT_SIZE, particle.getRadius()); float size = std::max(MINIMUM_PARTICLE_ELEMENT_SIZE, particle.getRadius());
ParticleTreeElement* element = (ParticleTreeElement*)getOrCreateChildElementAt(position.x, position.y, position.z, size);
ParticleTreeElement* element = (ParticleTreeElement*)getOrCreateChildElementAt(position.x, position.y, position.z, size);
element->storeParticle(particle); element->storeParticle(particle);
} }
// what else do we need to do here to get reaveraging to work // what else do we need to do here to get reaveraging to work
@ -149,8 +149,8 @@ void ParticleTree::addParticle(const ParticleID& particleID, const ParticlePrope
Particle particle(particleID, properties); Particle particle(particleID, properties);
glm::vec3 position = particle.getPosition(); glm::vec3 position = particle.getPosition();
float size = std::max(MINIMUM_PARTICLE_ELEMENT_SIZE, particle.getRadius()); float size = std::max(MINIMUM_PARTICLE_ELEMENT_SIZE, particle.getRadius());
ParticleTreeElement* element = (ParticleTreeElement*)getOrCreateChildElementAt(position.x, position.y, position.z, size); ParticleTreeElement* element = (ParticleTreeElement*)getOrCreateChildElementAt(position.x, position.y, position.z, size);
element->storeParticle(particle); element->storeParticle(particle);
_isDirty = true; _isDirty = true;
@ -370,17 +370,12 @@ bool ParticleTree::findByIDOperation(OctreeElement* element, void* extraData) {
} }
const Particle* ParticleTree::findParticleByID(uint32_t id, bool alreadyLocked) { const Particle* ParticleTree::findParticleByID(uint32_t id) {
FindByIDArgs args = { id, false, NULL }; FindByIDArgs args = { id, false, NULL };
if (!alreadyLocked) {
//qDebug() << "ParticleTree::findParticleByID().... about to call lockForRead()...."; lockForRead();
lockForRead();
//qDebug() << "ParticleTree::findParticleByID().... after call lockForRead()....";
}
recurseTreeWithOperation(findByIDOperation, &args); recurseTreeWithOperation(findByIDOperation, &args);
if (!alreadyLocked) { unlock();
unlock();
}
return args.foundParticle; return args.foundParticle;
} }
@ -487,7 +482,9 @@ void ParticleTree::update() {
} }
// prune the tree... // prune the tree...
lockForWrite();
recurseTreeWithOperation(pruneOperation, NULL); recurseTreeWithOperation(pruneOperation, NULL);
unlock();
} }

View file

@ -44,7 +44,7 @@ public:
void addParticle(const ParticleID& particleID, const ParticleProperties& properties); void addParticle(const ParticleID& particleID, const ParticleProperties& properties);
void deleteParticle(const ParticleID& particleID); void deleteParticle(const ParticleID& particleID);
const Particle* findClosestParticle(glm::vec3 position, float targetRadius); const Particle* findClosestParticle(glm::vec3 position, float targetRadius);
const Particle* findParticleByID(uint32_t id, bool alreadyLocked = false); const Particle* findParticleByID(uint32_t id);
/// finds all particles that touch a sphere /// finds all particles that touch a sphere
/// \param center the center of the sphere /// \param center the center of the sphere

View file

@ -33,9 +33,7 @@ ParticleID ParticlesScriptingInterface::addParticle(const ParticleProperties& pr
// If we have a local particle tree set, then also update it. // If we have a local particle tree set, then also update it.
if (_particleTree) { if (_particleTree) {
_particleTree->lockForWrite();
_particleTree->addParticle(id, properties); _particleTree->addParticle(id, properties);
_particleTree->unlock();
} }
return id; return id;
@ -66,7 +64,7 @@ ParticleProperties ParticlesScriptingInterface::getParticleProperties(ParticleID
} }
if (_particleTree) { if (_particleTree) {
_particleTree->lockForRead(); _particleTree->lockForRead();
const Particle* particle = _particleTree->findParticleByID(identity.id, true); const Particle* particle = _particleTree->findParticleByID(identity.id);
if (particle) { if (particle) {
results.copyFromParticle(*particle); results.copyFromParticle(*particle);
} else { } else {

View file

@ -30,12 +30,10 @@ public:
private slots: private slots:
/// inbound slots for external collision systems /// inbound slots for external collision systems
void forwardParticleCollisionWithVoxel(const ParticleID& particleID, const VoxelDetail& voxel) { void forwardParticleCollisionWithVoxel(const ParticleID& particleID, const VoxelDetail& voxel) {
qDebug() << "forwardParticleCollisionWithVoxel()";
emit particleCollisionWithVoxel(particleID, voxel); emit particleCollisionWithVoxel(particleID, voxel);
} }
void forwardParticleCollisionWithParticle(const ParticleID& idA, const ParticleID& idB) { void forwardParticleCollisionWithParticle(const ParticleID& idA, const ParticleID& idB) {
qDebug() << "forwardParticleCollisionWithParticle()";
emit particleCollisionWithParticle(idA, idB); emit particleCollisionWithParticle(idA, idB);
} }

View file

@ -71,6 +71,7 @@ void menuItemPropertiesFromScriptValue(const QScriptValue& object, MenuItemPrope
properties.menuItemName = object.property("menuItemName").toVariant().toString(); properties.menuItemName = object.property("menuItemName").toVariant().toString();
properties.isCheckable = object.property("isCheckable").toVariant().toBool(); properties.isCheckable = object.property("isCheckable").toVariant().toBool();
properties.isChecked = object.property("isChecked").toVariant().toBool(); properties.isChecked = object.property("isChecked").toVariant().toBool();
properties.isSeparator = object.property("isSeparator").toVariant().toBool();
// handle the shortcut key options in order... // handle the shortcut key options in order...
QScriptValue shortcutKeyValue = object.property("shortcutKey"); QScriptValue shortcutKeyValue = object.property("shortcutKey");

View file

@ -39,6 +39,7 @@ public:
// other properties // other properties
bool isCheckable; bool isCheckable;
bool isChecked; bool isChecked;
bool isSeparator;
}; };
Q_DECLARE_METATYPE(MenuItemProperties) Q_DECLARE_METATYPE(MenuItemProperties)
QScriptValue menuItemPropertiesToScriptValue(QScriptEngine* engine, const MenuItemProperties& props); QScriptValue menuItemPropertiesToScriptValue(QScriptEngine* engine, const MenuItemProperties& props);

View file

@ -35,7 +35,7 @@ const QString ACCOUNTS_GROUP = "accounts";
AccountManager::AccountManager() : AccountManager::AccountManager() :
_authURL(), _authURL(),
_networkAccessManager(), _networkAccessManager(new QNetworkAccessManager(this)),
_pendingCallbackMap(), _pendingCallbackMap(),
_accountInfo() _accountInfo()
{ {
@ -130,16 +130,16 @@ void AccountManager::invokedRequest(const QString& path, QNetworkAccessManager::
switch (operation) { switch (operation) {
case QNetworkAccessManager::GetOperation: case QNetworkAccessManager::GetOperation:
networkReply = _networkAccessManager.get(authenticatedRequest); networkReply = _networkAccessManager->get(authenticatedRequest);
break; break;
case QNetworkAccessManager::PostOperation: case QNetworkAccessManager::PostOperation:
case QNetworkAccessManager::PutOperation: case QNetworkAccessManager::PutOperation:
authenticatedRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); authenticatedRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
if (operation == QNetworkAccessManager::PostOperation) { if (operation == QNetworkAccessManager::PostOperation) {
networkReply = _networkAccessManager.post(authenticatedRequest, dataByteArray); networkReply = _networkAccessManager->post(authenticatedRequest, dataByteArray);
} else { } else {
networkReply = _networkAccessManager.put(authenticatedRequest, dataByteArray); networkReply = _networkAccessManager->put(authenticatedRequest, dataByteArray);
} }
break; break;
@ -242,7 +242,7 @@ void AccountManager::requestAccessToken(const QString& login, const QString& pas
request.setUrl(grantURL); request.setUrl(grantURL);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QNetworkReply* requestReply = _networkAccessManager.post(request, postData); QNetworkReply* requestReply = _networkAccessManager->post(request, postData);
connect(requestReply, &QNetworkReply::finished, this, &AccountManager::requestFinished); connect(requestReply, &QNetworkReply::finished, this, &AccountManager::requestFinished);
connect(requestReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestError(QNetworkReply::NetworkError))); connect(requestReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestError(QNetworkReply::NetworkError)));
} }
@ -292,4 +292,4 @@ void AccountManager::requestFinished() {
void AccountManager::requestError(QNetworkReply::NetworkError error) { void AccountManager::requestError(QNetworkReply::NetworkError error) {
// TODO: error handling // TODO: error handling
qDebug() << "AccountManager requestError - " << error; qDebug() << "AccountManager requestError - " << error;
} }

View file

@ -23,7 +23,7 @@ public:
jsonCallbackReceiver(NULL), jsonCallbackMethod(), jsonCallbackReceiver(NULL), jsonCallbackMethod(),
errorCallbackReceiver(NULL), errorCallbackMethod() {}; errorCallbackReceiver(NULL), errorCallbackMethod() {};
bool isEmpty() const { return jsonCallbackReceiver == NULL && errorCallbackReceiver == NULL; } bool isEmpty() const { return !jsonCallbackReceiver && !errorCallbackReceiver; }
QObject* jsonCallbackReceiver; QObject* jsonCallbackReceiver;
QString jsonCallbackMethod; QString jsonCallbackMethod;
@ -53,6 +53,8 @@ public:
QString getUsername() const { return _accountInfo.getUsername(); } QString getUsername() const { return _accountInfo.getUsername(); }
void destroy() { delete _networkAccessManager; }
public slots: public slots:
void requestFinished(); void requestFinished();
void requestError(QNetworkReply::NetworkError error); void requestError(QNetworkReply::NetworkError error);
@ -76,7 +78,7 @@ private:
const JSONCallbackParameters& callbackParams, const QByteArray& dataByteArray); const JSONCallbackParameters& callbackParams, const QByteArray& dataByteArray);
QUrl _authURL; QUrl _authURL;
QNetworkAccessManager _networkAccessManager; QNetworkAccessManager* _networkAccessManager;
QMap<QNetworkReply*, JSONCallbackParameters> _pendingCallbackMap; QMap<QNetworkReply*, JSONCallbackParameters> _pendingCallbackMap;
DataServerAccountInfo _accountInfo; DataServerAccountInfo _accountInfo;

View file

@ -98,7 +98,7 @@ void Node::activatePublicSocket() {
} }
void Node::recordBytesReceived(int bytesReceived) { void Node::recordBytesReceived(int bytesReceived) {
if (_bytesReceivedMovingAverage == NULL) { if (!_bytesReceivedMovingAverage) {
_bytesReceivedMovingAverage = new SimpleMovingAverage(100); _bytesReceivedMovingAverage = new SimpleMovingAverage(100);
} }

View file

@ -264,6 +264,11 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteAr
break; break;
} }
default: default:
// the node decided not to do anything with this packet
// if it comes from a known source we should keep that node alive
SharedNodePointer matchingNode = sendingNodeForPacket(packet);
matchingNode->setLastHeardMicrostamp(usecTimestampNow());
break; break;
} }
} }
@ -810,7 +815,7 @@ void NodeList::activateSocketFromNodeCommunication(const QByteArray& packet, con
SharedNodePointer NodeList::soloNodeOfType(char nodeType) { SharedNodePointer NodeList::soloNodeOfType(char nodeType) {
if (memchr(SOLO_NODE_TYPES, nodeType, sizeof(SOLO_NODE_TYPES)) != NULL) { if (memchr(SOLO_NODE_TYPES, nodeType, sizeof(SOLO_NODE_TYPES))) {
foreach (const SharedNodePointer& node, getNodeHash()) { foreach (const SharedNodePointer& node, getNodeHash()) {
if (node->getType() == nodeType) { if (node->getType() == nodeType) {
return node; return node;

View file

@ -73,7 +73,7 @@ unsigned char* childOctalCode(const unsigned char* parentOctalCode, char childNu
// find the length (in number of three bit code sequences) // find the length (in number of three bit code sequences)
// in the parent // in the parent
int parentCodeSections = parentOctalCode != NULL int parentCodeSections = parentOctalCode
? numberOfThreeBitSectionsInCode(parentOctalCode) ? numberOfThreeBitSectionsInCode(parentOctalCode)
: 0; : 0;
@ -87,7 +87,7 @@ unsigned char* childOctalCode(const unsigned char* parentOctalCode, char childNu
unsigned char* newCode = new unsigned char[childCodeBytes]; unsigned char* newCode = new unsigned char[childCodeBytes];
// copy the parent code to the child // copy the parent code to the child
if (parentOctalCode != NULL) { if (parentOctalCode) {
memcpy(newCode, parentOctalCode, parentCodeBytes); memcpy(newCode, parentOctalCode, parentCodeBytes);
} }

View file

@ -98,7 +98,7 @@ VoxelSystem* VoxelTreeElement::getVoxelSystem() const {
} }
void VoxelTreeElement::setVoxelSystem(VoxelSystem* voxelSystem) { void VoxelTreeElement::setVoxelSystem(VoxelSystem* voxelSystem) {
if (voxelSystem == NULL) { if (!voxelSystem) {
_voxelSystemIndex = INDEX_FOR_NULL; _voxelSystemIndex = INDEX_FOR_NULL;
} else { } else {
uint8_t index; uint8_t index;

View file

@ -72,7 +72,7 @@ void SvoViewer::InitializePointRenderSystem()
PointRenderAssembleData args; PointRenderAssembleData args;
args.buffer = _pointVertices = new glm::vec3[_nodeCount]; args.buffer = _pointVertices = new glm::vec3[_nodeCount];
args.colorBuffer = _pointColors = new unsigned char[_nodeCount*3]; args.colorBuffer = _pointColors = new unsigned char[_nodeCount*3];
assert(args.buffer != NULL); assert(args.buffer);
args.count = 0; args.count = 0;
_systemTree.recurseTreeWithOperation(&PointRenderAssemblePerVoxel, &args); _systemTree.recurseTreeWithOperation(&PointRenderAssemblePerVoxel, &args);
@ -297,7 +297,7 @@ void SvoViewer::InitializeVoxelRenderSystem()
VoxelRenderAssembleData args; VoxelRenderAssembleData args;
args.buffer = _readVerticesArray; args.buffer = _readVerticesArray;
args.colorBuffer = _readColorsArray; args.colorBuffer = _readColorsArray;
assert(args.buffer != NULL && args.colorBuffer != NULL); assert(args.buffer && args.colorBuffer);
args.leafCount = 0; args.leafCount = 0;
args.lastBufferSegmentStart = 0; args.lastBufferSegmentStart = 0;
args.idxIds = _vboIndicesIds; args.idxIds = _vboIndicesIds;
@ -622,12 +622,12 @@ void SvoViewer::InitializeVoxelOptRenderSystem()
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) for (int i = 0; i < NUMBER_OF_CHILDREN; i++)
{ {
OctreeElement* childNode1stOrder = node0fromRoot->getChildAtIndex(i); OctreeElement* childNode1stOrder = node0fromRoot->getChildAtIndex(i);
if (childNode1stOrder == NULL) continue; if (!childNode1stOrder) continue;
// Grab 2nd order nodes for better separation. At some point, this would need to be done intelligently. // Grab 2nd order nodes for better separation. At some point, this would need to be done intelligently.
for (int j = 0; j < NUMBER_OF_CHILDREN; j++) for (int j = 0; j < NUMBER_OF_CHILDREN; j++)
{ {
OctreeElement* childNode2ndOrder = childNode1stOrder->getChildAtIndex(j); OctreeElement* childNode2ndOrder = childNode1stOrder->getChildAtIndex(j);
if (childNode2ndOrder == NULL) continue; if (!childNode2ndOrder) continue;
//int num2ndOrderChildren = childNode2ndOrder->getChildCount(); //int num2ndOrderChildren = childNode2ndOrder->getChildCount();
// Figure out how populated this child is. // Figure out how populated this child is.

View file

@ -194,12 +194,12 @@ void SvoViewer::InitializeVoxelOpt2RenderSystem()
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) for (int i = 0; i < NUMBER_OF_CHILDREN; i++)
{ {
OctreeElement* childNode1stOrder = node0fromRoot->getChildAtIndex(i); OctreeElement* childNode1stOrder = node0fromRoot->getChildAtIndex(i);
if (childNode1stOrder == NULL) continue; if (!childNode1stOrder) continue;
// Grab 2nd order nodes for better separation. At some point, this would need to be done intelligently. // Grab 2nd order nodes for better separation. At some point, this would need to be done intelligently.
for (int j = 0; j < NUMBER_OF_CHILDREN; j++) for (int j = 0; j < NUMBER_OF_CHILDREN; j++)
{ {
OctreeElement* childNode2ndOrder = childNode1stOrder->getChildAtIndex(j); OctreeElement* childNode2ndOrder = childNode1stOrder->getChildAtIndex(j);
if (childNode2ndOrder == NULL) continue; if (!childNode2ndOrder) continue;
//int num2ndOrderChildren = childNode2ndOrder->getChildCount(); //int num2ndOrderChildren = childNode2ndOrder->getChildCount();
// Figure out how populated this child is. // Figure out how populated this child is.
@ -240,7 +240,7 @@ void SvoViewer::InitializeVoxelOpt2RenderSystem()
for (int k = 0; k < NUM_CUBE_FACES; k++) for (int k = 0; k < NUM_CUBE_FACES; k++)
{ {
_segmentIdxBuffers[i].idxBuff[k] = new GLuint[2 * 3 * _numChildNodeLeaves[i]]; _segmentIdxBuffers[i].idxBuff[k] = new GLuint[2 * 3 * _numChildNodeLeaves[i]];
assert(_segmentIdxBuffers[i].idxBuff[k] != NULL); assert(_segmentIdxBuffers[i].idxBuff[k]);
} }
VoxelOpt2RenderAssembleData args; VoxelOpt2RenderAssembleData args;
@ -267,7 +267,7 @@ void SvoViewer::InitializeVoxelOpt2RenderSystem()
delete [] _readVertexStructs; delete [] _readVertexStructs;
//delete [] _readIndicesArray; //delete [] _readIndicesArray;
delete [] faceCenters; delete [] faceCenters;
for (int k = 0; k < NUM_CUBE_FACES; k++) if (_segmentIdxBuffers[i].idxBuff[k] != NULL) delete [] _segmentIdxBuffers[i].idxBuff[k]; for (int k = 0; k < NUM_CUBE_FACES; k++) if (_segmentIdxBuffers[i].idxBuff[k]) delete [] _segmentIdxBuffers[i].idxBuff[k];
} }
_voxelOptRenderInitialized = true; _voxelOptRenderInitialized = true;