mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 15:13:41 +02:00
merge upstream/master into andrew/inertia
This commit is contained in:
commit
cee7a4db10
41 changed files with 1222 additions and 3337 deletions
|
@ -38,17 +38,19 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing")
|
||||
endif(WIN32)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
if (NOT MSVC12)
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
|
||||
if (COMPILER_SUPPORTS_CXX11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
else()
|
||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
||||
endif()
|
||||
if (COMPILER_SUPPORTS_CXX11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
else()
|
||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++0x")
|
||||
|
|
742
examples/controllers/hydra/hydraGrab.js
Normal file
742
examples/controllers/hydra/hydraGrab.js
Normal file
|
@ -0,0 +1,742 @@
|
|||
//
|
||||
// hydraGrab.js
|
||||
// examples
|
||||
//
|
||||
// Created by Clément Brisset on 4/24/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// This script allows you to edit models either with the razor hydras or with your mouse
|
||||
//
|
||||
// Using the hydras :
|
||||
// grab models with the triggers, you can then move the models around or scale them with both hands.
|
||||
// You can switch mode using the bumpers so that you can move models around more easily.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
Script.include("libraries/entityPropertyDialogBox.js");
|
||||
var entityPropertyDialogBox = EntityPropertyDialogBox;
|
||||
|
||||
var LASER_WIDTH = 4;
|
||||
var LASER_COLOR = { red: 255, green: 0, blue: 0 };
|
||||
var LASER_LENGTH_FACTOR = 500;
|
||||
|
||||
var MIN_ANGULAR_SIZE = 2;
|
||||
var MAX_ANGULAR_SIZE = 45;
|
||||
var allowLargeModels = false;
|
||||
var allowSmallModels = false;
|
||||
var wantEntityGlow = false;
|
||||
|
||||
var LEFT = 0;
|
||||
var RIGHT = 1;
|
||||
|
||||
var jointList = MyAvatar.getJointNames();
|
||||
|
||||
var mode = 0;
|
||||
|
||||
function controller(wichSide) {
|
||||
this.side = wichSide;
|
||||
this.palm = 2 * wichSide;
|
||||
this.tip = 2 * wichSide + 1;
|
||||
this.trigger = wichSide;
|
||||
this.bumper = 6 * wichSide + 5;
|
||||
|
||||
this.oldPalmPosition = Controller.getSpatialControlPosition(this.palm);
|
||||
this.palmPosition = Controller.getSpatialControlPosition(this.palm);
|
||||
|
||||
this.oldTipPosition = Controller.getSpatialControlPosition(this.tip);
|
||||
this.tipPosition = Controller.getSpatialControlPosition(this.tip);
|
||||
|
||||
this.oldUp = Controller.getSpatialControlNormal(this.palm);
|
||||
this.up = this.oldUp;
|
||||
|
||||
this.oldFront = Vec3.normalize(Vec3.subtract(this.tipPosition, this.palmPosition));
|
||||
this.front = this.oldFront;
|
||||
|
||||
this.oldRight = Vec3.cross(this.front, this.up);
|
||||
this.right = this.oldRight;
|
||||
|
||||
this.oldRotation = Quat.multiply(MyAvatar.orientation, Controller.getSpatialControlRawRotation(this.palm));
|
||||
this.rotation = this.oldRotation;
|
||||
|
||||
this.triggerValue = Controller.getTriggerValue(this.trigger);
|
||||
this.bumperValue = Controller.isButtonPressed(this.bumper);
|
||||
|
||||
this.pressed = false; // is trigger pressed
|
||||
this.pressing = false; // is trigger being pressed (is pressed now but wasn't previously)
|
||||
|
||||
this.grabbing = false;
|
||||
this.entityID = { isKnownID: false };
|
||||
this.modelURL = "";
|
||||
this.oldModelRotation;
|
||||
this.oldModelPosition;
|
||||
this.oldModelHalfDiagonal;
|
||||
|
||||
this.positionAtGrab;
|
||||
this.rotationAtGrab;
|
||||
this.modelPositionAtGrab;
|
||||
this.rotationAtGrab;
|
||||
this.jointsIntersectingFromStart = [];
|
||||
|
||||
this.laser = Overlays.addOverlay("line3d", {
|
||||
start: { x: 0, y: 0, z: 0 },
|
||||
end: { x: 0, y: 0, z: 0 },
|
||||
color: LASER_COLOR,
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: LASER_WIDTH,
|
||||
anchor: "MyAvatar"
|
||||
});
|
||||
|
||||
this.guideScale = 0.02;
|
||||
this.ball = Overlays.addOverlay("sphere", {
|
||||
position: { x: 0, y: 0, z: 0 },
|
||||
size: this.guideScale,
|
||||
solid: true,
|
||||
color: { red: 0, green: 255, blue: 0 },
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
anchor: "MyAvatar"
|
||||
});
|
||||
this.leftRight = Overlays.addOverlay("line3d", {
|
||||
start: { x: 0, y: 0, z: 0 },
|
||||
end: { x: 0, y: 0, z: 0 },
|
||||
color: { red: 0, green: 0, blue: 255 },
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: LASER_WIDTH,
|
||||
anchor: "MyAvatar"
|
||||
});
|
||||
this.topDown = Overlays.addOverlay("line3d", {
|
||||
start: { x: 0, y: 0, z: 0 },
|
||||
end: { x: 0, y: 0, z: 0 },
|
||||
color: { red: 0, green: 0, blue: 255 },
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: LASER_WIDTH,
|
||||
anchor: "MyAvatar"
|
||||
});
|
||||
|
||||
|
||||
|
||||
this.grab = function (entityID, properties) {
|
||||
print("Grabbing " + entityID.id);
|
||||
this.grabbing = true;
|
||||
this.entityID = entityID;
|
||||
this.modelURL = properties.modelURL;
|
||||
|
||||
this.oldModelPosition = properties.position;
|
||||
this.oldModelRotation = properties.rotation;
|
||||
this.oldModelHalfDiagonal = Vec3.length(properties.dimensions) / 2.0;
|
||||
|
||||
this.positionAtGrab = this.palmPosition;
|
||||
this.rotationAtGrab = this.rotation;
|
||||
this.modelPositionAtGrab = properties.position;
|
||||
this.rotationAtGrab = properties.rotation;
|
||||
this.jointsIntersectingFromStart = [];
|
||||
for (var i = 0; i < jointList.length; i++) {
|
||||
var distance = Vec3.distance(MyAvatar.getJointPosition(jointList[i]), this.oldModelPosition);
|
||||
if (distance < this.oldModelHalfDiagonal) {
|
||||
this.jointsIntersectingFromStart.push(i);
|
||||
}
|
||||
}
|
||||
this.showLaser(false);
|
||||
}
|
||||
|
||||
this.release = function () {
|
||||
if (this.grabbing) {
|
||||
jointList = MyAvatar.getJointNames();
|
||||
|
||||
var closestJointIndex = -1;
|
||||
var closestJointDistance = 10;
|
||||
for (var i = 0; i < jointList.length; i++) {
|
||||
var distance = Vec3.distance(MyAvatar.getJointPosition(jointList[i]), this.oldModelPosition);
|
||||
if (distance < closestJointDistance) {
|
||||
closestJointDistance = distance;
|
||||
closestJointIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (closestJointIndex != -1) {
|
||||
print("closestJoint: " + jointList[closestJointIndex]);
|
||||
print("closestJointDistance (attach max distance): " + closestJointDistance + " (" + this.oldModelHalfDiagonal + ")");
|
||||
}
|
||||
|
||||
if (closestJointDistance < this.oldModelHalfDiagonal) {
|
||||
|
||||
if (this.jointsIntersectingFromStart.indexOf(closestJointIndex) != -1 ||
|
||||
(leftController.grabbing && rightController.grabbing &&
|
||||
leftController.entityID.id == rightController.entityID.id)) {
|
||||
// Do nothing
|
||||
} else {
|
||||
print("Attaching to " + jointList[closestJointIndex]);
|
||||
var jointPosition = MyAvatar.getJointPosition(jointList[closestJointIndex]);
|
||||
var jointRotation = MyAvatar.getJointCombinedRotation(jointList[closestJointIndex]);
|
||||
|
||||
var attachmentOffset = Vec3.subtract(this.oldModelPosition, jointPosition);
|
||||
attachmentOffset = Vec3.multiplyQbyV(Quat.inverse(jointRotation), attachmentOffset);
|
||||
var attachmentRotation = Quat.multiply(Quat.inverse(jointRotation), this.oldModelRotation);
|
||||
|
||||
MyAvatar.attach(this.modelURL, jointList[closestJointIndex],
|
||||
attachmentOffset, attachmentRotation, 2.0 * this.oldModelHalfDiagonal,
|
||||
true, false);
|
||||
Entities.deleteEntity(this.entityID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.grabbing = false;
|
||||
this.entityID.isKnownID = false;
|
||||
this.jointsIntersectingFromStart = [];
|
||||
this.showLaser(true);
|
||||
}
|
||||
|
||||
this.checkTrigger = function () {
|
||||
if (this.triggerValue > 0.9) {
|
||||
if (this.pressed) {
|
||||
this.pressing = false;
|
||||
} else {
|
||||
this.pressing = true;
|
||||
}
|
||||
this.pressed = true;
|
||||
} else {
|
||||
this.pressing = false;
|
||||
this.pressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.checkEntity = function (properties) {
|
||||
// P P - Model
|
||||
// /| A - Palm
|
||||
// / | d B - unit vector toward tip
|
||||
// / | X - base of the perpendicular line
|
||||
// A---X----->B d - distance fom axis
|
||||
// x x - distance from A
|
||||
//
|
||||
// |X-A| = (P-A).B
|
||||
// X == A + ((P-A).B)B
|
||||
// d = |P-X|
|
||||
|
||||
var A = this.palmPosition;
|
||||
var B = this.front;
|
||||
var P = properties.position;
|
||||
|
||||
var x = Vec3.dot(Vec3.subtract(P, A), B);
|
||||
var y = Vec3.dot(Vec3.subtract(P, A), this.up);
|
||||
var z = Vec3.dot(Vec3.subtract(P, A), this.right);
|
||||
var X = Vec3.sum(A, Vec3.multiply(B, x));
|
||||
var d = Vec3.length(Vec3.subtract(P, X));
|
||||
var halfDiagonal = Vec3.length(properties.dimensions) / 2.0;
|
||||
|
||||
var angularSize = 2 * Math.atan(halfDiagonal / Vec3.distance(Camera.getPosition(), properties.position)) * 180 / 3.14;
|
||||
|
||||
var sizeOK = (allowLargeModels || angularSize < MAX_ANGULAR_SIZE)
|
||||
&& (allowSmallModels || angularSize > MIN_ANGULAR_SIZE);
|
||||
|
||||
if (0 < x && sizeOK) {
|
||||
return { valid: true, x: x, y: y, z: z };
|
||||
}
|
||||
return { valid: false };
|
||||
}
|
||||
|
||||
this.glowedIntersectingModel = { isKnownID: false };
|
||||
this.moveLaser = function () {
|
||||
// the overlays here are anchored to the avatar, which means they are specified in the avatar's local frame
|
||||
|
||||
var inverseRotation = Quat.inverse(MyAvatar.orientation);
|
||||
var startPosition = Vec3.multiplyQbyV(inverseRotation, Vec3.subtract(this.palmPosition, MyAvatar.position));
|
||||
var direction = Vec3.multiplyQbyV(inverseRotation, Vec3.subtract(this.tipPosition, this.palmPosition));
|
||||
var distance = Vec3.length(direction);
|
||||
direction = Vec3.multiply(direction, LASER_LENGTH_FACTOR / distance);
|
||||
var endPosition = Vec3.sum(startPosition, direction);
|
||||
|
||||
Overlays.editOverlay(this.laser, {
|
||||
start: startPosition,
|
||||
end: endPosition
|
||||
});
|
||||
|
||||
|
||||
Overlays.editOverlay(this.ball, {
|
||||
position: endPosition
|
||||
});
|
||||
Overlays.editOverlay(this.leftRight, {
|
||||
start: Vec3.sum(endPosition, Vec3.multiply(this.right, 2 * this.guideScale)),
|
||||
end: Vec3.sum(endPosition, Vec3.multiply(this.right, -2 * this.guideScale))
|
||||
});
|
||||
Overlays.editOverlay(this.topDown, {
|
||||
start: Vec3.sum(endPosition, Vec3.multiply(this.up, 2 * this.guideScale)),
|
||||
end: Vec3.sum(endPosition, Vec3.multiply(this.up, -2 * this.guideScale))
|
||||
});
|
||||
this.showLaser(!this.grabbing || mode == 0);
|
||||
|
||||
if (this.glowedIntersectingModel.isKnownID) {
|
||||
Entities.editEntity(this.glowedIntersectingModel, { glowLevel: 0.0 });
|
||||
this.glowedIntersectingModel.isKnownID = false;
|
||||
}
|
||||
if (!this.grabbing) {
|
||||
var intersection = Entities.findRayIntersection({
|
||||
origin: this.palmPosition,
|
||||
direction: this.front
|
||||
});
|
||||
|
||||
var halfDiagonal = Vec3.length(intersection.properties.dimensions) / 2.0;
|
||||
|
||||
var angularSize = 2 * Math.atan(halfDiagonal / Vec3.distance(Camera.getPosition(), intersection.properties.position)) * 180 / 3.14;
|
||||
var sizeOK = (allowLargeModels || angularSize < MAX_ANGULAR_SIZE)
|
||||
&& (allowSmallModels || angularSize > MIN_ANGULAR_SIZE);
|
||||
if (intersection.accurate && intersection.entityID.isKnownID && sizeOK) {
|
||||
this.glowedIntersectingModel = intersection.entityID;
|
||||
|
||||
if (wantEntityGlow) {
|
||||
Entities.editEntity(this.glowedIntersectingModel, { glowLevel: 0.25 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.showLaser = function (show) {
|
||||
Overlays.editOverlay(this.laser, { visible: show });
|
||||
Overlays.editOverlay(this.ball, { visible: show });
|
||||
Overlays.editOverlay(this.leftRight, { visible: show });
|
||||
Overlays.editOverlay(this.topDown, { visible: show });
|
||||
}
|
||||
this.moveEntity = function () {
|
||||
if (this.grabbing) {
|
||||
if (!this.entityID.isKnownID) {
|
||||
print("Unknown grabbed ID " + this.entityID.id + ", isKnown: " + this.entityID.isKnownID);
|
||||
this.entityID = Entities.findRayIntersection({
|
||||
origin: this.palmPosition,
|
||||
direction: this.front
|
||||
}).entityID;
|
||||
print("Identified ID " + this.entityID.id + ", isKnown: " + this.entityID.isKnownID);
|
||||
}
|
||||
var newPosition;
|
||||
var newRotation;
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
newPosition = Vec3.sum(this.palmPosition,
|
||||
Vec3.multiply(this.front, this.x));
|
||||
newPosition = Vec3.sum(newPosition,
|
||||
Vec3.multiply(this.up, this.y));
|
||||
newPosition = Vec3.sum(newPosition,
|
||||
Vec3.multiply(this.right, this.z));
|
||||
|
||||
|
||||
newRotation = Quat.multiply(this.rotation,
|
||||
Quat.inverse(this.oldRotation));
|
||||
newRotation = Quat.multiply(newRotation,
|
||||
this.oldModelRotation);
|
||||
break;
|
||||
case 1:
|
||||
var forward = Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0, z: -1 });
|
||||
var d = Vec3.dot(forward, MyAvatar.position);
|
||||
|
||||
var factor1 = Vec3.dot(forward, this.positionAtGrab) - d;
|
||||
var factor2 = Vec3.dot(forward, this.modelPositionAtGrab) - d;
|
||||
var vector = Vec3.subtract(this.palmPosition, this.positionAtGrab);
|
||||
|
||||
if (factor2 < 0) {
|
||||
factor2 = 0;
|
||||
}
|
||||
if (factor1 <= 0) {
|
||||
factor1 = 1;
|
||||
factor2 = 1;
|
||||
}
|
||||
|
||||
newPosition = Vec3.sum(this.modelPositionAtGrab,
|
||||
Vec3.multiply(vector,
|
||||
factor2 / factor1));
|
||||
|
||||
newRotation = Quat.multiply(this.rotation,
|
||||
Quat.inverse(this.rotationAtGrab));
|
||||
newRotation = Quat.multiply(newRotation,
|
||||
this.rotationAtGrab);
|
||||
break;
|
||||
}
|
||||
Entities.editEntity(this.entityID, {
|
||||
position: newPosition,
|
||||
rotation: newRotation
|
||||
});
|
||||
this.oldModelRotation = newRotation;
|
||||
this.oldModelPosition = newPosition;
|
||||
|
||||
var indicesToRemove = [];
|
||||
for (var i = 0; i < this.jointsIntersectingFromStart.length; ++i) {
|
||||
var distance = Vec3.distance(MyAvatar.getJointPosition(this.jointsIntersectingFromStart[i]), this.oldModelPosition);
|
||||
if (distance >= this.oldModelHalfDiagonal) {
|
||||
indicesToRemove.push(this.jointsIntersectingFromStart[i]);
|
||||
}
|
||||
|
||||
}
|
||||
for (var i = 0; i < indicesToRemove.length; ++i) {
|
||||
this.jointsIntersectingFromStart.splice(this.jointsIntersectingFromStart.indexOf(indicesToRemove[i], 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.update = function () {
|
||||
this.oldPalmPosition = this.palmPosition;
|
||||
this.oldTipPosition = this.tipPosition;
|
||||
this.palmPosition = Controller.getSpatialControlPosition(this.palm);
|
||||
this.tipPosition = Controller.getSpatialControlPosition(this.tip);
|
||||
|
||||
this.oldUp = this.up;
|
||||
this.up = Vec3.normalize(Controller.getSpatialControlNormal(this.palm));
|
||||
|
||||
this.oldFront = this.front;
|
||||
this.front = Vec3.normalize(Vec3.subtract(this.tipPosition, this.palmPosition));
|
||||
|
||||
this.oldRight = this.right;
|
||||
this.right = Vec3.normalize(Vec3.cross(this.front, this.up));
|
||||
|
||||
this.oldRotation = this.rotation;
|
||||
this.rotation = Quat.multiply(MyAvatar.orientation, Controller.getSpatialControlRawRotation(this.palm));
|
||||
|
||||
this.triggerValue = Controller.getTriggerValue(this.trigger);
|
||||
|
||||
var bumperValue = Controller.isButtonPressed(this.bumper);
|
||||
if (bumperValue && !this.bumperValue) {
|
||||
if (mode == 0) {
|
||||
mode = 1;
|
||||
Overlays.editOverlay(leftController.laser, { color: { red: 0, green: 0, blue: 255 } });
|
||||
Overlays.editOverlay(rightController.laser, { color: { red: 0, green: 0, blue: 255 } });
|
||||
} else {
|
||||
mode = 0;
|
||||
Overlays.editOverlay(leftController.laser, { color: { red: 255, green: 0, blue: 0 } });
|
||||
Overlays.editOverlay(rightController.laser, { color: { red: 255, green: 0, blue: 0 } });
|
||||
}
|
||||
}
|
||||
this.bumperValue = bumperValue;
|
||||
|
||||
|
||||
this.checkTrigger();
|
||||
|
||||
this.moveLaser();
|
||||
|
||||
if (!this.pressed && this.grabbing) {
|
||||
// release if trigger not pressed anymore.
|
||||
this.release();
|
||||
}
|
||||
|
||||
if (this.pressing) {
|
||||
// Checking for attachments intersecting
|
||||
var attachments = MyAvatar.getAttachmentData();
|
||||
var attachmentIndex = -1;
|
||||
var attachmentX = LASER_LENGTH_FACTOR;
|
||||
|
||||
var newModel;
|
||||
var newProperties;
|
||||
|
||||
for (var i = 0; i < attachments.length; ++i) {
|
||||
var position = Vec3.sum(MyAvatar.getJointPosition(attachments[i].jointName),
|
||||
Vec3.multiplyQbyV(MyAvatar.getJointCombinedRotation(attachments[i].jointName), attachments[i].translation));
|
||||
var scale = attachments[i].scale;
|
||||
|
||||
var A = this.palmPosition;
|
||||
var B = this.front;
|
||||
var P = position;
|
||||
|
||||
var x = Vec3.dot(Vec3.subtract(P, A), B);
|
||||
var X = Vec3.sum(A, Vec3.multiply(B, x));
|
||||
var d = Vec3.length(Vec3.subtract(P, X));
|
||||
|
||||
if (d < scale / 2.0 && 0 < x && x < attachmentX) {
|
||||
attachmentIndex = i;
|
||||
attachmentX = d;
|
||||
}
|
||||
}
|
||||
|
||||
if (attachmentIndex != -1) {
|
||||
print("Detaching: " + attachments[attachmentIndex].modelURL);
|
||||
MyAvatar.detachOne(attachments[attachmentIndex].modelURL, attachments[attachmentIndex].jointName);
|
||||
|
||||
newProperties = {
|
||||
type: "Model",
|
||||
position: Vec3.sum(MyAvatar.getJointPosition(attachments[attachmentIndex].jointName),
|
||||
Vec3.multiplyQbyV(MyAvatar.getJointCombinedRotation(attachments[attachmentIndex].jointName), attachments[attachmentIndex].translation)),
|
||||
rotation: Quat.multiply(MyAvatar.getJointCombinedRotation(attachments[attachmentIndex].jointName),
|
||||
attachments[attachmentIndex].rotation),
|
||||
|
||||
// TODO: how do we know the correct dimensions for detachment???
|
||||
dimensions: { x: attachments[attachmentIndex].scale / 2.0,
|
||||
y: attachments[attachmentIndex].scale / 2.0,
|
||||
z: attachments[attachmentIndex].scale / 2.0 },
|
||||
|
||||
modelURL: attachments[attachmentIndex].modelURL
|
||||
};
|
||||
|
||||
newModel = Entities.addEntity(newProperties);
|
||||
|
||||
|
||||
} else {
|
||||
// There is none so ...
|
||||
// Checking model tree
|
||||
Vec3.print("Looking at: ", this.palmPosition);
|
||||
var pickRay = { origin: this.palmPosition,
|
||||
direction: Vec3.normalize(Vec3.subtract(this.tipPosition, this.palmPosition)) };
|
||||
var foundIntersection = Entities.findRayIntersection(pickRay);
|
||||
|
||||
if(!foundIntersection.accurate) {
|
||||
print("No accurate intersection");
|
||||
return;
|
||||
}
|
||||
newModel = foundIntersection.entityID;
|
||||
if (!newModel.isKnownID) {
|
||||
var identify = Entities.identifyEntity(newModel);
|
||||
if (!identify.isKnownID) {
|
||||
print("Unknown ID " + identify.id + " (update loop " + newModel.id + ")");
|
||||
return;
|
||||
}
|
||||
newModel = identify;
|
||||
}
|
||||
newProperties = Entities.getEntityProperties(newModel);
|
||||
}
|
||||
print("foundEntity.modelURL=" + newProperties.modelURL);
|
||||
var check = this.checkEntity(newProperties);
|
||||
if (!check.valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.grab(newModel, newProperties);
|
||||
|
||||
this.x = check.x;
|
||||
this.y = check.y;
|
||||
this.z = check.z;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.cleanup = function () {
|
||||
Overlays.deleteOverlay(this.laser);
|
||||
Overlays.deleteOverlay(this.ball);
|
||||
Overlays.deleteOverlay(this.leftRight);
|
||||
Overlays.deleteOverlay(this.topDown);
|
||||
}
|
||||
}
|
||||
|
||||
var leftController = new controller(LEFT);
|
||||
var rightController = new controller(RIGHT);
|
||||
|
||||
function moveEntities() {
|
||||
if (leftController.grabbing && rightController.grabbing && rightController.entityID.id == leftController.entityID.id) {
|
||||
var newPosition = leftController.oldModelPosition;
|
||||
var rotation = leftController.oldModelRotation;
|
||||
var ratio = 1;
|
||||
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
var oldLeftPoint = Vec3.sum(leftController.oldPalmPosition, Vec3.multiply(leftController.oldFront, leftController.x));
|
||||
var oldRightPoint = Vec3.sum(rightController.oldPalmPosition, Vec3.multiply(rightController.oldFront, rightController.x));
|
||||
|
||||
var oldMiddle = Vec3.multiply(Vec3.sum(oldLeftPoint, oldRightPoint), 0.5);
|
||||
var oldLength = Vec3.length(Vec3.subtract(oldLeftPoint, oldRightPoint));
|
||||
|
||||
|
||||
var leftPoint = Vec3.sum(leftController.palmPosition, Vec3.multiply(leftController.front, leftController.x));
|
||||
var rightPoint = Vec3.sum(rightController.palmPosition, Vec3.multiply(rightController.front, rightController.x));
|
||||
|
||||
var middle = Vec3.multiply(Vec3.sum(leftPoint, rightPoint), 0.5);
|
||||
var length = Vec3.length(Vec3.subtract(leftPoint, rightPoint));
|
||||
|
||||
|
||||
ratio = length / oldLength;
|
||||
newPosition = Vec3.sum(middle,
|
||||
Vec3.multiply(Vec3.subtract(leftController.oldModelPosition, oldMiddle), ratio));
|
||||
break;
|
||||
case 1:
|
||||
var u = Vec3.normalize(Vec3.subtract(rightController.oldPalmPosition, leftController.oldPalmPosition));
|
||||
var v = Vec3.normalize(Vec3.subtract(rightController.palmPosition, leftController.palmPosition));
|
||||
|
||||
var cos_theta = Vec3.dot(u, v);
|
||||
if (cos_theta > 1) {
|
||||
cos_theta = 1;
|
||||
}
|
||||
var angle = Math.acos(cos_theta) / Math.PI * 180;
|
||||
if (angle < 0.1) {
|
||||
return;
|
||||
|
||||
}
|
||||
var w = Vec3.normalize(Vec3.cross(u, v));
|
||||
|
||||
rotation = Quat.multiply(Quat.angleAxis(angle, w), leftController.oldModelRotation);
|
||||
|
||||
|
||||
leftController.positionAtGrab = leftController.palmPosition;
|
||||
leftController.rotationAtGrab = leftController.rotation;
|
||||
leftController.modelPositionAtGrab = leftController.oldModelPosition;
|
||||
leftController.rotationAtGrab = rotation;
|
||||
rightController.positionAtGrab = rightController.palmPosition;
|
||||
rightController.rotationAtGrab = rightController.rotation;
|
||||
rightController.modelPositionAtGrab = rightController.oldModelPosition;
|
||||
rightController.rotationAtGrab = rotation;
|
||||
break;
|
||||
}
|
||||
Entities.editEntity(leftController.entityID, {
|
||||
position: newPosition,
|
||||
rotation: rotation,
|
||||
// TODO: how do we know the correct dimensions for detachment???
|
||||
//radius: leftController.oldModelHalfDiagonal * ratio
|
||||
dimensions: { x: leftController.oldModelHalfDiagonal * ratio,
|
||||
y: leftController.oldModelHalfDiagonal * ratio,
|
||||
z: leftController.oldModelHalfDiagonal * ratio }
|
||||
|
||||
|
||||
});
|
||||
leftController.oldModelPosition = newPosition;
|
||||
leftController.oldModelRotation = rotation;
|
||||
leftController.oldModelHalfDiagonal *= ratio;
|
||||
|
||||
rightController.oldModelPosition = newPosition;
|
||||
rightController.oldModelRotation = rotation;
|
||||
rightController.oldModelHalfDiagonal *= ratio;
|
||||
return;
|
||||
}
|
||||
leftController.moveEntity();
|
||||
rightController.moveEntity();
|
||||
}
|
||||
|
||||
var hydraConnected = false;
|
||||
function checkController(deltaTime) {
|
||||
var numberOfButtons = Controller.getNumberOfButtons();
|
||||
var numberOfTriggers = Controller.getNumberOfTriggers();
|
||||
var numberOfSpatialControls = Controller.getNumberOfSpatialControls();
|
||||
var controllersPerTrigger = numberOfSpatialControls / numberOfTriggers;
|
||||
|
||||
// this is expected for hydras
|
||||
if (numberOfButtons == 12 && numberOfTriggers == 2 && controllersPerTrigger == 2) {
|
||||
if (!hydraConnected) {
|
||||
hydraConnected = true;
|
||||
}
|
||||
|
||||
leftController.update();
|
||||
rightController.update();
|
||||
moveEntities();
|
||||
} else {
|
||||
if (hydraConnected) {
|
||||
hydraConnected = false;
|
||||
|
||||
leftController.showLaser(false);
|
||||
rightController.showLaser(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var glowedEntityID = { id: -1, isKnownID: false };
|
||||
|
||||
// In order for editVoxels and editModels to play nice together, they each check to see if a "delete" menu item already
|
||||
// exists. If it doesn't they add it. If it does they don't. They also only delete the menu item if they were the one that
|
||||
// added it.
|
||||
var modelMenuAddedDelete = false;
|
||||
var originalLightsArePickable = Entities.getLightsArePickable();
|
||||
function setupModelMenus() {
|
||||
print("setupModelMenus()");
|
||||
// adj our menuitems
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Models", isSeparator: true, beforeItem: "Physics" });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Edit Properties...",
|
||||
shortcutKeyEvent: { text: "`" }, afterItem: "Models" });
|
||||
if (!Menu.menuItemExists("Edit", "Delete")) {
|
||||
print("no delete... adding ours");
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Delete",
|
||||
shortcutKeyEvent: { text: "backspace" }, afterItem: "Models" });
|
||||
modelMenuAddedDelete = true;
|
||||
} else {
|
||||
print("delete exists... don't add ours");
|
||||
}
|
||||
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Large Models", shortcutKey: "CTRL+META+L",
|
||||
afterItem: "Paste Models", isCheckable: true });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Small Models", shortcutKey: "CTRL+META+S",
|
||||
afterItem: "Allow Selecting of Large Models", isCheckable: true });
|
||||
Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Lights", shortcutKey: "CTRL+SHIFT+META+L",
|
||||
afterItem: "Allow Selecting of Small Models", isCheckable: true });
|
||||
|
||||
Entities.setLightsArePickable(false);
|
||||
}
|
||||
|
||||
function cleanupModelMenus() {
|
||||
Menu.removeMenuItem("Edit", "Edit Properties...");
|
||||
if (modelMenuAddedDelete) {
|
||||
// delete our menuitems
|
||||
Menu.removeMenuItem("Edit", "Delete");
|
||||
}
|
||||
|
||||
Menu.removeMenuItem("Edit", "Allow Selecting of Large Models");
|
||||
Menu.removeMenuItem("Edit", "Allow Selecting of Small Models");
|
||||
Menu.removeMenuItem("Edit", "Allow Selecting of Lights");
|
||||
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
leftController.cleanup();
|
||||
rightController.cleanup();
|
||||
cleanupModelMenus();
|
||||
Entities.setLightsArePickable(originalLightsArePickable);
|
||||
}
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Script.update.connect(checkController);
|
||||
|
||||
setupModelMenus();
|
||||
|
||||
var editModelID = -1;
|
||||
function showPropertiesForm(editModelID) {
|
||||
entityPropertyDialogBox.openDialog(editModelID);
|
||||
}
|
||||
|
||||
Menu.menuItemEvent.connect(function (menuItem) {
|
||||
print("menuItemEvent() in JS... menuItem=" + menuItem);
|
||||
if (menuItem == "Allow Selecting of Small Models") {
|
||||
allowSmallModels = Menu.isOptionChecked("Allow Selecting of Small Models");
|
||||
} else if (menuItem == "Allow Selecting of Large Models") {
|
||||
allowLargeModels = Menu.isOptionChecked("Allow Selecting of Large Models");
|
||||
} else if (menuItem == "Allow Selecting of Lights") {
|
||||
Entities.setLightsArePickable(Menu.isOptionChecked("Allow Selecting of Lights"));
|
||||
} else if (menuItem == "Delete") {
|
||||
if (leftController.grabbing) {
|
||||
print(" Delete Entity.... leftController.entityID="+ leftController.entityID);
|
||||
Entities.deleteEntity(leftController.entityID);
|
||||
leftController.grabbing = false;
|
||||
if (glowedEntityID.id == leftController.entityID.id) {
|
||||
glowedEntityID = { id: -1, isKnownID: false };
|
||||
}
|
||||
} else if (rightController.grabbing) {
|
||||
print(" Delete Entity.... rightController.entityID="+ rightController.entityID);
|
||||
Entities.deleteEntity(rightController.entityID);
|
||||
rightController.grabbing = false;
|
||||
if (glowedEntityID.id == rightController.entityID.id) {
|
||||
glowedEntityID = { id: -1, isKnownID: false };
|
||||
}
|
||||
} else {
|
||||
print(" Delete Entity.... not holding...");
|
||||
}
|
||||
} else if (menuItem == "Edit Properties...") {
|
||||
editModelID = -1;
|
||||
if (leftController.grabbing) {
|
||||
print(" Edit Properties.... leftController.entityID="+ leftController.entityID);
|
||||
editModelID = leftController.entityID;
|
||||
} else if (rightController.grabbing) {
|
||||
print(" Edit Properties.... rightController.entityID="+ rightController.entityID);
|
||||
editModelID = rightController.entityID;
|
||||
} else {
|
||||
print(" Edit Properties.... not holding...");
|
||||
}
|
||||
if (editModelID != -1) {
|
||||
print(" Edit Properties.... about to edit properties...");
|
||||
showPropertiesForm(editModelID);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Controller.keyReleaseEvent.connect(function (event) {
|
||||
// since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items
|
||||
if (event.text == "`") {
|
||||
handeMenuEvent("Edit Properties...");
|
||||
}
|
||||
if (event.text == "BACKSPACE") {
|
||||
handeMenuEvent("Delete");
|
||||
}
|
||||
});
|
||||
|
|
@ -1077,6 +1077,19 @@ PropertiesTool = function(opts) {
|
|||
pushCommandForSelections();
|
||||
selectionManager._update();
|
||||
}
|
||||
} else if (data.action == "rescaleDimensions") {
|
||||
var multiplier = data.percentage / 100;
|
||||
if (selectionManager.hasSelection()) {
|
||||
selectionManager.saveProperties();
|
||||
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
|
||||
Entities.editEntity(selectionManager.selections[i], {
|
||||
dimensions: Vec3.multiply(multiplier, properties.dimensions),
|
||||
});
|
||||
}
|
||||
pushCommandForSelections();
|
||||
selectionManager._update();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -84,6 +84,8 @@
|
|||
var elDimensionsY = document.getElementById("property-dim-y");
|
||||
var elDimensionsZ = document.getElementById("property-dim-z");
|
||||
var elResetToNaturalDimensions = document.getElementById("reset-to-natural-dimensions");
|
||||
var elRescaleDimensionsPct = document.getElementById("dimension-rescale-pct");
|
||||
var elRescaleDimensionsButton = document.getElementById("dimension-rescale-button");
|
||||
|
||||
var elRegistrationX = document.getElementById("property-reg-x");
|
||||
var elRegistrationY = document.getElementById("property-reg-y");
|
||||
|
@ -419,6 +421,13 @@
|
|||
action: "resetToNaturalDimensions",
|
||||
}));
|
||||
});
|
||||
elRescaleDimensionsButton.addEventListener("click", function() {
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: "action",
|
||||
action: "rescaleDimensions",
|
||||
percentage: parseInt(elRescaleDimensionsPct.value),
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
var resizing = false;
|
||||
|
@ -537,6 +546,12 @@
|
|||
<div>
|
||||
<input type="button" id="reset-to-natural-dimensions" value="Reset to Natural Dimensions">
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<input class="coord" type='number' id="dimension-rescale-pct" value=100></input>%
|
||||
</div>
|
||||
<span>
|
||||
<input type="button" id="dimension-rescale-button" value="Rescale"></input>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
|
@ -138,11 +138,13 @@ function drawLobby() {
|
|||
// add an attachment on this avatar so other people see them in the lobby
|
||||
MyAvatar.attach(HELMET_ATTACHMENT_URL, "Neck", {x: 0, y: 0, z: 0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.15);
|
||||
|
||||
// start the drone sound
|
||||
// currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME });
|
||||
if (droneSound.downloaded) {
|
||||
// start the drone sound
|
||||
currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME });
|
||||
}
|
||||
|
||||
// start one of our muzak sounds
|
||||
// playRandomMuzak();
|
||||
playRandomMuzak();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,9 +355,9 @@ function update(deltaTime) {
|
|||
Overlays.editOverlay(descriptionText, { position: textOverlayPosition() });
|
||||
|
||||
// if the reticle is up then we may need to play the next muzak
|
||||
// if (!Audio.isInjectorPlaying(currentMuzakInjector)) {
|
||||
// playNextMuzak();
|
||||
// }
|
||||
if (currentMuzakInjector && !Audio.isInjectorPlaying(currentMuzakInjector)) {
|
||||
playNextMuzak();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
13
interface/external/sdl2/readme.txt
vendored
Normal file
13
interface/external/sdl2/readme.txt
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
Instructions for adding the SDL library (SDL2) to Interface
|
||||
David Rowe, 11 Jan 2015
|
||||
|
||||
You can download the SDL development library from https://www.libsdl.org/. Interface has been tested with version 2.0.3.
|
||||
|
||||
1. Copy the include and lib folders into the interface/externals/sdl2 folder.
|
||||
This readme.txt should be there as well.
|
||||
|
||||
You may optionally choose to copy the SDK folders to a location outside the repository (so you can re-use with different checkouts and different projects).
|
||||
If so our CMake find module expects you to set the ENV variable 'HIFI_LIB_DIR' to a directory containing a subfolder 'sdl2' that contains the two folders mentioned above.
|
||||
|
||||
2. Clear your build directory, run cmake and build, and you should be all set.
|
|
@ -880,7 +880,7 @@ bool Audio::outputLocalInjector(bool isStereo, qreal volume, AudioInjector* inje
|
|||
localFormat.setChannelCount(isStereo ? 2 : 1);
|
||||
|
||||
QAudioOutput* localOutput = new QAudioOutput(getNamedAudioDeviceForMode(QAudio::AudioOutput, _outputAudioDeviceName),
|
||||
localFormat, this);
|
||||
localFormat);
|
||||
localOutput->setVolume(volume);
|
||||
|
||||
// move the localOutput to the same thread as the local injector buffer
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QColorDialog>
|
||||
#include <QDialogButtonBox>
|
||||
|
@ -44,20 +43,26 @@
|
|||
#include "Audio.h"
|
||||
#include "audio/AudioIOStatsRenderer.h"
|
||||
#include "audio/AudioScope.h"
|
||||
#include "devices/Faceshift.h"
|
||||
#include "devices/OculusManager.h"
|
||||
#include "devices/Visage.h"
|
||||
#include "Menu.h"
|
||||
#include "scripting/LocationScriptingInterface.h"
|
||||
#include "scripting/MenuScriptingInterface.h"
|
||||
#include "Util.h"
|
||||
#include "ui/AddressBarDialog.h"
|
||||
#include "ui/AnimationsDialog.h"
|
||||
#include "ui/AttachmentsDialog.h"
|
||||
#include "ui/BandwidthDialog.h"
|
||||
#include "ui/CachesSizeDialog.h"
|
||||
#include "ui/DataWebDialog.h"
|
||||
#include "ui/HMDToolsDialog.h"
|
||||
#include "ui/LodToolsDialog.h"
|
||||
#include "ui/LoginDialog.h"
|
||||
#include "ui/OctreeStatsDialog.h"
|
||||
#include "ui/PreferencesDialog.h"
|
||||
#include "ui/InfoView.h"
|
||||
#include "ui/MetavoxelEditor.h"
|
||||
#include "ui/MetavoxelNetworkSimulator.h"
|
||||
#include "ui/ModelsBrowser.h"
|
||||
#include "ui/LoginDialog.h"
|
||||
#include "ui/NodeBounds.h"
|
||||
|
||||
Menu* Menu::_instance = NULL;
|
||||
|
@ -79,56 +84,9 @@ Menu* Menu::getInstance() {
|
|||
return _instance;
|
||||
}
|
||||
|
||||
const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f;
|
||||
const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost";
|
||||
const float DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER = 1.0f;
|
||||
const int ONE_SECOND_OF_FRAMES = 60;
|
||||
const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES;
|
||||
|
||||
const QString CONSOLE_TITLE = "Scripting Console";
|
||||
const float CONSOLE_WINDOW_OPACITY = 0.95f;
|
||||
const int CONSOLE_WIDTH = 800;
|
||||
const int CONSOLE_HEIGHT = 200;
|
||||
|
||||
Menu::Menu() :
|
||||
_actionHash(),
|
||||
_receivedAudioStreamSettings(),
|
||||
_bandwidthDialog(NULL),
|
||||
_fieldOfView(DEFAULT_FIELD_OF_VIEW_DEGREES),
|
||||
_realWorldFieldOfView(DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
|
||||
_faceshiftEyeDeflection(DEFAULT_FACESHIFT_EYE_DEFLECTION),
|
||||
_faceshiftHostname(DEFAULT_FACESHIFT_HOSTNAME),
|
||||
_jsConsole(NULL),
|
||||
_octreeStatsDialog(NULL),
|
||||
_lodToolsDialog(NULL),
|
||||
_hmdToolsDialog(NULL),
|
||||
_newLocationDialog(NULL),
|
||||
_userLocationsDialog(NULL),
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
_speechRecognizer(),
|
||||
#endif
|
||||
_octreeSizeScale(DEFAULT_OCTREE_SIZE_SCALE),
|
||||
_oculusUIAngularSize(DEFAULT_OCULUS_UI_ANGULAR_SIZE),
|
||||
_sixenseReticleMoveSpeed(DEFAULT_SIXENSE_RETICLE_MOVE_SPEED),
|
||||
_invertSixenseButtons(DEFAULT_INVERT_SIXENSE_MOUSE_BUTTONS),
|
||||
_automaticAvatarLOD(true),
|
||||
_avatarLODDecreaseFPS(DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS),
|
||||
_avatarLODIncreaseFPS(ADJUST_LOD_UP_FPS),
|
||||
_avatarLODDistanceMultiplier(DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER),
|
||||
_boundaryLevelAdjust(0),
|
||||
_maxOctreePacketsPerSecond(DEFAULT_MAX_OCTREE_PPS),
|
||||
_lastAdjust(usecTimestampNow()),
|
||||
_lastAvatarDetailDrop(usecTimestampNow()),
|
||||
_fpsAverage(FIVE_SECONDS_OF_FRAMES),
|
||||
_fastFPSAverage(ONE_SECOND_OF_FRAMES),
|
||||
_loginAction(NULL),
|
||||
_preferencesDialog(NULL),
|
||||
_loginDialog(NULL),
|
||||
_hasLoginDialogDisplayed(false),
|
||||
_snapshotsLocation(),
|
||||
_scriptsLocation(),
|
||||
_walletPrivateKey(),
|
||||
_shouldRenderTableNeedsRebuilding(true)
|
||||
_lastAvatarDetailDrop(usecTimestampNow())
|
||||
{
|
||||
Application *appInstance = Application::getInstance();
|
||||
|
||||
|
@ -492,6 +450,7 @@ Menu::Menu() :
|
|||
false,
|
||||
&UserActivityLogger::getInstance(),
|
||||
SLOT(disable(bool)));
|
||||
addActionToQMenuAndActionHash(networkMenu, MenuOption::CachesSize, 0, this, SLOT(cachesSizeDialog()));
|
||||
|
||||
addActionToQMenuAndActionHash(developerMenu, MenuOption::WalletPrivateKey, 0, this, SLOT(changePrivateKey()));
|
||||
|
||||
|
@ -619,15 +578,6 @@ Menu::Menu() :
|
|||
#endif
|
||||
}
|
||||
|
||||
Menu::~Menu() {
|
||||
bandwidthDetailsClosed();
|
||||
octreeStatsDetailsClosed();
|
||||
if (_hmdToolsDialog) {
|
||||
delete _hmdToolsDialog;
|
||||
_hmdToolsDialog = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::loadSettings(QSettings* settings) {
|
||||
bool lockedSettings = false;
|
||||
if (!settings) {
|
||||
|
@ -1153,7 +1103,7 @@ void Menu::bandwidthDetails() {
|
|||
if (! _bandwidthDialog) {
|
||||
_bandwidthDialog = new BandwidthDialog(DependencyManager::get<GLCanvas>().data(),
|
||||
Application::getInstance()->getBandwidthMeter());
|
||||
connect(_bandwidthDialog, SIGNAL(closed()), SLOT(bandwidthDetailsClosed()));
|
||||
connect(_bandwidthDialog, SIGNAL(closed()), _bandwidthDialog, SLOT(deleteLater()));
|
||||
|
||||
_bandwidthDialog->show();
|
||||
|
||||
|
@ -1253,18 +1203,11 @@ void Menu::audioMuteToggled() {
|
|||
}
|
||||
}
|
||||
|
||||
void Menu::bandwidthDetailsClosed() {
|
||||
if (_bandwidthDialog) {
|
||||
delete _bandwidthDialog;
|
||||
_bandwidthDialog = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::octreeStatsDetails() {
|
||||
if (!_octreeStatsDialog) {
|
||||
_octreeStatsDialog = new OctreeStatsDialog(DependencyManager::get<GLCanvas>().data(),
|
||||
Application::getInstance()->getOcteeSceneStats());
|
||||
connect(_octreeStatsDialog, SIGNAL(closed()), SLOT(octreeStatsDetailsClosed()));
|
||||
connect(_octreeStatsDialog, SIGNAL(closed()), _octreeStatsDialog, SLOT(deleteLater()));
|
||||
_octreeStatsDialog->show();
|
||||
if (_hmdToolsDialog) {
|
||||
_hmdToolsDialog->watchWindow(_octreeStatsDialog->windowHandle());
|
||||
|
@ -1273,13 +1216,6 @@ void Menu::octreeStatsDetails() {
|
|||
_octreeStatsDialog->raise();
|
||||
}
|
||||
|
||||
void Menu::octreeStatsDetailsClosed() {
|
||||
if (_octreeStatsDialog) {
|
||||
delete _octreeStatsDialog;
|
||||
_octreeStatsDialog = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
QString Menu::getLODFeedbackText() {
|
||||
// determine granularity feedback
|
||||
int boundaryLevelAdjust = getBoundaryLevelAdjust();
|
||||
|
@ -1443,11 +1379,23 @@ bool Menu::shouldRenderMesh(float largestDimension, float distanceToCamera) {
|
|||
return (distanceToCamera <= visibleDistanceAtClosestScale);
|
||||
}
|
||||
|
||||
void Menu::cachesSizeDialog() {
|
||||
qDebug() << "Caches size:" << _cachesSizeDialog.isNull();
|
||||
if (!_cachesSizeDialog) {
|
||||
_cachesSizeDialog = new CachesSizeDialog(DependencyManager::get<GLCanvas>().data());
|
||||
connect(_cachesSizeDialog, SIGNAL(closed()), _cachesSizeDialog, SLOT(deleteLater()));
|
||||
_cachesSizeDialog->show();
|
||||
if (_hmdToolsDialog) {
|
||||
_hmdToolsDialog->watchWindow(_cachesSizeDialog->windowHandle());
|
||||
}
|
||||
}
|
||||
_cachesSizeDialog->raise();
|
||||
}
|
||||
|
||||
void Menu::lodTools() {
|
||||
if (!_lodToolsDialog) {
|
||||
_lodToolsDialog = new LodToolsDialog(DependencyManager::get<GLCanvas>().data());
|
||||
connect(_lodToolsDialog, SIGNAL(closed()), SLOT(lodToolsClosed()));
|
||||
connect(_lodToolsDialog, SIGNAL(closed()), _lodToolsDialog, SLOT(deleteLater()));
|
||||
_lodToolsDialog->show();
|
||||
if (_hmdToolsDialog) {
|
||||
_hmdToolsDialog->watchWindow(_lodToolsDialog->windowHandle());
|
||||
|
@ -1456,13 +1404,6 @@ void Menu::lodTools() {
|
|||
_lodToolsDialog->raise();
|
||||
}
|
||||
|
||||
void Menu::lodToolsClosed() {
|
||||
if (_lodToolsDialog) {
|
||||
delete _lodToolsDialog;
|
||||
_lodToolsDialog = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::hmdTools(bool showTools) {
|
||||
if (showTools) {
|
||||
if (!_hmdToolsDialog) {
|
||||
|
|
|
@ -27,14 +27,13 @@
|
|||
#include "SpeechRecognizer.h"
|
||||
#endif
|
||||
|
||||
#include "ui/AddressBarDialog.h"
|
||||
#include "devices/Faceshift.h"
|
||||
#include "devices/SixenseManager.h"
|
||||
#include "ui/ChatWindow.h"
|
||||
#include "ui/DataWebDialog.h"
|
||||
#include "ui/JSConsole.h"
|
||||
#include "ui/LoginDialog.h"
|
||||
#include "ui/PreferencesDialog.h"
|
||||
#include "ui/ScriptEditorWindow.h"
|
||||
|
||||
// Make an LOD handler class and move everything overthere
|
||||
const float ADJUST_LOD_DOWN_FPS = 40.0;
|
||||
const float ADJUST_LOD_UP_FPS = 55.0;
|
||||
const float DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f;
|
||||
|
@ -50,26 +49,37 @@ const float ADJUST_LOD_MAX_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE;
|
|||
|
||||
const float MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 0.1f;
|
||||
const float MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 15.0f;
|
||||
const float DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER = 1.0f;
|
||||
|
||||
const int ONE_SECOND_OF_FRAMES = 60;
|
||||
const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES;
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f;
|
||||
|
||||
const QString SETTINGS_ADDRESS_KEY = "address";
|
||||
class QSettings;
|
||||
|
||||
class AddressBarDialog;
|
||||
class AnimationsDialog;
|
||||
class AttachmentsDialog;
|
||||
class CachesSizeDialog;
|
||||
class BandwidthDialog;
|
||||
class DataWebDialog;
|
||||
class HMDToolsDialog;
|
||||
class LodToolsDialog;
|
||||
class LoginDialog;
|
||||
class OctreeStatsDialog;
|
||||
class PreferencesDialog;
|
||||
class MetavoxelEditor;
|
||||
class MetavoxelNetworkSimulator;
|
||||
class ChatWindow;
|
||||
class OctreeStatsDialog;
|
||||
class MenuItemProperties;
|
||||
|
||||
class Menu : public QMenuBar {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static Menu* getInstance();
|
||||
~Menu();
|
||||
|
||||
void triggerOption(const QString& menuOption);
|
||||
QAction* getActionForOption(const QString& menuOption);
|
||||
|
@ -159,6 +169,7 @@ public slots:
|
|||
void showLoginForCurrentDomain();
|
||||
void bandwidthDetails();
|
||||
void octreeStatsDetails();
|
||||
void cachesSizeDialog();
|
||||
void lodTools();
|
||||
void hmdTools(bool showTools);
|
||||
void loadSettings(QSettings* settings = NULL);
|
||||
|
@ -191,9 +202,6 @@ private slots:
|
|||
void changePrivateKey();
|
||||
void nameLocation();
|
||||
void toggleLocationList();
|
||||
void bandwidthDetailsClosed();
|
||||
void octreeStatsDetailsClosed();
|
||||
void lodToolsClosed();
|
||||
void hmdToolsClosed();
|
||||
void runTests();
|
||||
void showMetavoxelEditor();
|
||||
|
@ -242,54 +250,63 @@ private:
|
|||
|
||||
QHash<QString, QAction*> _actionHash;
|
||||
InboundAudioStream::Settings _receivedAudioStreamSettings;
|
||||
BandwidthDialog* _bandwidthDialog;
|
||||
float _fieldOfView; /// in Degrees, doesn't apply to HMD like Oculus
|
||||
float _realWorldFieldOfView; // The actual FOV set by the user's monitor size and view distance
|
||||
float _faceshiftEyeDeflection;
|
||||
QString _faceshiftHostname;
|
||||
// in Degrees, doesn't apply to HMD like Oculus
|
||||
float _fieldOfView = DEFAULT_FIELD_OF_VIEW_DEGREES;
|
||||
// The actual FOV set by the user's monitor size and view distance
|
||||
float _realWorldFieldOfView = DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES;
|
||||
float _faceshiftEyeDeflection = DEFAULT_FACESHIFT_EYE_DEFLECTION;
|
||||
QString _faceshiftHostname = DEFAULT_FACESHIFT_HOSTNAME;
|
||||
|
||||
QDialog* _jsConsole = nullptr;
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
SpeechRecognizer _speechRecognizer;
|
||||
#endif
|
||||
float _octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE;
|
||||
float _oculusUIAngularSize = DEFAULT_OCULUS_UI_ANGULAR_SIZE;
|
||||
float _sixenseReticleMoveSpeed = DEFAULT_SIXENSE_RETICLE_MOVE_SPEED;
|
||||
bool _invertSixenseButtons = DEFAULT_INVERT_SIXENSE_MOUSE_BUTTONS;
|
||||
bool _hasLoginDialogDisplayed = false;
|
||||
|
||||
bool _automaticAvatarLOD = true;
|
||||
float _avatarLODDecreaseFPS = DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS;
|
||||
float _avatarLODIncreaseFPS = ADJUST_LOD_UP_FPS;
|
||||
float _avatarLODDistanceMultiplier = DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER;
|
||||
|
||||
int _boundaryLevelAdjust = 0;
|
||||
int _maxOctreePacketsPerSecond = DEFAULT_MAX_OCTREE_PPS;
|
||||
|
||||
quint64 _lastAdjust;
|
||||
quint64 _lastAvatarDetailDrop;
|
||||
|
||||
SimpleMovingAverage _fpsAverage = FIVE_SECONDS_OF_FRAMES;
|
||||
SimpleMovingAverage _fastFPSAverage = ONE_SECOND_OF_FRAMES;
|
||||
|
||||
QPointer<AddressBarDialog> _addressBarDialog;
|
||||
QPointer<AnimationsDialog> _animationsDialog;
|
||||
QPointer<AttachmentsDialog> _attachmentsDialog;
|
||||
QPointer<BandwidthDialog> _bandwidthDialog;
|
||||
QPointer<CachesSizeDialog> _cachesSizeDialog;
|
||||
QPointer<DataWebDialog> _newLocationDialog;
|
||||
QPointer<DataWebDialog> _userLocationsDialog;
|
||||
QPointer<HMDToolsDialog> _hmdToolsDialog;
|
||||
QPointer<LodToolsDialog> _lodToolsDialog;
|
||||
QPointer<LoginDialog> _loginDialog;
|
||||
QPointer<OctreeStatsDialog> _octreeStatsDialog;
|
||||
QPointer<PreferencesDialog> _preferencesDialog;
|
||||
|
||||
QPointer<MetavoxelEditor> _MetavoxelEditor;
|
||||
QPointer<MetavoxelNetworkSimulator> _metavoxelNetworkSimulator;
|
||||
QPointer<ScriptEditorWindow> _ScriptEditor;
|
||||
QPointer<ChatWindow> _chatWindow;
|
||||
QDialog* _jsConsole;
|
||||
OctreeStatsDialog* _octreeStatsDialog;
|
||||
LodToolsDialog* _lodToolsDialog;
|
||||
HMDToolsDialog* _hmdToolsDialog;
|
||||
QPointer<DataWebDialog> _newLocationDialog;
|
||||
QPointer<DataWebDialog> _userLocationsDialog;
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
SpeechRecognizer _speechRecognizer;
|
||||
#endif
|
||||
float _octreeSizeScale;
|
||||
float _oculusUIAngularSize;
|
||||
float _sixenseReticleMoveSpeed;
|
||||
bool _invertSixenseButtons;
|
||||
bool _automaticAvatarLOD;
|
||||
float _avatarLODDecreaseFPS;
|
||||
float _avatarLODIncreaseFPS;
|
||||
float _avatarLODDistanceMultiplier;
|
||||
int _boundaryLevelAdjust;
|
||||
int _maxOctreePacketsPerSecond;
|
||||
QString replaceLastOccurrence(QChar search, QChar replace, QString string);
|
||||
quint64 _lastAdjust;
|
||||
quint64 _lastAvatarDetailDrop;
|
||||
SimpleMovingAverage _fpsAverage;
|
||||
SimpleMovingAverage _fastFPSAverage;
|
||||
QAction* _loginAction;
|
||||
QPointer<PreferencesDialog> _preferencesDialog;
|
||||
QPointer<AttachmentsDialog> _attachmentsDialog;
|
||||
QPointer<AnimationsDialog> _animationsDialog;
|
||||
QPointer<AddressBarDialog> _addressBarDialog;
|
||||
QPointer<LoginDialog> _loginDialog;
|
||||
bool _hasLoginDialogDisplayed;
|
||||
QAction* _chatAction;
|
||||
|
||||
QAction* _loginAction = nullptr;
|
||||
QAction* _chatAction = nullptr;
|
||||
QString _snapshotsLocation;
|
||||
QString _scriptsLocation;
|
||||
QByteArray _walletPrivateKey;
|
||||
|
||||
bool _shouldRenderTableNeedsRebuilding;
|
||||
bool _shouldRenderTableNeedsRebuilding = true;
|
||||
QMap<float, float> _shouldRenderTable;
|
||||
|
||||
};
|
||||
|
||||
namespace MenuOption {
|
||||
|
@ -318,6 +335,7 @@ namespace MenuOption {
|
|||
const QString BandwidthDetails = "Bandwidth Details";
|
||||
const QString BlueSpeechSphere = "Blue Sphere While Speaking";
|
||||
const QString CascadedShadows = "Cascaded";
|
||||
const QString CachesSize = "Caches Size";
|
||||
const QString Chat = "Chat...";
|
||||
const QString ChatCircling = "Chat Circling";
|
||||
const QString CollideAsRagdoll = "Collide With Self (Ragdoll)";
|
||||
|
@ -406,7 +424,6 @@ namespace MenuOption {
|
|||
const QString RenderTargetFramerate40 = "40";
|
||||
const QString RenderTargetFramerate30 = "30";
|
||||
const QString RenderTargetFramerateVSyncOn = "V-Sync On";
|
||||
|
||||
const QString RenderResolution = "Scale Resolution";
|
||||
const QString RenderResolutionOne = "1";
|
||||
const QString RenderResolutionTwoThird = "2/3";
|
||||
|
|
|
@ -55,7 +55,6 @@ static const QString MODEL_URL = "/api/v1/models";
|
|||
|
||||
static const QString SETTING_NAME = "LastModelUploadLocation";
|
||||
|
||||
static const long long BYTES_PER_MEGABYTES = 1024 * 1024;
|
||||
static const unsigned long long MAX_SIZE = 50 * 1024 * BYTES_PER_MEGABYTES; // 50 GB (Virtually remove limit)
|
||||
static const int MAX_TEXTURE_SIZE = 1024;
|
||||
static const int TIMEOUT = 1000;
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
|
||||
#include "FaceTracker.h"
|
||||
|
||||
const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f;
|
||||
const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost";
|
||||
|
||||
/// Handles interaction with the Faceshift software, which provides head position/orientation and facial features.
|
||||
class Faceshift : public FaceTracker {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "InterfaceConfig.h"
|
||||
|
||||
#include "OculusManager.h"
|
||||
#include "ui/overlays/Text3DOverlay.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <QGuiApplication>
|
||||
|
|
|
@ -19,12 +19,9 @@
|
|||
|
||||
#include <ProgramObject.h>
|
||||
|
||||
#include "ui/overlays/Text3DOverlay.h"
|
||||
|
||||
const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f;
|
||||
|
||||
class Camera;
|
||||
class PalmData;
|
||||
class Text3DOverlay;
|
||||
|
||||
/// Handles interaction with the Oculus Rift.
|
||||
class OculusManager {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#endif
|
||||
|
||||
class PalmData;
|
||||
|
||||
const unsigned int BUTTON_0 = 1U << 0; // the skinny button between 1 and 2
|
||||
const unsigned int BUTTON_1 = 1U << 5;
|
||||
const unsigned int BUTTON_2 = 1U << 6;
|
||||
|
|
|
@ -197,19 +197,23 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) {
|
|||
const float FAR_CLIP = 10000;
|
||||
glLoadIdentity();
|
||||
glOrtho(0, glCanvas->width(), glCanvas->height(), 0, NEAR_CLIP, FAR_CLIP);
|
||||
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
renderAudioMeter();
|
||||
|
||||
|
||||
renderStatsAndLogs();
|
||||
|
||||
|
||||
// give external parties a change to hook in
|
||||
emit application->renderingOverlay();
|
||||
|
||||
|
||||
overlays.renderHUD();
|
||||
|
||||
|
||||
renderPointers();
|
||||
|
||||
|
||||
renderDomainConnectionStatusBorder();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
} glPopMatrix();
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#ifndef hifi_ApplicationOverlay_h
|
||||
#define hifi_ApplicationOverlay_h
|
||||
|
||||
class Camera;
|
||||
class Overlays;
|
||||
class QOpenGLFramebufferObject;
|
||||
|
||||
|
|
85
interface/src/ui/CachesSizeDialog.cpp
Normal file
85
interface/src/ui/CachesSizeDialog.cpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
//
|
||||
// CachesSizeDialog.cpp
|
||||
//
|
||||
//
|
||||
// Created by Clement on 1/12/15.
|
||||
// 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 <QDoubleSpinBox>
|
||||
#include <QFormLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <AnimationCache.h>
|
||||
#include <DependencyManager.h>
|
||||
#include <GeometryCache.h>
|
||||
#include <ScriptCache.h>
|
||||
#include <SoundCache.h>
|
||||
#include <TextureCache.h>
|
||||
|
||||
#include "CachesSizeDialog.h"
|
||||
|
||||
|
||||
QDoubleSpinBox* createDoubleSpinBox(QWidget* parent) {
|
||||
QDoubleSpinBox* box = new QDoubleSpinBox(parent);
|
||||
box->setDecimals(0);
|
||||
box->setRange(MIN_UNUSED_MAX_SIZE / BYTES_PER_MEGABYTES, MAX_UNUSED_MAX_SIZE / BYTES_PER_MEGABYTES);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
CachesSizeDialog::CachesSizeDialog(QWidget* parent) :
|
||||
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint)
|
||||
{
|
||||
setWindowTitle("Caches Size");
|
||||
|
||||
// Create layouter
|
||||
QFormLayout* form = new QFormLayout(this);
|
||||
setLayout(form);
|
||||
|
||||
form->addRow("Animations cache size (MB):", _animations = createDoubleSpinBox(this));
|
||||
form->addRow("Geometries cache size (MB):", _geometries = createDoubleSpinBox(this));
|
||||
form->addRow("Scripts cache size (MB):", _scripts = createDoubleSpinBox(this));
|
||||
form->addRow("Sounds cache size (MB):", _sounds = createDoubleSpinBox(this));
|
||||
form->addRow("Textures cache size (MB):", _textures = createDoubleSpinBox(this));
|
||||
|
||||
resetClicked(true);
|
||||
|
||||
// Add a button to reset
|
||||
QPushButton* confirmButton = new QPushButton("Confirm", this);
|
||||
QPushButton* resetButton = new QPushButton("Reset", this);
|
||||
form->addRow(confirmButton, resetButton);
|
||||
connect(confirmButton, SIGNAL(clicked(bool)), this, SLOT(confirmClicked(bool)));
|
||||
connect(resetButton, SIGNAL(clicked(bool)), this, SLOT(resetClicked(bool)));
|
||||
}
|
||||
|
||||
void CachesSizeDialog::confirmClicked(bool checked) {
|
||||
DependencyManager::get<AnimationCache>()->setUnusedResourceCacheSize(_animations->value() * BYTES_PER_MEGABYTES);
|
||||
DependencyManager::get<GeometryCache>()->setUnusedResourceCacheSize(_geometries->value() * BYTES_PER_MEGABYTES);
|
||||
ScriptCache::getInstance()->setUnusedResourceCacheSize(_scripts->value() * BYTES_PER_MEGABYTES);
|
||||
SoundCache::getInstance().setUnusedResourceCacheSize(_sounds->value() * BYTES_PER_MEGABYTES);
|
||||
DependencyManager::get<TextureCache>()->setUnusedResourceCacheSize(_textures->value() * BYTES_PER_MEGABYTES);
|
||||
|
||||
QDialog::close();
|
||||
}
|
||||
|
||||
void CachesSizeDialog::resetClicked(bool checked) {
|
||||
_animations->setValue(DependencyManager::get<AnimationCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
_geometries->setValue(DependencyManager::get<GeometryCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
_scripts->setValue(ScriptCache::getInstance()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
_sounds->setValue(SoundCache::getInstance().getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
_textures->setValue(DependencyManager::get<TextureCache>()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES);
|
||||
}
|
||||
|
||||
void CachesSizeDialog::reject() {
|
||||
// Just regularly close upon ESC
|
||||
QDialog::close();
|
||||
}
|
||||
|
||||
void CachesSizeDialog::closeEvent(QCloseEvent* event) {
|
||||
QDialog::closeEvent(event);
|
||||
emit closed();
|
||||
}
|
45
interface/src/ui/CachesSizeDialog.h
Normal file
45
interface/src/ui/CachesSizeDialog.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// CachesSizeDialog.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 1/12/15.
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef hifi_CachesSizeDialog_h
|
||||
#define hifi_CachesSizeDialog_h
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
class CachesSizeDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Sets up the UI
|
||||
CachesSizeDialog(QWidget* parent);
|
||||
|
||||
signals:
|
||||
void closed();
|
||||
|
||||
public slots:
|
||||
void reject();
|
||||
void confirmClicked(bool checked);
|
||||
void resetClicked(bool checked);
|
||||
|
||||
protected:
|
||||
// Emits a 'closed' signal when this dialog is closed.
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
private:
|
||||
QDoubleSpinBox* _animations = nullptr;
|
||||
QDoubleSpinBox* _geometries = nullptr;
|
||||
QDoubleSpinBox* _scripts = nullptr;
|
||||
QDoubleSpinBox* _sounds = nullptr;
|
||||
QDoubleSpinBox* _textures = nullptr;
|
||||
};
|
||||
|
||||
#endif // hifi_CachesSizeDialog_h
|
|
@ -20,6 +20,11 @@
|
|||
#include "ui_console.h"
|
||||
#include "ScriptEngine.h"
|
||||
|
||||
const QString CONSOLE_TITLE = "Scripting Console";
|
||||
const float CONSOLE_WINDOW_OPACITY = 0.95f;
|
||||
const int CONSOLE_WIDTH = 800;
|
||||
const int CONSOLE_HEIGHT = 200;
|
||||
|
||||
class JSConsole : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -30,9 +30,9 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) :
|
|||
this->setWindowTitle("LOD Tools");
|
||||
|
||||
// Create layouter
|
||||
QFormLayout* form = new QFormLayout();
|
||||
QFormLayout* form = new QFormLayout(this);
|
||||
|
||||
_lodSize = new QSlider(Qt::Horizontal);
|
||||
_lodSize = new QSlider(Qt::Horizontal, this);
|
||||
const int MAX_LOD_SIZE = MAX_LOD_SIZE_MULTIPLIER;
|
||||
const int MIN_LOD_SIZE = 0;
|
||||
const int STEP_LOD_SIZE = 1;
|
||||
|
@ -50,7 +50,7 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) :
|
|||
form->addRow("LOD Size Scale:", _lodSize);
|
||||
connect(_lodSize,SIGNAL(valueChanged(int)),this,SLOT(sizeScaleValueChanged(int)));
|
||||
|
||||
_boundaryLevelAdjust = new QSlider(Qt::Horizontal);
|
||||
_boundaryLevelAdjust = new QSlider(Qt::Horizontal, this);
|
||||
const int MAX_ADJUST = 10;
|
||||
const int MIN_ADJUST = 0;
|
||||
const int STEP_ADJUST = 1;
|
||||
|
@ -66,7 +66,7 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) :
|
|||
connect(_boundaryLevelAdjust,SIGNAL(valueChanged(int)),this,SLOT(boundaryLevelValueChanged(int)));
|
||||
|
||||
// Create a label with feedback...
|
||||
_feedback = new QLabel();
|
||||
_feedback = new QLabel(this);
|
||||
QPalette palette = _feedback->palette();
|
||||
const unsigned redish = 0xfff00000;
|
||||
palette.setColor(QPalette::WindowText, QColor::fromRgb(redish));
|
||||
|
@ -76,21 +76,21 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) :
|
|||
_feedback->setFixedWidth(FEEDBACK_WIDTH);
|
||||
form->addRow("You can see... ", _feedback);
|
||||
|
||||
form->addRow("Automatic Avatar LOD Adjustment:", _automaticAvatarLOD = new QCheckBox());
|
||||
form->addRow("Automatic Avatar LOD Adjustment:", _automaticAvatarLOD = new QCheckBox(this));
|
||||
_automaticAvatarLOD->setChecked(Menu::getInstance()->getAutomaticAvatarLOD());
|
||||
connect(_automaticAvatarLOD, SIGNAL(toggled(bool)), SLOT(updateAvatarLODControls()));
|
||||
|
||||
form->addRow("Decrease Avatar LOD Below FPS:", _avatarLODDecreaseFPS = new QDoubleSpinBox());
|
||||
form->addRow("Decrease Avatar LOD Below FPS:", _avatarLODDecreaseFPS = new QDoubleSpinBox(this));
|
||||
_avatarLODDecreaseFPS->setValue(Menu::getInstance()->getAvatarLODDecreaseFPS());
|
||||
_avatarLODDecreaseFPS->setDecimals(0);
|
||||
connect(_avatarLODDecreaseFPS, SIGNAL(valueChanged(double)), SLOT(updateAvatarLODValues()));
|
||||
|
||||
form->addRow("Increase Avatar LOD Above FPS:", _avatarLODIncreaseFPS = new QDoubleSpinBox());
|
||||
form->addRow("Increase Avatar LOD Above FPS:", _avatarLODIncreaseFPS = new QDoubleSpinBox(this));
|
||||
_avatarLODIncreaseFPS->setValue(Menu::getInstance()->getAvatarLODIncreaseFPS());
|
||||
_avatarLODIncreaseFPS->setDecimals(0);
|
||||
connect(_avatarLODIncreaseFPS, SIGNAL(valueChanged(double)), SLOT(updateAvatarLODValues()));
|
||||
|
||||
form->addRow("Avatar LOD:", _avatarLOD = new QDoubleSpinBox());
|
||||
form->addRow("Avatar LOD:", _avatarLOD = new QDoubleSpinBox(this));
|
||||
_avatarLOD->setDecimals(3);
|
||||
_avatarLOD->setRange(1.0 / MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, 1.0 / MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER);
|
||||
_avatarLOD->setSingleStep(0.001);
|
||||
|
@ -98,21 +98,15 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) :
|
|||
connect(_avatarLOD, SIGNAL(valueChanged(double)), SLOT(updateAvatarLODValues()));
|
||||
|
||||
// Add a button to reset
|
||||
QPushButton* resetButton = new QPushButton("Reset");
|
||||
QPushButton* resetButton = new QPushButton("Reset", this);
|
||||
form->addRow("", resetButton);
|
||||
connect(resetButton,SIGNAL(clicked(bool)),this,SLOT(resetClicked(bool)));
|
||||
connect(resetButton, SIGNAL(clicked(bool)), this, SLOT(resetClicked(bool)));
|
||||
|
||||
this->QDialog::setLayout(form);
|
||||
|
||||
updateAvatarLODControls();
|
||||
}
|
||||
|
||||
LodToolsDialog::~LodToolsDialog() {
|
||||
delete _feedback;
|
||||
delete _lodSize;
|
||||
delete _boundaryLevelAdjust;
|
||||
}
|
||||
|
||||
void LodToolsDialog::reloadSliders() {
|
||||
_lodSize->setValue(Menu::getInstance()->getOctreeSizeScale() / TREE_SCALE);
|
||||
_boundaryLevelAdjust->setValue(Menu::getInstance()->getBoundaryLevelAdjust());
|
||||
|
|
|
@ -13,18 +13,17 @@
|
|||
#define hifi_LodToolsDialog_h
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
|
||||
class QCheckBox;
|
||||
class QDoubleSpinBox;
|
||||
class QLabel;
|
||||
class QSlider;
|
||||
|
||||
class LodToolsDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Sets up the UI
|
||||
LodToolsDialog(QWidget* parent);
|
||||
~LodToolsDialog();
|
||||
|
||||
signals:
|
||||
void closed();
|
||||
|
@ -41,7 +40,7 @@ public slots:
|
|||
protected:
|
||||
|
||||
// Emits a 'closed' signal when this dialog is closed.
|
||||
void closeEvent(QCloseEvent*);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
private:
|
||||
QSlider* _lodSize;
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
#include "FlowLayout.h"
|
||||
#include "JSConsole.h"
|
||||
|
||||
const int CONSOLE_HEIGHT = 150;
|
||||
|
||||
ScriptEditorWindow::ScriptEditorWindow() :
|
||||
_ScriptEditorWindowUI(new Ui::ScriptEditorWindow),
|
||||
_loadMenu(new QMenu),
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
static int animationPointerMetaTypeId = qRegisterMetaType<AnimationPointer>();
|
||||
|
||||
AnimationCache::AnimationCache(QObject* parent) :
|
||||
ResourceCache(parent) {
|
||||
ResourceCache(parent)
|
||||
{
|
||||
const qint64 ANIMATION_DEFAULT_UNUSED_MAX_SIZE = 50 * BYTES_PER_MEGABYTES;
|
||||
setUnusedResourceCacheSize(ANIMATION_DEFAULT_UNUSED_MAX_SIZE);
|
||||
}
|
||||
|
||||
AnimationPointer AnimationCache::getAnimation(const QUrl& url) {
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
void registerAudioMetaTypes(QScriptEngine* engine) {
|
||||
qScriptRegisterMetaType(engine, injectorOptionsToScriptValue, injectorOptionsFromScriptValue);
|
||||
qScriptRegisterMetaType(engine, soundToScriptValue, soundFromScriptValue);
|
||||
qScriptRegisterMetaType(engine, soundSharedPointerToScriptValue, soundSharedPointerFromScriptValue);
|
||||
qScriptRegisterMetaType(engine, soundPointerToScriptValue, soundPointerFromScriptValue);
|
||||
}
|
||||
|
||||
AudioScriptingInterface& AudioScriptingInterface::getInstance() {
|
||||
|
|
|
@ -29,13 +29,22 @@
|
|||
#include "AudioEditBuffer.h"
|
||||
#include "Sound.h"
|
||||
|
||||
QScriptValue soundToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in) {
|
||||
static int soundMetaTypeId = qRegisterMetaType<Sound*>();
|
||||
|
||||
QScriptValue soundSharedPointerToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in) {
|
||||
return engine->newQObject(in.data());
|
||||
}
|
||||
|
||||
void soundFromScriptValue(const QScriptValue &object, SharedSoundPointer &out) {
|
||||
void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPointer &out) {
|
||||
out = SharedSoundPointer(qobject_cast<Sound*>(object.toQObject()));
|
||||
qDebug() << "Sound from script value" << out.data();
|
||||
}
|
||||
|
||||
QScriptValue soundPointerToScriptValue(QScriptEngine* engine, Sound* const& in) {
|
||||
return engine->newQObject(in);
|
||||
}
|
||||
|
||||
void soundPointerFromScriptValue(const QScriptValue &object, Sound* &out) {
|
||||
out = qobject_cast<Sound*>(object.toQObject());
|
||||
}
|
||||
|
||||
Sound::Sound(const QUrl& url, bool isStereo) :
|
||||
|
|
|
@ -45,8 +45,12 @@ private:
|
|||
typedef QSharedPointer<Sound> SharedSoundPointer;
|
||||
|
||||
Q_DECLARE_METATYPE(SharedSoundPointer)
|
||||
QScriptValue soundSharedPointerToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in);
|
||||
void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPointer &out);
|
||||
|
||||
Q_DECLARE_METATYPE(Sound*)
|
||||
QScriptValue soundPointerToScriptValue(QScriptEngine* engine, Sound* const& in);
|
||||
void soundPointerFromScriptValue(const QScriptValue& object, Sound* &out);
|
||||
|
||||
QScriptValue soundToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in);
|
||||
void soundFromScriptValue(const QScriptValue& object, SharedSoundPointer& out);
|
||||
|
||||
#endif // hifi_Sound_h
|
||||
|
|
|
@ -23,7 +23,8 @@ SoundCache& SoundCache::getInstance() {
|
|||
SoundCache::SoundCache(QObject* parent) :
|
||||
ResourceCache(parent)
|
||||
{
|
||||
|
||||
const qint64 SOUND_DEFAULT_UNUSED_MAX_SIZE = 50 * BYTES_PER_MEGABYTES;
|
||||
setUnusedResourceCacheSize(SOUND_DEFAULT_UNUSED_MAX_SIZE);
|
||||
}
|
||||
|
||||
SharedSoundPointer SoundCache::getSound(const QUrl& url) {
|
||||
|
|
|
@ -665,7 +665,7 @@ const EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemI
|
|||
}
|
||||
return foundEntity;
|
||||
}
|
||||
|
||||
|
||||
EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id) {
|
||||
EntityItem* foundEntity = NULL;
|
||||
uint16_t numberOfEntities = _entityItems->size();
|
||||
|
|
|
@ -38,7 +38,7 @@ struct TextureParam {
|
|||
glm::vec2 UVTranslation;
|
||||
glm::vec2 UVScaling;
|
||||
glm::vec4 cropping;
|
||||
std::string UVSet;
|
||||
QString UVSet;
|
||||
|
||||
glm::vec3 translation;
|
||||
glm::vec3 rotation;
|
||||
|
@ -802,14 +802,14 @@ public:
|
|||
QVector<QHash<int, int> > blendshapeIndexMaps;
|
||||
QVector<QPair<int, int> > partMaterialTextures;
|
||||
QHash<QString, int> texcoordSetMap;
|
||||
std::map<std::string, int> texcoordSetMap2;
|
||||
std::map<QString, int> texcoordSetMap2;
|
||||
};
|
||||
|
||||
class AttributeData {
|
||||
public:
|
||||
QVector<glm::vec2> texCoords;
|
||||
QVector<int> texCoordIndices;
|
||||
std::string name;
|
||||
QString name;
|
||||
int index;
|
||||
};
|
||||
|
||||
|
@ -945,12 +945,12 @@ ExtractedMesh extractMesh(const FBXNode& object) {
|
|||
data.texCoordIndices = getIntVector(subdata);
|
||||
attrib.texCoordIndices = getIntVector(subdata);
|
||||
} else if (subdata.name == "Name") {
|
||||
attrib.name = subdata.properties.at(0).toString().toStdString();
|
||||
attrib.name = subdata.properties.at(0).toString();
|
||||
}
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
else {
|
||||
int unknown = 0;
|
||||
std::string subname = subdata.name.data();
|
||||
QString subname = subdata.name.data();
|
||||
if ( (subdata.name == "Version")
|
||||
|| (subdata.name == "MappingInformationType")
|
||||
|| (subdata.name == "ReferenceInformationType") ) {
|
||||
|
@ -960,7 +960,7 @@ ExtractedMesh extractMesh(const FBXNode& object) {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
data.extracted.texcoordSetMap.insert(QString(attrib.name.c_str()), data.attributes.size());
|
||||
data.extracted.texcoordSetMap.insert(attrib.name, data.attributes.size());
|
||||
data.attributes.push_back(attrib);
|
||||
} else {
|
||||
AttributeData attrib;
|
||||
|
@ -971,12 +971,12 @@ ExtractedMesh extractMesh(const FBXNode& object) {
|
|||
} else if (subdata.name == "UVIndex") {
|
||||
attrib.texCoordIndices = getIntVector(subdata);
|
||||
} else if (subdata.name == "Name") {
|
||||
attrib.name = subdata.properties.at(0).toString().toStdString();
|
||||
attrib.name = subdata.properties.at(0).toString();
|
||||
}
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
else {
|
||||
int unknown = 0;
|
||||
std::string subname = subdata.name.data();
|
||||
QString subname = subdata.name.data();
|
||||
if ( (subdata.name == "Version")
|
||||
|| (subdata.name == "MappingInformationType")
|
||||
|| (subdata.name == "ReferenceInformationType") ) {
|
||||
|
@ -987,9 +987,9 @@ ExtractedMesh extractMesh(const FBXNode& object) {
|
|||
#endif
|
||||
}
|
||||
|
||||
QHash<QString, int>::iterator it = data.extracted.texcoordSetMap.find(QString(attrib.name.c_str()));
|
||||
QHash<QString, int>::iterator it = data.extracted.texcoordSetMap.find(attrib.name);
|
||||
if (it == data.extracted.texcoordSetMap.end()) {
|
||||
data.extracted.texcoordSetMap.insert(QString(attrib.name.c_str()), data.attributes.size());
|
||||
data.extracted.texcoordSetMap.insert(attrib.name, data.attributes.size());
|
||||
data.attributes.push_back(attrib);
|
||||
} else {
|
||||
// WTF same names for different UVs?
|
||||
|
@ -1198,11 +1198,11 @@ bool checkMaterialsHaveTextures(const QHash<QString, Material>& materials,
|
|||
return false;
|
||||
}
|
||||
|
||||
int matchTextureUVSetToAttributeChannel(const std::string& texUVSetName, const QHash<QString, int>& texcoordChannels) {
|
||||
if (texUVSetName.empty()) {
|
||||
int matchTextureUVSetToAttributeChannel(const QString& texUVSetName, const QHash<QString, int>& texcoordChannels) {
|
||||
if (texUVSetName.isEmpty()) {
|
||||
return 0;
|
||||
} else {
|
||||
QHash<QString, int>::const_iterator tcUnit = texcoordChannels.find(QString(texUVSetName.c_str()));
|
||||
QHash<QString, int>::const_iterator tcUnit = texcoordChannels.find(texUVSetName);
|
||||
if (tcUnit != texcoordChannels.end()) {
|
||||
int channel = (*tcUnit);
|
||||
if (channel >= 2) {
|
||||
|
@ -1220,13 +1220,13 @@ FBXLight extractLight(const FBXNode& object) {
|
|||
FBXLight light;
|
||||
|
||||
foreach (const FBXNode& subobject, object.children) {
|
||||
std::string childname = QString(subobject.name).toStdString();
|
||||
QString childname = QString(subobject.name);
|
||||
if (subobject.name == "Properties70") {
|
||||
foreach (const FBXNode& property, subobject.children) {
|
||||
int valIndex = 4;
|
||||
std::string propName = QString(property.name).toStdString();
|
||||
QString propName = QString(property.name);
|
||||
if (property.name == "P") {
|
||||
std::string propname = property.properties.at(0).toString().toStdString();
|
||||
QString propname = property.properties.at(0).toString();
|
||||
if (propname == "Intensity") {
|
||||
light.intensity = 0.01f * property.properties.at(valIndex).value<double>();
|
||||
}
|
||||
|
@ -1238,13 +1238,13 @@ FBXLight extractLight(const FBXNode& object) {
|
|||
}
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
|
||||
std::string type = object.properties.at(0).toString().toStdString();
|
||||
type = object.properties.at(1).toString().toStdString();
|
||||
type = object.properties.at(2).toString().toStdString();
|
||||
QString type = object.properties.at(0).toString();
|
||||
type = object.properties.at(1).toString();
|
||||
type = object.properties.at(2).toString();
|
||||
|
||||
foreach (const QVariant& prop, object.properties) {
|
||||
std::string proptype = prop.typeName();
|
||||
std::string propval = prop.toString().toStdString();
|
||||
QString proptype = prop.typeName();
|
||||
QString propval = prop.toString();
|
||||
if (proptype == "Properties70") {
|
||||
}
|
||||
}
|
||||
|
@ -1281,7 +1281,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
QHash<QString, QString> yComponents;
|
||||
QHash<QString, QString> zComponents;
|
||||
|
||||
std::map<std::string, FBXLight> lights;
|
||||
std::map<QString, FBXLight> lights;
|
||||
|
||||
QVariantHash joints = mapping.value("joint").toHash();
|
||||
QString jointEyeLeftName = processID(getString(joints.value("jointEyeLeft", "jointEyeLeft")));
|
||||
|
@ -1369,7 +1369,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
int index = 4;
|
||||
foreach (const FBXNode& subobject, object.children) {
|
||||
if (subobject.name == propertyName) {
|
||||
std::string subpropName = subobject.properties.at(0).toString().toStdString();
|
||||
QString subpropName = subobject.properties.at(0).toString();
|
||||
if (subpropName == "UnitScaleFactor") {
|
||||
unitScaleFactor = subobject.properties.at(index).toFloat();
|
||||
} else if (subpropName == "AmbientColor") {
|
||||
|
@ -1393,8 +1393,8 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
QString id = getID(object.properties);
|
||||
modelIDsToNames.insert(id, name);
|
||||
|
||||
std::string modelname = name.toLower().toStdString();
|
||||
if (modelname.find("hifi") == 0) {
|
||||
QString modelname = name.toLower();
|
||||
if (modelname.startsWith("hifi")) {
|
||||
hifiGlobalNodeID = id;
|
||||
}
|
||||
|
||||
|
@ -1527,19 +1527,19 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
}
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
else if (subobject.name == "TypeFlags") {
|
||||
std::string attributetype = subobject.properties.at(0).toString().toStdString();
|
||||
QString attributetype = subobject.properties.at(0).toString();
|
||||
if (!attributetype.empty()) {
|
||||
if (attributetype == "Light") {
|
||||
std::string lightprop;
|
||||
QString lightprop;
|
||||
foreach (const QVariant& vprop, subobject.properties) {
|
||||
lightprop = vprop.toString().toStdString();
|
||||
lightprop = vprop.toString();
|
||||
}
|
||||
|
||||
FBXLight light = extractLight(object);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::string whatisthat = subobject.name;
|
||||
QString whatisthat = subobject.name;
|
||||
if (whatisthat == "Shape") {
|
||||
}
|
||||
}
|
||||
|
@ -1604,7 +1604,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
if (property.name == propertyName) {
|
||||
QString v = property.properties.at(0).toString();
|
||||
if (property.properties.at(0) == "UVSet") {
|
||||
tex.assign(tex.UVSet, property.properties.at(index).toString().toStdString());
|
||||
tex.assign(tex.UVSet, property.properties.at(index).toString());
|
||||
} else if (property.properties.at(0) == "CurrentTextureBlendMode") {
|
||||
tex.assign<uint8_t>(tex.currentTextureBlendMode, property.properties.at(index).value<int>());
|
||||
} else if (property.properties.at(0) == "UseMaterial") {
|
||||
|
@ -1618,7 +1618,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
}
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
else {
|
||||
std::string propName = v.toStdString();
|
||||
QString propName = v;
|
||||
unknown++;
|
||||
}
|
||||
#endif
|
||||
|
@ -1632,7 +1632,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
} else if (subobject.name == "FileName") {
|
||||
} else if (subobject.name == "Media") {
|
||||
} else {
|
||||
std::string subname = subobject.name.data();
|
||||
QString subname = subobject.name.data();
|
||||
unknown++;
|
||||
}
|
||||
}
|
||||
|
@ -1693,7 +1693,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
}
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
else {
|
||||
const std::string propname = property.properties.at(0).toString().toStdString();
|
||||
const QString propname = property.properties.at(0).toString();
|
||||
if (propname == "EmissiveFactor") {
|
||||
}
|
||||
}
|
||||
|
@ -1703,7 +1703,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
}
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
else {
|
||||
std::string propname = subobject.name.data();
|
||||
QString propname = subobject.name.data();
|
||||
int unknown = 0;
|
||||
if ( (propname == "Version")
|
||||
||(propname == "ShadingModel")
|
||||
|
@ -1719,21 +1719,21 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
|
||||
} else if (object.name == "NodeAttribute") {
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
std::vector<std::string> properties;
|
||||
std::vector<QString> properties;
|
||||
foreach(const QVariant& v, object.properties) {
|
||||
properties.push_back(v.toString().toStdString());
|
||||
properties.push_back(v.toString());
|
||||
}
|
||||
#endif
|
||||
std::string attribID = getID(object.properties).toStdString();
|
||||
std::string attributetype;
|
||||
QString attribID = getID(object.properties);
|
||||
QString attributetype;
|
||||
foreach (const FBXNode& subobject, object.children) {
|
||||
if (subobject.name == "TypeFlags") {
|
||||
typeFlags.insert(getID(object.properties), subobject.properties.at(0).toString());
|
||||
attributetype = subobject.properties.at(0).toString().toStdString();
|
||||
attributetype = subobject.properties.at(0).toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (!attributetype.empty()) {
|
||||
if (!attributetype.isEmpty()) {
|
||||
if (attributetype == "Light") {
|
||||
FBXLight light = extractLight(object);
|
||||
lights[attribID] = light;
|
||||
|
@ -1781,7 +1781,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
}
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
else {
|
||||
std::string objectname = object.name.data();
|
||||
QString objectname = object.name.data();
|
||||
if ( objectname == "Pose"
|
||||
|| objectname == "AnimationStack"
|
||||
|| objectname == "AnimationLayer"
|
||||
|
@ -1800,7 +1800,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
QString parentID = getID(connection.properties, 2);
|
||||
ooChildToParent.insert(childID, parentID);
|
||||
if (!hifiGlobalNodeID.isEmpty() && (parentID == hifiGlobalNodeID)) {
|
||||
std::map< std::string, FBXLight >::iterator lit = lights.find(childID.toStdString());
|
||||
std::map< QString, FBXLight >::iterator lit = lights.find(childID);
|
||||
if (lit != lights.end()) {
|
||||
lightmapLevel = (*lit).second.intensity;
|
||||
if (lightmapLevel <= 0.0f) {
|
||||
|
@ -1842,7 +1842,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
} else if (loadLightmaps && type.contains("ambient")) {
|
||||
ambientTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else {
|
||||
std::string typenam = type.data();
|
||||
QString typenam = type.data();
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
@ -1853,7 +1853,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
}
|
||||
#if defined(DEBUG_FBXREADER)
|
||||
else {
|
||||
std::string objectname = child.name.data();
|
||||
QString objectname = child.name.data();
|
||||
if ( objectname == "Pose"
|
||||
|| objectname == "CreationTime"
|
||||
|| objectname == "FileId"
|
||||
|
@ -1875,7 +1875,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
// TODO: check if is code is needed
|
||||
if (!lights.empty()) {
|
||||
if (hifiGlobalNodeID.isEmpty()) {
|
||||
std::map< std::string, FBXLight >::iterator l = lights.begin();
|
||||
std::map< QString, FBXLight >::iterator l = lights.begin();
|
||||
lightmapLevel = (*l).second.intensity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public:
|
|||
|
||||
Transform transform;
|
||||
int texcoordSet;
|
||||
std::string texcoordSetName;
|
||||
QString texcoordSetName;
|
||||
};
|
||||
|
||||
/// A single part of a mesh (with the same material).
|
||||
|
|
|
@ -109,9 +109,12 @@ ScriptCache* ScriptCache::getInstance() {
|
|||
}
|
||||
|
||||
ScriptCache::ScriptCache() :
|
||||
_engine(NULL) {
|
||||
|
||||
_engine(NULL)
|
||||
{
|
||||
setEngine(new QScriptEngine(this));
|
||||
|
||||
const qint64 SCRIPT_DEFAULT_UNUSED_MAX_SIZE = 50 * BYTES_PER_MEGABYTES;
|
||||
setUnusedResourceCacheSize(SCRIPT_DEFAULT_UNUSED_MAX_SIZE);
|
||||
}
|
||||
|
||||
void ScriptCache::setEngine(QScriptEngine* engine) {
|
||||
|
|
|
@ -20,11 +20,12 @@
|
|||
|
||||
#include "ResourceCache.h"
|
||||
|
||||
#define clamp(x, min, max) (((x) < (min)) ? (min) :\
|
||||
(((x) > (max)) ? (max) :\
|
||||
(x)))
|
||||
|
||||
ResourceCache::ResourceCache(QObject* parent) :
|
||||
QObject(parent),
|
||||
_lastLRUKey(0)
|
||||
{
|
||||
|
||||
QObject(parent) {
|
||||
}
|
||||
|
||||
ResourceCache::~ResourceCache() {
|
||||
|
@ -32,7 +33,7 @@ ResourceCache::~ResourceCache() {
|
|||
// list on destruction, so keep clearing until there are no references left
|
||||
while (!_unusedResources.isEmpty()) {
|
||||
foreach (const QSharedPointer<Resource>& resource, _unusedResources) {
|
||||
resource->setCache(NULL);
|
||||
resource->setCache(nullptr);
|
||||
}
|
||||
_unusedResources.clear();
|
||||
}
|
||||
|
@ -72,37 +73,40 @@ QSharedPointer<Resource> ResourceCache::getResource(const QUrl& url, const QUrl&
|
|||
return resource;
|
||||
}
|
||||
|
||||
void ResourceCache::setUnusedResourceCacheSize(qint64 unusedResourcesMaxSize) {
|
||||
_unusedResourcesMaxSize = clamp(unusedResourcesMaxSize, MIN_UNUSED_MAX_SIZE, MAX_UNUSED_MAX_SIZE);
|
||||
reserveUnusedResource(0);
|
||||
}
|
||||
|
||||
void ResourceCache::addUnusedResource(const QSharedPointer<Resource>& resource) {
|
||||
static const int BYTES_PER_MEGABYTES = 1024 * 1024;
|
||||
const int RETAINED_RESOURCE_COUNT = 50;
|
||||
const int RETAINED_RESOURCE_SIZE = 100 * BYTES_PER_MEGABYTES;
|
||||
|
||||
while (_unusedResourcesTotalBytes + resource->getBytesTotal() > RETAINED_RESOURCE_SIZE &&
|
||||
!_unusedResources.empty()) {
|
||||
// unload the oldest resource
|
||||
QMap<int, QSharedPointer<Resource> >::iterator it = _unusedResources.begin();
|
||||
|
||||
_unusedResourcesTotalBytes -= it.value()->getBytesTotal();
|
||||
it.value()->setCache(NULL);
|
||||
_unusedResources.erase(it);
|
||||
if (resource->getBytesTotal() > _unusedResourcesMaxSize) {
|
||||
// If it doesn't fit anyway, let's leave whatever is already in the cache.
|
||||
resource->setCache(nullptr);
|
||||
return;
|
||||
}
|
||||
reserveUnusedResource(resource->getBytesTotal());
|
||||
|
||||
|
||||
if (_unusedResources.size() > RETAINED_RESOURCE_COUNT) {
|
||||
// unload the oldest resource
|
||||
QMap<int, QSharedPointer<Resource> >::iterator it = _unusedResources.begin();
|
||||
it.value()->setCache(NULL);
|
||||
_unusedResources.erase(it);
|
||||
}
|
||||
resource->setLRUKey(++_lastLRUKey);
|
||||
_unusedResources.insert(resource->getLRUKey(), resource);
|
||||
_unusedResourcesTotalBytes += resource->getBytesTotal();
|
||||
_unusedResourcesSize += resource->getBytesTotal();
|
||||
}
|
||||
|
||||
void ResourceCache::removeUnusedResource(const QSharedPointer<Resource>& resource) {
|
||||
if (_unusedResources.contains(resource->getLRUKey())) {
|
||||
_unusedResources.remove(resource->getLRUKey());
|
||||
_unusedResourcesTotalBytes -= resource->getBytesTotal();
|
||||
_unusedResourcesSize -= resource->getBytesTotal();
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceCache::reserveUnusedResource(qint64 resourceSize) {
|
||||
while (!_unusedResources.empty() &&
|
||||
_unusedResourcesSize + resourceSize > _unusedResourcesMaxSize) {
|
||||
// unload the oldest resource
|
||||
QMap<int, QSharedPointer<Resource> >::iterator it = _unusedResources.begin();
|
||||
|
||||
_unusedResourcesSize -= it.value()->getBytesTotal();
|
||||
it.value()->setCache(nullptr);
|
||||
_unusedResources.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,9 +154,7 @@ QList<Resource*> ResourceCache::_loadingRequests;
|
|||
|
||||
Resource::Resource(const QUrl& url, bool delayLoad) :
|
||||
_url(url),
|
||||
_request(url),
|
||||
_lruKey(0),
|
||||
_reply(NULL) {
|
||||
_request(url) {
|
||||
|
||||
init();
|
||||
|
||||
|
@ -168,6 +170,7 @@ Resource::~Resource() {
|
|||
if (_reply) {
|
||||
ResourceCache::requestCompleted(this);
|
||||
delete _reply;
|
||||
_reply = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,13 +216,13 @@ float Resource::getLoadPriority() {
|
|||
}
|
||||
|
||||
void Resource::refresh() {
|
||||
if (_reply == NULL && !(_loaded || _failedToLoad)) {
|
||||
if (_reply == nullptr && !(_loaded || _failedToLoad)) {
|
||||
return;
|
||||
}
|
||||
if (_reply) {
|
||||
ResourceCache::requestCompleted(this);
|
||||
delete _reply;
|
||||
_reply = NULL;
|
||||
_reply = nullptr;
|
||||
}
|
||||
init();
|
||||
_request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
|
||||
|
@ -295,10 +298,10 @@ void Resource::handleDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
|
|||
}
|
||||
_reply->disconnect(this);
|
||||
QNetworkReply* reply = _reply;
|
||||
_reply = NULL;
|
||||
_reply = nullptr;
|
||||
_replyTimer->disconnect(this);
|
||||
_replyTimer->deleteLater();
|
||||
_replyTimer = NULL;
|
||||
_replyTimer = nullptr;
|
||||
ResourceCache::requestCompleted(this);
|
||||
|
||||
downloadFinished(reply);
|
||||
|
@ -330,10 +333,10 @@ void Resource::makeRequest() {
|
|||
void Resource::handleReplyError(QNetworkReply::NetworkError error, QDebug debug) {
|
||||
_reply->disconnect(this);
|
||||
_reply->deleteLater();
|
||||
_reply = NULL;
|
||||
_reply = nullptr;
|
||||
_replyTimer->disconnect(this);
|
||||
_replyTimer->deleteLater();
|
||||
_replyTimer = NULL;
|
||||
_replyTimer = nullptr;
|
||||
ResourceCache::requestCompleted(this);
|
||||
|
||||
// retry for certain types of failures
|
||||
|
|
|
@ -27,6 +27,19 @@ class QTimer;
|
|||
|
||||
class Resource;
|
||||
|
||||
static const qint64 BYTES_PER_MEGABYTES = 1024 * 1024;
|
||||
static const qint64 BYTES_PER_GIGABYTES = 1024 * BYTES_PER_MEGABYTES;
|
||||
|
||||
// Windows can have troubles allocating that much memory in ram sometimes
|
||||
// so default cache size at 100 MB on windows (1GB otherwise)
|
||||
#ifdef Q_OS_WIN32
|
||||
static const qint64 DEFAULT_UNUSED_MAX_SIZE = 100 * BYTES_PER_MEGABYTES;
|
||||
#else
|
||||
static const qint64 DEFAULT_UNUSED_MAX_SIZE = 1024 * BYTES_PER_MEGABYTES;
|
||||
#endif
|
||||
static const qint64 MIN_UNUSED_MAX_SIZE = 0;
|
||||
static const qint64 MAX_UNUSED_MAX_SIZE = 10 * BYTES_PER_GIGABYTES;
|
||||
|
||||
/// Base class for resource caches.
|
||||
class ResourceCache : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -34,6 +47,9 @@ class ResourceCache : public QObject {
|
|||
public:
|
||||
static void setRequestLimit(int limit) { _requestLimit = limit; }
|
||||
static int getRequestLimit() { return _requestLimit; }
|
||||
|
||||
void setUnusedResourceCacheSize(qint64 unusedResourcesMaxSize);
|
||||
qint64 getUnusedResourceCacheSize() const { return _unusedResourcesMaxSize; }
|
||||
|
||||
static const QList<Resource*>& getLoadingRequests() { return _loadingRequests; }
|
||||
|
||||
|
@ -45,8 +61,8 @@ public:
|
|||
void refresh(const QUrl& url);
|
||||
|
||||
protected:
|
||||
|
||||
qint64 _unusedResourcesTotalBytes = 0;
|
||||
qint64 _unusedResourcesMaxSize = DEFAULT_UNUSED_MAX_SIZE;
|
||||
qint64 _unusedResourcesSize = 0;
|
||||
QMap<int, QSharedPointer<Resource> > _unusedResources;
|
||||
|
||||
/// Loads a resource from the specified URL.
|
||||
|
@ -62,16 +78,16 @@ protected:
|
|||
|
||||
void addUnusedResource(const QSharedPointer<Resource>& resource);
|
||||
void removeUnusedResource(const QSharedPointer<Resource>& resource);
|
||||
void reserveUnusedResource(qint64 resourceSize);
|
||||
|
||||
static void attemptRequest(Resource* resource);
|
||||
static void requestCompleted(Resource* resource);
|
||||
|
||||
private:
|
||||
|
||||
friend class Resource;
|
||||
|
||||
QHash<QUrl, QWeakPointer<Resource> > _resources;
|
||||
int _lastLRUKey;
|
||||
int _lastLRUKey = 0;
|
||||
|
||||
static int _requestLimit;
|
||||
static QList<QPointer<Resource> > _pendingRequests;
|
||||
|
@ -152,9 +168,9 @@ protected:
|
|||
|
||||
QUrl _url;
|
||||
QNetworkRequest _request;
|
||||
bool _startedLoading;
|
||||
bool _failedToLoad;
|
||||
bool _loaded;
|
||||
bool _startedLoading = false;
|
||||
bool _failedToLoad = false;
|
||||
bool _loaded = false;
|
||||
QHash<QPointer<QObject>, float> _loadPriorities;
|
||||
QWeakPointer<Resource> _self;
|
||||
QPointer<ResourceCache> _cache;
|
||||
|
@ -176,13 +192,12 @@ private:
|
|||
|
||||
friend class ResourceCache;
|
||||
|
||||
int _lruKey;
|
||||
QNetworkReply* _reply;
|
||||
QTimer* _replyTimer;
|
||||
int _index;
|
||||
qint64 _bytesReceived;
|
||||
qint64 _bytesTotal;
|
||||
int _attempts;
|
||||
int _lruKey = 0;
|
||||
QNetworkReply* _reply = nullptr;
|
||||
QTimer* _replyTimer = nullptr;
|
||||
qint64 _bytesReceived = 0;
|
||||
qint64 _bytesTotal = 0;
|
||||
int _attempts = 0;
|
||||
};
|
||||
|
||||
uint qHash(const QPointer<QObject>& value, uint seed = 0);
|
||||
|
|
|
@ -9,5 +9,10 @@ include_glm()
|
|||
|
||||
link_hifi_libraries(animation fbx shared gpu)
|
||||
|
||||
if (WIN32)
|
||||
# we're using static GLEW, so define GLEW_STATIC
|
||||
add_definitions(-DGLEW_STATIC)
|
||||
endif ()
|
||||
|
||||
# call macro to include our dependency includes and bubble them up via a property on our target
|
||||
include_dependency_includes()
|
|
@ -30,6 +30,8 @@ const int GeometryCache::UNKNOWN_ID = -1;
|
|||
GeometryCache::GeometryCache() :
|
||||
_nextID(0)
|
||||
{
|
||||
const qint64 GEOMETRY_DEFAULT_UNUSED_MAX_SIZE = DEFAULT_UNUSED_MAX_SIZE;
|
||||
setUnusedResourceCacheSize(GEOMETRY_DEFAULT_UNUSED_MAX_SIZE);
|
||||
}
|
||||
|
||||
GeometryCache::~GeometryCache() {
|
||||
|
@ -1871,9 +1873,9 @@ void GeometryReader::run() {
|
|||
if (!_reply) {
|
||||
throw QString("Reply is NULL ?!");
|
||||
}
|
||||
std::string urlname = _url.path().toLower().toStdString();
|
||||
QString urlname = _url.path().toLower();
|
||||
bool urlValid = true;
|
||||
urlValid &= !urlname.empty();
|
||||
urlValid &= !urlname.isEmpty();
|
||||
urlValid &= !_url.path().isEmpty();
|
||||
urlValid &= _url.path().toLower().endsWith(".fbx")
|
||||
|| _url.path().toLower().endsWith(".svo");
|
||||
|
|
|
@ -39,6 +39,8 @@ TextureCache::TextureCache() :
|
|||
_frameBufferSize(100, 100),
|
||||
_associatedWidget(NULL)
|
||||
{
|
||||
const qint64 TEXTURE_DEFAULT_UNUSED_MAX_SIZE = DEFAULT_UNUSED_MAX_SIZE;
|
||||
setUnusedResourceCacheSize(TEXTURE_DEFAULT_UNUSED_MAX_SIZE);
|
||||
}
|
||||
|
||||
TextureCache::~TextureCache() {
|
||||
|
@ -203,7 +205,7 @@ NetworkTexturePointer TextureCache::getTexture(const QUrl& url, TextureType type
|
|||
texture->setCache(this);
|
||||
_dilatableNetworkTextures.insert(url, texture);
|
||||
} else {
|
||||
_unusedResources.remove(texture->getLRUKey());
|
||||
removeUnusedResource(texture);
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef hifi_EventTypes_h
|
||||
#define hifi_EventTypes_h
|
||||
|
||||
#include <qscriptengine.h>
|
||||
#include <QScriptEngine>
|
||||
|
||||
void registerEventTypes(QScriptEngine* engine);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#define hifi_KeyEvent_h
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <qscriptvalue.h>
|
||||
#include <QScriptValue>
|
||||
|
||||
class KeyEvent {
|
||||
public:
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <unistd.h> // not on windows, not needed for mac or windows
|
||||
#endif
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QDebug>
|
||||
|
||||
const int BYTES_PER_COLOR = 3;
|
||||
const int BYTES_PER_FLAGS = 1;
|
||||
|
|
Loading…
Reference in a new issue