-
X
-
Y
-
Z
+
X
+
Y
+
Z
@@ -1566,33 +1567,33 @@
Atmosphere Scattering Wavelenghts
diff --git a/examples/toys/bubblewand/bubble.js b/examples/toys/bubblewand/bubble.js
deleted file mode 100644
index 3cc68fecfa..0000000000
--- a/examples/toys/bubblewand/bubble.js
+++ /dev/null
@@ -1,54 +0,0 @@
-// bubble.js
-// part of bubblewand
-//
-// Created by James B. Pollack @imgntn -- 09/03/2015
-// Copyright 2015 High Fidelity, Inc.
-//
-// example of a nested entity. it doesn't do much now besides delete itself if it collides with something (bubbles are fragile! it would be cool if it sometimes merged with other bubbbles it hit)
-// todo: play bubble sounds from the bubble itself instead of the wand.
-// blocker: needs some sound fixes and a way to find its own position before unload for spatialization
-//
-// Distributed under the Apache License, Version 2.0.
-// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
-
-
-(function() {
- // Script.include("https://raw.githubusercontent.com/highfidelity/hifi/master/examples/utilities.js");
- // Script.include("https://raw.githubusercontent.com/highfidelity/hifi/master/examples/libraries/utils.js");
-
- //var popSound;
- this.preload = function(entityID) {
- // print('bubble preload')
- this.entityID = entityID;
- // popSound = SoundCache.getSound("http://hifi-public.s3.amazonaws.com/james/bubblewand/sounds/pop.wav");
-
- }
-
- this.collisionWithEntity = function(myID, otherID, collision) {
- //if(Entites.getEntityProperties(otherID).userData.objectType==='') { merge bubbles?}
- // Entities.deleteEntity(myID);
- // this.burstBubbleSound(collision.contactPoint)
-
- };
-
- this.unload = function(entityID) {
- // this.properties = Entities.getEntityProperties(entityID);
- //var location = this.properties.position;
- //this.burstBubbleSound();
- };
-
-
-
- this.burstBubbleSound = function(location) {
-
- // var audioOptions = {
- // volume: 0.5,
- // position: location
- // }
-
- //Audio.playSound(popSound, audioOptions);
-
- }
-
-
-})
\ No newline at end of file
diff --git a/examples/toys/bubblewand/createWand.js b/examples/toys/bubblewand/createWand.js
index 15c347d62a..25649a9aad 100644
--- a/examples/toys/bubblewand/createWand.js
+++ b/examples/toys/bubblewand/createWand.js
@@ -1,42 +1,43 @@
// createWand.js
// part of bubblewand
//
+// Script Type: Entity Spawner
// Created by James B. Pollack @imgntn -- 09/03/2015
// Copyright 2015 High Fidelity, Inc.
-//
-// Loads a wand model and attaches the bubble wand behavior.
+//
+// Loads a wand model and attaches the bubble wand behavior.
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
+/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
+Script.include("../../utilities.js");
+Script.include("../../libraries/utils.js");
+var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/wand.fbx';
+var WAND_COLLISION_SHAPE = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/collisionHull.obj';
+var WAND_SCRIPT_URL = Script.resolvePath("wand.js");
-Script.include("https://raw.githubusercontent.com/highfidelity/hifi/master/examples/utilities.js");
-Script.include("https://raw.githubusercontent.com/highfidelity/hifi/master/examples/libraries/utils.js");
+//create the wand in front of the avatar
-var wandModel = "http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/wand.fbx?" + randInt(0, 10000);
-var scriptURL = "http://hifi-public.s3.amazonaws.com/james/bubblewand/scripts/wand.js?" + randInt(1, 100500)
+var center = Vec3.sum(Vec3.sum(MyAvatar.position, {x: 0, y: 0.5, z: 0}), Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation())));
-
-//create the wand in front of the avatar
-var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation())));
var wand = Entities.addEntity({
- type: "Model",
- modelURL: wandModel,
- position: center,
- dimensions: {
- x: 0.1,
- y: 1,
- z: 0.1
- },
- //must be enabled to be grabbable in the physics engine
- collisionsWillMove: true,
- shapeType: 'box',
- script: scriptURL
-});
-
-function cleanup() {
- Entities.deleteEntity(wand);
-}
-
-
-Script.scriptEnding.connect(cleanup);
\ No newline at end of file
+ name: 'Bubble Wand',
+ type: "Model",
+ modelURL: WAND_MODEL,
+ position: center,
+ gravity: {
+ x: 0,
+ y: 0,
+ z: 0,
+ },
+ dimensions: {
+ x: 0.05,
+ y: 0.25,
+ z: 0.05
+ },
+ //must be enabled to be grabbable in the physics engine
+ collisionsWillMove: true,
+ compoundShapeURL: WAND_COLLISION_SHAPE,
+ script: WAND_SCRIPT_URL
+});
\ No newline at end of file
diff --git a/examples/toys/bubblewand/wand.js b/examples/toys/bubblewand/wand.js
index be1042ab79..707b0fd47f 100644
--- a/examples/toys/bubblewand/wand.js
+++ b/examples/toys/bubblewand/wand.js
@@ -1,317 +1,203 @@
// wand.js
// part of bubblewand
//
+// Script Type: Entity Script
// Created by James B. Pollack @imgntn -- 09/03/2015
// Copyright 2015 High Fidelity, Inc.
//
-// Makes bubbles when you wave the object around, or hold it near your mouth and make noise into the microphone.
+// Makes bubbles when you wave the object around.
//
-// For the example, it's attached to a wand -- but you can attach it to whatever entity you want. I dream of BubbleBees :) bzzzz...pop!
-//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
-function convertRange(value, r1, r2) {
- return (value - r1[0]) * (r2[1] - r2[0]) / (r1[1] - r1[0]) + r2[0];
-}
+/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
-(function() {
- Script.include("https://raw.githubusercontent.com/highfidelity/hifi/master/examples/utilities.js");
- Script.include("https://raw.githubusercontent.com/highfidelity/hifi/master/examples/libraries/utils.js");
+(function () {
- var bubbleModel = "http://hifi-public.s3.amazonaws.com/james/bubblewand/models/bubble/bubble.fbx";
- var bubbleScript = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/scripts/bubble.js?' + randInt(1, 10000);
- var popSound = SoundCache.getSound("http://hifi-public.s3.amazonaws.com/james/bubblewand/sounds/pop.wav");
+ Script.include("../../utilities.js");
+ Script.include("../../libraries/utils.js");
- var TARGET_SIZE = 0.4;
- var TARGET_COLOR = {
- red: 128,
- green: 128,
- blue: 128
- };
- var TARGET_COLOR_HIT = {
- red: 0,
- green: 255,
- blue: 0
+ var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/james/bubblewand/models/bubble/bubble.fbx";
+
+ var BUBBLE_INITIAL_DIMENSIONS = {
+ x: 0.01,
+ y: 0.01,
+ z: 0.01
};
- var HAND_SIZE = 0.25;
- var leftCubePosition = MyAvatar.getLeftPalmPosition();
- var rightCubePosition = MyAvatar.getRightPalmPosition();
+ var BUBBLE_LIFETIME_MIN = 3;
+ var BUBBLE_LIFETIME_MAX = 8;
+ var BUBBLE_SIZE_MIN = 0.02;
+ var BUBBLE_SIZE_MAX = 0.1;
+ var BUBBLE_LINEAR_DAMPING = 0.4;
+ var BUBBLE_GRAVITY_MIN = 0.1;
+ var BUBBLE_GRAVITY_MAX = 0.3;
+ var GROWTH_FACTOR = 0.005;
+ var SHRINK_FACTOR = 0.001;
+ var SHRINK_LOWER_LIMIT = 0.02;
+ var WAND_TIP_OFFSET = 0.095;
+ var VELOCITY_THRESHOLD = 0.5;
- var leftHand = Overlays.addOverlay("cube", {
- position: leftCubePosition,
- size: HAND_SIZE,
- color: {
- red: 0,
- green: 0,
- blue: 255
- },
- alpha: 1,
- solid: false
- });
+ //this helps us get the time passed since the last function call, for use in velocity calculations
+ function interval() {
+ var lastTime = new Date().getTime() / 1000;
- var rightHand = Overlays.addOverlay("cube", {
- position: rightCubePosition,
- size: HAND_SIZE,
- color: {
- red: 255,
- green: 0,
- blue: 0
- },
- alpha: 1,
- solid: false
- });
-
- var gustZoneOverlay = Overlays.addOverlay("cube", {
- position: getGustDetectorPosition(),
- size: TARGET_SIZE,
- color: TARGET_COLOR,
- alpha: 1,
- solid: false
- });
-
-
- function getGustDetectorPosition() {
- //put the zone in front of your avatar's face
- var DISTANCE_IN_FRONT = 0.2;
- var DISTANCE_UP = 0.5;
- var DISTANCE_TO_SIDE = 0.0;
-
- var up = Quat.getUp(MyAvatar.orientation);
- var front = Quat.getFront(MyAvatar.orientation);
- var right = Quat.getRight(MyAvatar.orientation);
-
- var upOffset = Vec3.multiply(up, DISTANCE_UP);
- var rightOffset = Vec3.multiply(right, DISTANCE_TO_SIDE);
- var frontOffset = Vec3.multiply(front, DISTANCE_IN_FRONT);
-
- var offset = Vec3.sum(Vec3.sum(rightOffset, frontOffset), upOffset);
- var position = Vec3.sum(MyAvatar.position, offset);
- return position;
+ return function getInterval() {
+ var newTime = new Date().getTime() / 1000;
+ var delta = newTime - lastTime;
+ lastTime = newTime;
+ return delta;
+ };
}
+ var checkInterval = interval();
- var BUBBLE_GRAVITY = {
- x: 0,
- y: -0.05,
- z: 0
+ function BubbleWand() {
+ return;
}
-
- var wandEntity = this;
-
- this.preload = function(entityID) {
- // print('PRELOAD')
- this.entityID = entityID;
- this.properties = Entities.getEntityProperties(this.entityID);
- }
-
- this.unload = function(entityID) {
- Overlays.deleteOverlay(leftHand);
- Overlays.deleteOverlay(rightHand);
- Overlays.deleteOverlay(gustZoneOverlay)
- Entities.editEntity(entityID, {
- name: ""
- });
- Script.update.disconnect(BubbleWand.update);
- Entities.deleteEntity(BubbleWand.currentBubble);
- while (BubbleWand.bubbles.length > 0) {
- Entities.deleteEntity(BubbleWand.bubbles.pop());
- }
-
- };
-
-
- var BubbleWand = {
- bubbles: [],
+ BubbleWand.prototype = {
+ timePassed: null,
currentBubble: null,
- update: function() {
- BubbleWand.internalUpdate();
+ preload: function (entityID) {
+ this.entityID = entityID;
},
- internalUpdate: function() {
- var _t = this;
- //get the current position of the wand
- var properties = Entities.getEntityProperties(wandEntity.entityID);
+ getWandTipPosition: function (properties) {
+ //the tip of the wand is going to be in a different place than the center, so we move in space relative to the model to find that position
+ var upVector = Quat.getUp(properties.rotation);
+ var upOffset = Vec3.multiply(upVector, WAND_TIP_OFFSET);
+ var wandTipPosition = Vec3.sum(properties.position, upOffset);
+ return wandTipPosition;
+ },
+ addCollisionsToBubbleAfterCreation: function (bubble) {
+ //if the bubble collide immediately, we get weird effects. so we add collisions after release
+ Entities.editEntity(bubble, {
+ collisionsWillMove: true
+ });
+ },
+ randomizeBubbleGravity: function () {
+ //change up the gravity a little bit for variation in floating effects
+ var randomNumber = randFloat(BUBBLE_GRAVITY_MIN, BUBBLE_GRAVITY_MAX);
+ var gravity = {
+ x: 0,
+ y: -randomNumber,
+ z: 0
+ };
+ return gravity;
+ },
+ growBubbleWithWandVelocity: function (properties, deltaTime) {
+ //get the wand and tip position for calculations
var wandPosition = properties.position;
+ this.getWandTipPosition(properties);
+ // velocity = change in position / time
+ var velocity = Vec3.multiply(Vec3.subtract(wandPosition, this.lastPosition), 1 / deltaTime);
- //debug overlays for mouth mode
- var leftHandPos = MyAvatar.getLeftPalmPosition();
- var rightHandPos = MyAvatar.getRightPalmPosition();
- Overlays.editOverlay(leftHand, {
- position: leftHandPos
- });
- Overlays.editOverlay(rightHand, {
- position: rightHandPos
- });
-
- //if the wand is in the gust detector, activate mouth mode and change the overlay color
- var hitTargetWithWand = findSphereSphereHit(wandPosition, HAND_SIZE / 2, getGustDetectorPosition(), TARGET_SIZE / 2)
-
- var mouthMode;
- if (hitTargetWithWand) {
- Overlays.editOverlay(gustZoneOverlay, {
- position: getGustDetectorPosition(),
- color: TARGET_COLOR_HIT
- })
- mouthMode = true;
-
- } else {
- Overlays.editOverlay(gustZoneOverlay, {
- position: getGustDetectorPosition(),
- color: TARGET_COLOR
- })
- mouthMode = false;
- }
-
- var volumeLevel = MyAvatar.audioAverageLoudness;
- //volume numbers are pretty large, so lets scale them down.
- var convertedVolume = convertRange(volumeLevel, [0, 5000], [0, 10]);
-
- // default is 'wave mode', where waving the object around grows the bubbles
- var velocity = Vec3.subtract(wandPosition, BubbleWand.lastPosition)
+ var velocityStrength = Vec3.length(velocity);
//store the last position of the wand for velocity calculations
- _t.lastPosition = wandPosition;
-
- // velocity numbers are pretty small, so lets make them a bit bigger
- var velocityStrength = Vec3.length(velocity) * 100;
-
- if (velocityStrength > 10) {
- velocityStrength = 10
- }
+ this.lastPosition = wandPosition;
//actually grow the bubble
- var dimensions = Entities.getEntityProperties(_t.currentBubble).dimensions;
-
- if (velocityStrength > 1 || convertedVolume > 1) {
+ var dimensions = Entities.getEntityProperties(this.currentBubble, "dimensions").dimensions;
+ if (velocityStrength > VELOCITY_THRESHOLD) {
//add some variation in bubble sizes
- var bubbleSize = randInt(1, 5);
- bubbleSize = bubbleSize / 10;
-
+ var bubbleSize = randFloat(BUBBLE_SIZE_MIN, BUBBLE_SIZE_MAX);
//release the bubble if its dimensions are bigger than the bubble size
if (dimensions.x > bubbleSize) {
+
//bubbles pop after existing for a bit -- so set a random lifetime
- var lifetime = randInt(3, 8);
+ var lifetime = randInt(BUBBLE_LIFETIME_MIN, BUBBLE_LIFETIME_MAX);
- //sound is somewhat unstable at the moment so this is commented out. really audio should be played by the bubbles, but there's a blocker.
- // Script.setTimeout(function() {
- // _t.burstBubbleSound(_t.currentBubble)
- // }, lifetime * 1000)
-
-
- //todo: angular velocity without the controller -- forward velocity for mouth mode bubbles
- // var angularVelocity = Controller.getSpatialControlRawAngularVelocity(hands.leftHand.tip);
-
- Entities.editEntity(_t.currentBubble, {
- velocity: Vec3.normalize(velocity),
- // angularVelocity: Controller.getSpatialControlRawAngularVelocity(hands.leftHand.tip),
- lifetime: lifetime
+ //edit the bubble properties at release
+ Entities.editEntity(this.currentBubble, {
+ velocity: velocity,
+ lifetime: lifetime,
+ gravity: this.randomizeBubbleGravity()
});
+ //wait to make the bubbles collidable, so that they dont hit each other and the wand
+ Script.setTimeout(this.addCollisionsToBubbleAfterCreation(this.currentBubble), lifetime / 2);
+
//release the bubble -- when we create a new bubble, it will carry on and this update loop will affect the new bubble
- BubbleWand.spawnBubble();
-
- return
+ this.createBubbleAtTipOfWand();
+ return;
} else {
- if (mouthMode) {
- dimensions.x += 0.015 * convertedVolume;
- dimensions.y += 0.015 * convertedVolume;
- dimensions.z += 0.015 * convertedVolume;
-
- } else {
- dimensions.x += 0.015 * velocityStrength;
- dimensions.y += 0.015 * velocityStrength;
- dimensions.z += 0.015 * velocityStrength;
- }
+ //grow small bubbles
+ dimensions.x += GROWTH_FACTOR * velocityStrength;
+ dimensions.y += GROWTH_FACTOR * velocityStrength;
+ dimensions.z += GROWTH_FACTOR * velocityStrength;
}
+
} else {
- if (dimensions.x >= 0.02) {
- dimensions.x -= 0.001;
- dimensions.y -= 0.001;
- dimensions.z -= 0.001;
+ // if the wand is not moving, make the current bubble smaller
+ if (dimensions.x >= SHRINK_LOWER_LIMIT) {
+ dimensions.x -= SHRINK_FACTOR;
+ dimensions.y -= SHRINK_FACTOR;
+ dimensions.z -= SHRINK_FACTOR;
}
}
- //update the bubble to stay with the wand tip
- Entities.editEntity(_t.currentBubble, {
- position: _t.wandTipPosition,
+ //adjust the bubble dimensions
+ Entities.editEntity(this.currentBubble, {
dimensions: dimensions
});
-
},
- burstBubbleSound: function(bubble) {
- //we want to play the sound at the same location and orientation as the bubble
- var position = Entities.getEntityProperties(bubble).position;
- var orientation = Entities.getEntityProperties(bubble).orientation;
+ createBubbleAtTipOfWand: function () {
- //set the options for the audio injector
- var audioOptions = {
- volume: 0.5,
- position: position,
- orientation: orientation
- }
-
-
- //var audioInjector = Audio.playSound(popSound, audioOptions);
-
- //remove this bubble from the array to keep things clean
- var i = BubbleWand.bubbles.indexOf(bubble);
- if (i != -1) {
- BubbleWand.bubbles.splice(i, 1);
- }
-
- },
- spawnBubble: function() {
- var _t = this;
//create a new bubble at the tip of the wand
- //the tip of the wand is going to be in a different place than the center, so we move in space relative to the model to find that position
-
- var properties = Entities.getEntityProperties(wandEntity.entityID);
+ var properties = Entities.getEntityProperties(this.entityID, ["position", "rotation"]);
var wandPosition = properties.position;
- var upVector = Quat.getUp(properties.rotation);
- var frontVector = Quat.getFront(properties.rotation);
- var upOffset = Vec3.multiply(upVector, 0.5);
- var forwardOffset = Vec3.multiply(frontVector, 0.1);
- var offsetVector = Vec3.sum(upOffset, forwardOffset);
- var wandTipPosition = Vec3.sum(wandPosition, offsetVector);
- _t.wandTipPosition = wandTipPosition;
- //store the position of the tip on spawn for use in velocity calculations
- _t.lastPosition = wandTipPosition;
+ //store the position of the tip for use in velocity calculations
+ this.lastPosition = wandPosition;
//create a bubble at the wand tip
- _t.currentBubble = Entities.addEntity({
+ this.currentBubble = Entities.addEntity({
+ name: 'Bubble',
type: 'Model',
- modelURL: bubbleModel,
- position: wandTipPosition,
- dimensions: {
- x: 0.01,
- y: 0.01,
- z: 0.01
- },
+ modelURL: BUBBLE_MODEL,
+ position: this.getWandTipPosition(properties),
+ dimensions: BUBBLE_INITIAL_DIMENSIONS,
collisionsWillMove: false,
- ignoreForCollisions: true,
- gravity: BUBBLE_GRAVITY,
- // collisionSoundURL:popSound,
- shapeType: "sphere",
- script: bubbleScript,
+ ignoreForCollisions: false,
+ linearDamping: BUBBLE_LINEAR_DAMPING,
+ shapeType: "sphere"
});
- //add this bubble to an array of bubbles so we can keep track of them
- _t.bubbles.push(_t.currentBubble)
+ },
+ startNearGrab: function () {
+ //create a bubble to grow at the start of the grab
+ if (this.currentBubble === null) {
+ this.createBubbleAtTipOfWand();
+ }
+ },
+ continueNearGrab: function () {
+ var deltaTime = checkInterval();
+ //only get the properties that we need
+ var properties = Entities.getEntityProperties(this.entityID, ["position", "rotation"]);
+
+
+ var wandTipPosition = this.getWandTipPosition(properties);
+
+ //update the bubble to stay with the wand tip
+ Entities.editEntity(this.currentBubble, {
+ position: wandTipPosition,
+ });
+ this.growBubbleWithWandVelocity(properties, deltaTime);
},
- init: function() {
- this.spawnBubble();
- Script.update.connect(BubbleWand.update);
- }
- }
+ releaseGrab: function () {
+ //delete the current buble and reset state when the wand is released
+ Entities.deleteEntity(this.currentBubble);
+ this.currentBubble = null;
+ },
- BubbleWand.init();
+ };
-})
\ No newline at end of file
+ return new BubbleWand();
+
+});
\ No newline at end of file
diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp
index 1deb45cf90..c359275d8a 100644
--- a/interface/src/Application.cpp
+++ b/interface/src/Application.cpp
@@ -2614,20 +2614,19 @@ void Application::updateMyAvatarLookAtPosition() {
bool isLookingAtSomeone = false;
bool isHMD = _avatarUpdate->isHMDMode();
glm::vec3 lookAtSpot;
- if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
- // When I am in mirror mode, just look right at the camera (myself); don't switch gaze points because when physically
- // looking in a mirror one's eyes appear steady.
- lookAtSpot = _myCamera.getPosition();
- } else if (eyeTracker->isTracking() && (isHMD || eyeTracker->isSimulating())) {
+ if (eyeTracker->isTracking() && (isHMD || eyeTracker->isSimulating())) {
// Look at the point that the user is looking at.
+ glm::vec3 lookAtPosition = eyeTracker->getLookAtPosition();
+ if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
+ lookAtPosition.x = -lookAtPosition.x;
+ }
if (isHMD) {
glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose();
glm::quat hmdRotation = glm::quat_cast(headPose);
- lookAtSpot = _myCamera.getPosition() +
- _myAvatar->getOrientation() * (hmdRotation * eyeTracker->getLookAtPosition());
+ lookAtSpot = _myCamera.getPosition() + _myAvatar->getOrientation() * (hmdRotation * lookAtPosition);
} else {
- lookAtSpot = _myAvatar->getHead()->getEyePosition() +
- (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * eyeTracker->getLookAtPosition());
+ lookAtSpot = _myAvatar->getHead()->getEyePosition()
+ + (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * lookAtPosition);
}
} else {
AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().lock();
diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp
index a144661f8b..0eeb7222b6 100644
--- a/interface/src/avatar/Hand.cpp
+++ b/interface/src/avatar/Hand.cpp
@@ -51,7 +51,6 @@ void Hand::renderHandTargets(RenderArgs* renderArgs, bool isMine) {
const glm::vec3 greenColor(0.0f, 1.0f, 0.0f); // Color the hand targets red to be different than skin
const glm::vec3 blueColor(0.0f, 0.0f, 1.0f); // Color the hand targets red to be different than skin
const glm::vec3 grayColor(0.5f);
- const int NUM_FACETS = 8;
const float SPHERE_RADIUS = 0.03f * avatarScale;
gpu::Batch& batch = *renderArgs->_batch;
diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp
index 6b56e92d80..f88508ba5b 100644
--- a/interface/src/avatar/SkeletonModel.cpp
+++ b/interface/src/avatar/SkeletonModel.cpp
@@ -635,8 +635,6 @@ void SkeletonModel::computeBoundingShape() {
}
void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha) {
- const int BALL_SUBDIVISIONS = 10;
-
auto geometryCache = DependencyManager::get();
auto deferredLighting = DependencyManager::get();
// draw a blue sphere at the capsule top point
diff --git a/interface/src/devices/3DConnexionClient.cpp b/interface/src/devices/3DConnexionClient.cpp
index 52b4dce68d..b6f2aa8718 100755
--- a/interface/src/devices/3DConnexionClient.cpp
+++ b/interface/src/devices/3DConnexionClient.cpp
@@ -425,6 +425,7 @@ bool ConnexionClient::InitializeRawInput(HWND hwndTarget) {
return false;
}
+ // FIXME - http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe
// Get OS version.
OSVERSIONINFO osvi = { sizeof(OSVERSIONINFO), 0 };
::GetVersionEx(&osvi);
diff --git a/interface/src/ui/ScriptEditorWidget.cpp b/interface/src/ui/ScriptEditorWidget.cpp
index 6d66e04bc6..fa829d4ace 100644
--- a/interface/src/ui/ScriptEditorWidget.cpp
+++ b/interface/src/ui/ScriptEditorWidget.cpp
@@ -97,7 +97,8 @@ bool ScriptEditorWidget::setRunning(bool run) {
if (run) {
const QString& scriptURLString = QUrl(_currentScript).toString();
- _scriptEngine = Application::getInstance()->loadScript(scriptURLString, true, true);
+ // Reload script so that an out of date copy is not retrieved from the cache
+ _scriptEngine = Application::getInstance()->loadScript(scriptURLString, true, true, false, true);
connect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged);
connect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError);
connect(_scriptEngine, &ScriptEngine::printedMessage, this, &ScriptEditorWidget::onScriptPrint);
diff --git a/interface/src/ui/overlays/Circle3DOverlay.cpp b/interface/src/ui/overlays/Circle3DOverlay.cpp
index 588a5077b4..44d8b6861a 100644
--- a/interface/src/ui/overlays/Circle3DOverlay.cpp
+++ b/interface/src/ui/overlays/Circle3DOverlay.cpp
@@ -89,7 +89,6 @@ void Circle3DOverlay::render(RenderArgs* args) {
const float SLICES = 180.0f; // The amount of segment to create the circle
const float SLICE_ANGLE = FULL_CIRCLE / SLICES;
- //const int slices = 15;
xColor colorX = getColor();
const float MAX_COLOR = 255.0f;
glm::vec4 color(colorX.red / MAX_COLOR, colorX.green / MAX_COLOR, colorX.blue / MAX_COLOR, alpha);
diff --git a/interface/src/ui/overlays/Sphere3DOverlay.cpp b/interface/src/ui/overlays/Sphere3DOverlay.cpp
index 0df09d25f6..7caff3ea04 100644
--- a/interface/src/ui/overlays/Sphere3DOverlay.cpp
+++ b/interface/src/ui/overlays/Sphere3DOverlay.cpp
@@ -32,7 +32,6 @@ void Sphere3DOverlay::render(RenderArgs* args) {
return; // do nothing if we're not visible
}
- const int SLICES = 15;
float alpha = getAlpha();
xColor color = getColor();
const float MAX_COLOR = 255.0f;
diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp
index f14fcf4dc0..73e83fa097 100644
--- a/interface/src/ui/overlays/Web3DOverlay.cpp
+++ b/interface/src/ui/overlays/Web3DOverlay.cpp
@@ -29,11 +29,7 @@
#include
-// #include "Application.h"
-// #include "GeometryUtil.h"
-
static const float DPI = 30.47f;
-static const float METERS_TO_INCHES = 39.3701f;
static const float INCHES_TO_METERS = 1.0f / 39.3701f;
QString const Web3DOverlay::TYPE = "web3d";
diff --git a/libraries/animation/src/AnimInverseKinematics.cpp b/libraries/animation/src/AnimInverseKinematics.cpp
index 57459abacb..e31f7795f3 100644
--- a/libraries/animation/src/AnimInverseKinematics.cpp
+++ b/libraries/animation/src/AnimInverseKinematics.cpp
@@ -33,8 +33,10 @@ void AnimInverseKinematics::loadPoses(const AnimPoseVec& poses) {
assert(_skeleton && ((poses.size() == 0) || (_skeleton->getNumJoints() == (int)poses.size())));
if (_skeleton->getNumJoints() == (int)poses.size()) {
_relativePoses = poses;
+ _accumulators.resize(_relativePoses.size());
} else {
_relativePoses.clear();
+ _accumulators.clear();
}
}
@@ -133,8 +135,8 @@ void AnimInverseKinematics::solveWithCyclicCoordinateDescent(std::vector 0) {
- _relativePoses[accumulatorPair.first].rot = accumulator.getAverage();
- accumulator.clear();
+ const int numJoints = (int)_accumulators.size();
+ for (int i = 0; i < numJoints; ++i) {
+ if (_accumulators[i].size() > 0) {
+ _relativePoses[i].rot = _accumulators[i].getAverage();
+ _accumulators[i].clear();
}
}
@@ -299,7 +301,11 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
int numJoints = (int)_relativePoses.size();
for (int i = 0; i < numJoints; ++i) {
float dotSign = copysignf(1.0f, glm::dot(_relativePoses[i].rot, underPoses[i].rot));
- _relativePoses[i].rot = glm::normalize(glm::lerp(_relativePoses[i].rot, dotSign * underPoses[i].rot, blend));
+ if (_accumulators[i].isDirty()) {
+ _relativePoses[i].rot = glm::normalize(glm::lerp(_relativePoses[i].rot, dotSign * underPoses[i].rot, blend));
+ } else {
+ _relativePoses[i].rot = underPoses[i].rot;
+ }
}
}
return evaluate(animVars, dt, triggersOut);
@@ -642,18 +648,3 @@ void AnimInverseKinematics::setSkeletonInternal(AnimSkeleton::ConstPointer skele
clearConstraints();
}
}
-
-void AnimInverseKinematics::relaxTowardDefaults(float dt) {
- // NOTE: for now we just use a single relaxation timescale for all joints, but in the future
- // we could vary the timescale on a per-joint basis or do other fancy things.
-
- // for each joint: lerp towards the default pose
- const float RELAXATION_TIMESCALE = 0.25f;
- const float alpha = glm::clamp(dt / RELAXATION_TIMESCALE, 0.0f, 1.0f);
- int numJoints = (int)_relativePoses.size();
- for (int i = 0; i < numJoints; ++i) {
- float dotSign = copysignf(1.0f, glm::dot(_relativePoses[i].rot, _defaultRelativePoses[i].rot));
- _relativePoses[i].rot = glm::normalize(glm::lerp(_relativePoses[i].rot, dotSign * _defaultRelativePoses[i].rot, alpha));
- }
-}
-
diff --git a/libraries/animation/src/AnimInverseKinematics.h b/libraries/animation/src/AnimInverseKinematics.h
index f2073c01b8..70808f5919 100644
--- a/libraries/animation/src/AnimInverseKinematics.h
+++ b/libraries/animation/src/AnimInverseKinematics.h
@@ -50,8 +50,6 @@ protected:
// for AnimDebugDraw rendering
virtual const AnimPoseVec& getPosesInternal() const override { return _relativePoses; }
- void relaxTowardDefaults(float dt);
-
RotationConstraint* getConstraint(int index);
void clearConstraints();
void initConstraints();
@@ -72,7 +70,7 @@ protected:
};
std::map _constraints;
- std::map _accumulators; // class-member to exploit temporal coherency
+ std::vector _accumulators;
std::vector _targetVarVec;
AnimPoseVec _defaultRelativePoses; // poses of the relaxed state
AnimPoseVec _relativePoses; // current relative poses
diff --git a/libraries/animation/src/RotationAccumulator.cpp b/libraries/animation/src/RotationAccumulator.cpp
index 58ce4b9f36..26bdfd8517 100644
--- a/libraries/animation/src/RotationAccumulator.cpp
+++ b/libraries/animation/src/RotationAccumulator.cpp
@@ -11,17 +11,23 @@
#include
-void RotationAccumulator::add(glm::quat rotation) {
+void RotationAccumulator::add(const glm::quat& rotation) {
// make sure both quaternions are on the same hyper-hemisphere before we add them linearly (lerp)
_rotationSum += copysignf(1.0f, glm::dot(_rotationSum, rotation)) * rotation;
++_numRotations;
+ _isDirty = true;
}
glm::quat RotationAccumulator::getAverage() {
return (_numRotations > 0) ? glm::normalize(_rotationSum) : glm::quat();
}
-void RotationAccumulator::clear() {
+void RotationAccumulator::clear() {
_rotationSum *= 0.0f;
_numRotations = 0;
}
+
+void RotationAccumulator::clearAndClean() {
+ clear();
+ _isDirty = false;
+}
diff --git a/libraries/animation/src/RotationAccumulator.h b/libraries/animation/src/RotationAccumulator.h
index 634a3d0eac..87b1a753c9 100644
--- a/libraries/animation/src/RotationAccumulator.h
+++ b/libraries/animation/src/RotationAccumulator.h
@@ -14,19 +14,27 @@
class RotationAccumulator {
public:
- RotationAccumulator() : _rotationSum(0.0f, 0.0f, 0.0f, 0.0f), _numRotations(0) { }
+ RotationAccumulator() : _rotationSum(0.0f, 0.0f, 0.0f, 0.0f), _numRotations(0), _isDirty(false) { }
int size() const { return _numRotations; }
- void add(glm::quat rotation);
+ void add(const glm::quat& rotation);
glm::quat getAverage();
+ /// \return true if any rotations were accumulated
+ bool isDirty() const { return _isDirty; }
+
+ /// \brief clear accumulated rotation but don't change _isDirty
void clear();
+ /// \brief clear accumulated rotation and set _isDirty to false
+ void clearAndClean();
+
private:
glm::quat _rotationSum;
int _numRotations;
+ bool _isDirty;
};
#endif // hifi_RotationAccumulator_h
diff --git a/libraries/entities-renderer/src/RenderableDebugableEntityItem.cpp b/libraries/entities-renderer/src/RenderableDebugableEntityItem.cpp
index a13ed5b06d..f103aaed4c 100644
--- a/libraries/entities-renderer/src/RenderableDebugableEntityItem.cpp
+++ b/libraries/entities-renderer/src/RenderableDebugableEntityItem.cpp
@@ -25,8 +25,8 @@ void RenderableDebugableEntityItem::renderBoundingBox(EntityItem* entity, Render
gpu::Batch& batch = *args->_batch;
auto shapeTransform = entity->getTransformToCenter();
- if (puffedOut != 0.0) {
- shapeTransform.postScale(1.0 + puffedOut);
+ if (puffedOut != 0.0f) {
+ shapeTransform.postScale(1.0f + puffedOut);
}
batch.setModelTransform(Transform()); // we want to include the scale as well
DependencyManager::get()->renderWireCubeInstance(batch, shapeTransform, color);
diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp
index d1798df397..da240e826a 100644
--- a/libraries/fbx/src/FBXReader.cpp
+++ b/libraries/fbx/src/FBXReader.cpp
@@ -934,8 +934,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
_textureContent.insert(filename, content);
}
} else if (object.name == "Material") {
- FBXMaterial material = { glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(), glm::vec2(0.f, 1.0f), 96.0f, 1.0f,
- QString("")};
+ FBXMaterial material(glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f), glm::vec3(), glm::vec2(0.f, 1.0f), 96.0f, 1.0f);
foreach (const FBXNode& subobject, object.children) {
bool properties = false;
QByteArray propertyName;
diff --git a/libraries/fbx/src/FBXReader.h b/libraries/fbx/src/FBXReader.h
index 3027eb52cc..5cfff9826f 100644
--- a/libraries/fbx/src/FBXReader.h
+++ b/libraries/fbx/src/FBXReader.h
@@ -136,6 +136,16 @@ public:
class FBXMaterial {
public:
+ FBXMaterial() {};
+ FBXMaterial(const glm::vec3& diffuseColor, const glm::vec3& specularColor, const glm::vec3& emissiveColor,
+ const glm::vec2& emissiveParams, float shininess, float opacity) :
+ diffuseColor(diffuseColor),
+ specularColor(specularColor),
+ emissiveColor(emissiveColor),
+ emissiveParams(emissiveParams),
+ shininess(shininess),
+ opacity(opacity) {}
+
glm::vec3 diffuseColor;
glm::vec3 specularColor;
glm::vec3 emissiveColor;
diff --git a/libraries/fbx/src/OBJReader.cpp b/libraries/fbx/src/OBJReader.cpp
index c2cd77e5bc..619aa901bb 100644
--- a/libraries/fbx/src/OBJReader.cpp
+++ b/libraries/fbx/src/OBJReader.cpp
@@ -487,11 +487,10 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping,
groupMaterialName = SMART_DEFAULT_MATERIAL_NAME;
}
if (!groupMaterialName.isEmpty()) {
- OBJMaterial* material = &materials[groupMaterialName];
-
// TODO Fix this once the transision is understood
/*// The code behind this is in transition. Some things are set directly in the FXBMeshPart...
+ OBJMaterial* material = &materials[groupMaterialName];
meshPart.materialID = groupMaterialName;
meshPart.diffuseTexture.filename = material->diffuseTextureFilename;
meshPart.specularTexture.filename = material->specularTextureFilename;
diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp
index 62508f273c..ab8c90a2c8 100644
--- a/libraries/gpu/src/gpu/GLBackend.cpp
+++ b/libraries/gpu/src/gpu/GLBackend.cpp
@@ -337,6 +337,8 @@ void GLBackend::do_drawIndexedInstanced(Batch& batch, uint32 paramOffset) {
glDrawElementsInstanced(mode, numIndices, glType, reinterpret_cast(startIndex + _input._indexBufferOffset), numInstances);
(void)CHECK_GL_ERROR();
+
+ Q_UNUSED(startInstance);
}
void GLBackend::do_resetStages(Batch& batch, uint32 paramOffset) {
diff --git a/libraries/gpu/src/gpu/Stream.cpp b/libraries/gpu/src/gpu/Stream.cpp
index 98d23ac266..61150ab90e 100644
--- a/libraries/gpu/src/gpu/Stream.cpp
+++ b/libraries/gpu/src/gpu/Stream.cpp
@@ -18,7 +18,7 @@ using namespace gpu;
using ElementArray = std::array;
const ElementArray& getDefaultElements() {
- static ElementArray defaultElements{
+ static ElementArray defaultElements{{
//POSITION = 0,
Element::VEC3F_XYZ,
//NORMAL = 1,
@@ -42,7 +42,7 @@ const ElementArray& getDefaultElements() {
//INSTANCE_XFM = 10,
// FIXME make a matrix element
Element::VEC4F_XYZW
- };
+ }};
return defaultElements;
}
diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp
index a66fda624d..780cf83649 100644
--- a/libraries/model-networking/src/model-networking/ModelCache.cpp
+++ b/libraries/model-networking/src/model-networking/ModelCache.cpp
@@ -270,7 +270,7 @@ static NetworkMesh* buildNetworkMesh(const FBXMesh& mesh, const QUrl& textureBas
NetworkMesh* networkMesh = new NetworkMesh();
int totalIndices = 0;
- bool checkForTexcoordLightmap = false;
+ //bool checkForTexcoordLightmap = false;
@@ -393,8 +393,7 @@ static NetworkMaterial* buildNetworkMaterial(const FBXMaterial& material, const
auto textureCache = DependencyManager::get();
NetworkMaterial* networkMaterial = new NetworkMaterial();
- int totalIndices = 0;
- bool checkForTexcoordLightmap = false;
+ //bool checkForTexcoordLightmap = false;
networkMaterial->_material = material._material;
@@ -430,7 +429,7 @@ static NetworkMaterial* buildNetworkMaterial(const FBXMaterial& material, const
networkMaterial->emissiveTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.emissiveTexture.filename)), EMISSIVE_TEXTURE, material.emissiveTexture.content);
networkMaterial->emissiveTextureName = material.emissiveTexture.name;
- checkForTexcoordLightmap = true;
+ //checkForTexcoordLightmap = true;
auto lightmapMap = model::TextureMapPointer(new model::TextureMap());
lightmapMap->setTextureSource(networkMaterial->emissiveTexture->_textureSource);
@@ -492,9 +491,9 @@ void NetworkGeometry::modelParseError(int error, QString str) {
const NetworkMaterial* NetworkGeometry::getShapeMaterial(int shapeID) {
- if ((shapeID >= 0) && (shapeID < _shapes.size())) {
+ if ((shapeID >= 0) && (shapeID < (int)_shapes.size())) {
int materialID = _shapes[shapeID]->_materialID;
- if ((materialID >= 0) && (materialID < _materials.size())) {
+ if ((materialID >= 0) && ((unsigned int)materialID < _materials.size())) {
return _materials[materialID].get();
} else {
return 0;
diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp
index c2551d276d..e3031e2b4d 100755
--- a/libraries/model/src/model/TextureMap.cpp
+++ b/libraries/model/src/model/TextureMap.cpp
@@ -59,7 +59,7 @@ gpu::Texture* TextureUsage::create2DTextureFromImage(const QImage& srcImage, con
int opaquePixels = 0;
int translucentPixels = 0;
- bool isTransparent = false;
+ //bool isTransparent = false;
int redTotal = 0, greenTotal = 0, blueTotal = 0, alphaTotal = 0;
const int EIGHT_BIT_MAXIMUM = 255;
QColor averageColor(EIGHT_BIT_MAXIMUM, EIGHT_BIT_MAXIMUM, EIGHT_BIT_MAXIMUM);
@@ -112,7 +112,7 @@ gpu::Texture* TextureUsage::create2DTextureFromImage(const QImage& srcImage, con
averageColor = QColor(redTotal / imageArea,
greenTotal / imageArea, blueTotal / imageArea, alphaTotal / imageArea);
- isTransparent = (translucentPixels >= imageArea / 2);
+ //isTransparent = (translucentPixels >= imageArea / 2);
}
gpu::Texture* theTexture = nullptr;
@@ -269,7 +269,7 @@ gpu::Texture* TextureUsage::createCubeTextureFromImage(const QImage& srcImage, c
int opaquePixels = 0;
int translucentPixels = 0;
- bool isTransparent = false;
+ //bool isTransparent = false;
int redTotal = 0, greenTotal = 0, blueTotal = 0, alphaTotal = 0;
const int EIGHT_BIT_MAXIMUM = 255;
QColor averageColor(EIGHT_BIT_MAXIMUM, EIGHT_BIT_MAXIMUM, EIGHT_BIT_MAXIMUM);
@@ -322,7 +322,7 @@ gpu::Texture* TextureUsage::createCubeTextureFromImage(const QImage& srcImage, c
averageColor = QColor(redTotal / imageArea,
greenTotal / imageArea, blueTotal / imageArea, alphaTotal / imageArea);
- isTransparent = (translucentPixels >= imageArea / 2);
+ //isTransparent = (translucentPixels >= imageArea / 2);
}
gpu::Texture* theTexture = nullptr;
diff --git a/libraries/networking/src/udt/ConnectionStats.cpp b/libraries/networking/src/udt/ConnectionStats.cpp
index 4cc9b17e64..e7efe3d5af 100644
--- a/libraries/networking/src/udt/ConnectionStats.cpp
+++ b/libraries/networking/src/udt/ConnectionStats.cpp
@@ -85,30 +85,30 @@ static const double EWMA_PREVIOUS_SAMPLES_WEIGHT = 1.0 - EWMA_CURRENT_SAMPLE_WEI
void ConnectionStats::recordSendRate(int sample) {
_currentSample.sendRate = sample;
- _total.sendRate = (_total.sendRate * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT);
+ _total.sendRate = (int)((_total.sendRate * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT));
}
void ConnectionStats::recordReceiveRate(int sample) {
_currentSample.receiveRate = sample;
- _total.receiveRate = (_total.receiveRate * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT);
+ _total.receiveRate = (int)((_total.receiveRate * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT));
}
void ConnectionStats::recordEstimatedBandwidth(int sample) {
_currentSample.estimatedBandwith = sample;
- _total.estimatedBandwith = (_total.estimatedBandwith * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT);
+ _total.estimatedBandwith = (int)((_total.estimatedBandwith * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT));
}
void ConnectionStats::recordRTT(int sample) {
_currentSample.rtt = sample;
- _total.rtt = (_total.rtt * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT);
+ _total.rtt = (int)((_total.rtt * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT));
}
void ConnectionStats::recordCongestionWindowSize(int sample) {
_currentSample.congestionWindowSize = sample;
- _total.congestionWindowSize = (_total.congestionWindowSize * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT);
+ _total.congestionWindowSize = (int)((_total.congestionWindowSize * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT));
}
void ConnectionStats::recordPacketSendPeriod(int sample) {
_currentSample.packetSendPeriod = sample;
- _total.packetSendPeriod = (_total.packetSendPeriod * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT);
+ _total.packetSendPeriod = (int)((_total.packetSendPeriod * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT));
}
diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp
index b120bb8a57..d23d60cf49 100644
--- a/libraries/render-utils/src/DeferredLightingEffect.cpp
+++ b/libraries/render-utils/src/DeferredLightingEffect.cpp
@@ -435,7 +435,7 @@ void DeferredLightingEffect::render(RenderArgs* args) {
args->_context->getStereoProjections(projMats);
args->_context->getStereoViews(eyeViews);
- float halfWidth = 0.5 * sWidth;
+ float halfWidth = 0.5f * sWidth;
for (int i = 0; i < numPasses; i++) {
// In stereo, the 2 sides are layout side by side in the mono viewport and their width is half
diff --git a/libraries/render-utils/src/GLEscrow.cpp b/libraries/render-utils/src/GLEscrow.cpp
deleted file mode 100644
index 253af35d92..0000000000
--- a/libraries/render-utils/src/GLEscrow.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-//
-// Created by Bradley Austin Davis on 2015/08/06.
-// Copyright 2015 High Fidelity, Inc.
-//
-// Distributed under the Apache License, Version 2.0.
-// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
-//
-
-#include "GLEscrow.h"
diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp
index 093434f079..d117b5f729 100644
--- a/libraries/render-utils/src/GeometryCache.cpp
+++ b/libraries/render-utils/src/GeometryCache.cpp
@@ -36,17 +36,18 @@
const int GeometryCache::UNKNOWN_ID = -1;
-static const uint FLOATS_PER_VERTEX = 3;
-static const uint VERTICES_PER_TRIANGLE = 3;
-static const uint TRIANGLES_PER_QUAD = 2;
-static const uint CUBE_FACES = 6;
-static const uint CUBE_VERTICES_PER_FACE = 4;
-static const uint CUBE_VERTICES = CUBE_FACES * CUBE_VERTICES_PER_FACE;
-static const uint CUBE_VERTEX_POINTS = CUBE_VERTICES * FLOATS_PER_VERTEX;
-static const uint CUBE_INDICES = CUBE_FACES * TRIANGLES_PER_QUAD * VERTICES_PER_TRIANGLE;
-static const uint SPHERE_LATITUDES = 24;
-static const uint SPHERE_MERIDIANS = SPHERE_LATITUDES * 2;
-static const uint SPHERE_INDICES = SPHERE_MERIDIANS * (SPHERE_LATITUDES - 1) * TRIANGLES_PER_QUAD * VERTICES_PER_TRIANGLE;
+static const int VERTICES_PER_TRIANGLE = 3;
+
+//static const uint FLOATS_PER_VERTEX = 3;
+//static const uint TRIANGLES_PER_QUAD = 2;
+//static const uint CUBE_FACES = 6;
+//static const uint CUBE_VERTICES_PER_FACE = 4;
+//static const uint CUBE_VERTICES = CUBE_FACES * CUBE_VERTICES_PER_FACE;
+//static const uint CUBE_VERTEX_POINTS = CUBE_VERTICES * FLOATS_PER_VERTEX;
+//static const uint CUBE_INDICES = CUBE_FACES * TRIANGLES_PER_QUAD * VERTICES_PER_TRIANGLE;
+//static const uint SPHERE_LATITUDES = 24;
+//static const uint SPHERE_MERIDIANS = SPHERE_LATITUDES * 2;
+//static const uint SPHERE_INDICES = SPHERE_MERIDIANS * (SPHERE_LATITUDES - 1) * TRIANGLES_PER_QUAD * VERTICES_PER_TRIANGLE;
static const gpu::Element POSITION_ELEMENT{ gpu::VEC3, gpu::FLOAT, gpu::XYZ };
static const gpu::Element NORMAL_ELEMENT{ gpu::VEC3, gpu::FLOAT, gpu::XYZ };
@@ -122,9 +123,9 @@ void GeometryCache::ShapeData::drawWireInstances(gpu::Batch& batch, size_t count
}
const VertexVector& icosahedronVertices() {
- static const float phi = (1.0 + sqrt(5.0)) / 2.0;
- static const float a = 0.5;
- static const float b = 1.0 / (2.0 * phi);
+ static const float phi = (1.0f + sqrtf(5.0f)) / 2.0f;
+ static const float a = 0.5f;
+ static const float b = 1.0f / (2.0f * phi);
static const VertexVector vertices{ //
vec3(0, b, -a), vec3(-b, a, 0), vec3(b, a, 0), //
@@ -152,7 +153,7 @@ const VertexVector& icosahedronVertices() {
}
const VertexVector& tetrahedronVertices() {
- static const float a = 1.0f / sqrt(2.0f);
+ static const float a = 1.0f / sqrtf(2.0f);
static const auto A = vec3(0, 1, a);
static const auto B = vec3(0, -1, a);
static const auto C = vec3(1, 0, -a);
@@ -294,7 +295,6 @@ void GeometryCache::buildShapes() {
static const size_t VERTEX_FORMAT_SIZE = 2;
static const size_t VERTEX_OFFSET = 0;
- static const size_t NORMAL_OFFSET = 1;
for (size_t i = 0; i < vertices.size(); ++i) {
auto vertexIndex = i;
@@ -323,7 +323,7 @@ void GeometryCache::buildShapes() {
20, 21, 21, 22, 22, 23, 23, 20, // back
0, 23, 1, 22, 2, 21, 3, 20 // sides
};
- for (int i = 0; i < wireIndices.size(); ++i) {
+ for (unsigned int i = 0; i < wireIndices.size(); ++i) {
indices[i] += startingIndex;
}
@@ -374,7 +374,7 @@ void GeometryCache::buildShapes() {
0, 3, 1, 3, 2, 3,
};
- for (int i = 0; i < wireIndices.size(); ++i) {
+ for (unsigned int i = 0; i < wireIndices.size(); ++i) {
wireIndices[i] += startingIndex;
}
diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp
index 7cf965951b..ff27c3ab62 100644
--- a/libraries/render-utils/src/Model.cpp
+++ b/libraries/render-utils/src/Model.cpp
@@ -1727,9 +1727,7 @@ void Model::segregateMeshGroups() {
// Run through all of the meshes, and place them into their segregated, but unsorted buckets
int shapeID = 0;
for (int i = 0; i < (int)networkMeshes.size(); i++) {
- const NetworkMesh& networkMesh = *(networkMeshes.at(i).get());
const FBXMesh& mesh = geometry.meshes.at(i);
- const MeshState& state = _meshStates.at(i);
// Create the render payloads
int totalParts = mesh.parts.size();
diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h
index a55e83b9ec..de760dc793 100644
--- a/libraries/render-utils/src/Model.h
+++ b/libraries/render-utils/src/Model.h
@@ -192,8 +192,8 @@ public:
void setCauterizeBoneSet(const std::unordered_set& boneSet) { _cauterizeBoneSet = boneSet; }
int getBlendshapeCoefficientsNum() const { return _blendshapeCoefficients.size(); }
- float getBlendshapeCoefficient(unsigned int index) const {
- return index >= _blendshapeCoefficients.size() ? 0.0f : _blendshapeCoefficients.at(index);
+ float getBlendshapeCoefficient(int index) const {
+ return ((index < 0) && (index >= _blendshapeCoefficients.size())) ? 0.0f : _blendshapeCoefficients.at(index);
}
protected:
diff --git a/libraries/render-utils/src/OglplusHelpers.h b/libraries/render-utils/src/OglplusHelpers.h
index 99232b97cb..4734b8b213 100644
--- a/libraries/render-utils/src/OglplusHelpers.h
+++ b/libraries/render-utils/src/OglplusHelpers.h
@@ -24,6 +24,11 @@
#define OGLPLUS_NO_SITE_CONFIG 1
#define OGLPLUS_LOW_PROFILE 1
+// NOTE: oglplus does some naked "#pragma GCC" without proper platform wrapping, so we need to disable this warning.
+#ifdef _WIN32
+#pragma warning(push)
+#pragma warning( disable : 4068 )
+#endif
#include
#include
@@ -34,6 +39,10 @@
#include
#include
+#ifdef _WIN32
+#pragma warning(pop)
+#endif
+
#include "NumericalConstants.h"
using FramebufferPtr = std::shared_ptr;
diff --git a/libraries/shared/src/MatrixStack.cpp b/libraries/shared/src/MatrixStack.cpp
deleted file mode 100644
index 2a2817a413..0000000000
--- a/libraries/shared/src/MatrixStack.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-//
-// Created by Bradley Austin Davis
-// Copyright 2013 High Fidelity, Inc.
-//
-// Distributed under the Apache License, Version 2.0.
-// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
-//
-
-#include "MatrixStack.h"
diff --git a/libraries/shared/src/shared/ReadWriteLockable.cpp b/libraries/shared/src/shared/ReadWriteLockable.cpp
deleted file mode 100644
index 04b71cf64f..0000000000
--- a/libraries/shared/src/shared/ReadWriteLockable.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-//
-// Created by Bradley Austin Davis on 2015/09/10
-// Copyright 2013-2015 High Fidelity, Inc.
-//
-// Distributed under the Apache License, Version 2.0.
-// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
-//
-
-#include "ReadWriteLockable.h"
-
diff --git a/tests/entities/src/main.cpp b/tests/entities/src/main.cpp
index 8eac7e931f..1b150ee3f5 100644
--- a/tests/entities/src/main.cpp
+++ b/tests/entities/src/main.cpp
@@ -93,10 +93,6 @@ template
void testByteCountCoded() {
testByteCountCodedStable(0);
testByteCountCodedStable(1);
- // These two can't possibly be right. TODO: figure out what was being tested, here
- // testByteCountCodedStable(1 << 8*sizeof(T));
- // testByteCountCodedStable(std::numeric_limits::max() >> 8*sizeof(T));
- testByteCountCodedStable(std::numeric_limits::max() >> 8);
testByteCountCodedStable(std::numeric_limits::max() >> 1);
testByteCountCodedStable(std::numeric_limits::max());
}
diff --git a/tests/gpu-test/src/main.cpp b/tests/gpu-test/src/main.cpp
index ad9ed9bb4a..f8eb361cb9 100644
--- a/tests/gpu-test/src/main.cpp
+++ b/tests/gpu-test/src/main.cpp
@@ -175,8 +175,6 @@ public:
}
void draw() {
- static auto startTime = usecTimestampNow();
-
if (!isVisible()) {
return;
}
@@ -192,7 +190,7 @@ public:
glm::vec3 unitscale { 1.0f };
glm::vec3 up { 0.0f, 1.0f, 0.0f };
- glm::vec3 camera_position { 1.5f * sinf(t), 0.0f, 1.5f * cos(t) };
+ glm::vec3 camera_position { 1.5f * sinf(t), 0.0f, 1.5f * cosf(t) };
static const vec3 camera_focus(0);
static const vec3 camera_up(0, 1, 0);
@@ -251,9 +249,9 @@ public:
static auto startUsecs = usecTimestampNow();
float seconds = getSeconds(startUsecs);
- seconds /= 4.0;
+ seconds /= 4.0f;
int shapeIndex = ((int)seconds) % 4;
- bool wire = seconds - floor(seconds) > 0.5f;
+ bool wire = seconds - (float)floor(seconds) > 0.5f;
batch.setModelTransform(Transform());
batch._glColor4f(0.8f, 0.25f, 0.25f, 1.0f);