mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:10:25 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into 20143
This commit is contained in:
commit
4e75837a64
21 changed files with 278 additions and 63 deletions
|
@ -237,8 +237,7 @@ void MetavoxelSession::update() {
|
||||||
|
|
||||||
// go back to the beginning with the current packet and note that there's a delta pending
|
// go back to the beginning with the current packet and note that there's a delta pending
|
||||||
_sequencer.getOutputStream().getUnderlying().device()->seek(start);
|
_sequencer.getOutputStream().getUnderlying().device()->seek(start);
|
||||||
MetavoxelDeltaPendingMessage msg = { ++_reliableDeltaID, sendRecord->getPacketNumber(),
|
MetavoxelDeltaPendingMessage msg = { ++_reliableDeltaID, sendRecord->getPacketNumber(), _lodPacketNumber };
|
||||||
_sequencer.getIncomingPacketNumber() };
|
|
||||||
out << (_reliableDeltaMessage = QVariant::fromValue(msg));
|
out << (_reliableDeltaMessage = QVariant::fromValue(msg));
|
||||||
_sequencer.endPacket();
|
_sequencer.endPacket();
|
||||||
|
|
||||||
|
@ -265,7 +264,8 @@ void MetavoxelSession::handleMessage(const QVariant& message) {
|
||||||
if (userType == ClientStateMessage::Type) {
|
if (userType == ClientStateMessage::Type) {
|
||||||
ClientStateMessage state = message.value<ClientStateMessage>();
|
ClientStateMessage state = message.value<ClientStateMessage>();
|
||||||
_lod = state.lod;
|
_lod = state.lod;
|
||||||
|
_lodPacketNumber = _sequencer.getIncomingPacketNumber();
|
||||||
|
|
||||||
} else if (userType == MetavoxelEditMessage::Type) {
|
} else if (userType == MetavoxelEditMessage::Type) {
|
||||||
QMetaObject::invokeMethod(_sender->getServer(), "applyEdit", Q_ARG(const MetavoxelEditMessage&,
|
QMetaObject::invokeMethod(_sender->getServer(), "applyEdit", Q_ARG(const MetavoxelEditMessage&,
|
||||||
message.value<MetavoxelEditMessage>()));
|
message.value<MetavoxelEditMessage>()));
|
||||||
|
|
|
@ -127,6 +127,7 @@ private:
|
||||||
MetavoxelSender* _sender;
|
MetavoxelSender* _sender;
|
||||||
|
|
||||||
MetavoxelLOD _lod;
|
MetavoxelLOD _lod;
|
||||||
|
int _lodPacketNumber;
|
||||||
|
|
||||||
ReliableChannel* _reliableDeltaChannel;
|
ReliableChannel* _reliableDeltaChannel;
|
||||||
int _reliableDeltaReceivedOffset;
|
int _reliableDeltaReceivedOffset;
|
||||||
|
|
|
@ -64,7 +64,6 @@ function activateWarp() {
|
||||||
|
|
||||||
var TRIGGER_PULLBACK_DISTANCE = 0.04;
|
var TRIGGER_PULLBACK_DISTANCE = 0.04;
|
||||||
var WATCH_AVATAR_DISTANCE = 1.5;
|
var WATCH_AVATAR_DISTANCE = 1.5;
|
||||||
var MAX_WARP_YAW = 40.0;
|
|
||||||
var MAX_PULLBACK_YAW = 5.0;
|
var MAX_PULLBACK_YAW = 5.0;
|
||||||
|
|
||||||
var sound = new Sound("http://public.highfidelity.io/sounds/Footsteps/FootstepW2Right-12db.wav");
|
var sound = new Sound("http://public.highfidelity.io/sounds/Footsteps/FootstepW2Right-12db.wav");
|
||||||
|
@ -72,7 +71,7 @@ function playSound() {
|
||||||
var options = new AudioInjectionOptions();
|
var options = new AudioInjectionOptions();
|
||||||
var position = MyAvatar.position;
|
var position = MyAvatar.position;
|
||||||
options.position = position;
|
options.position = position;
|
||||||
options.volume = 0.5;
|
options.volume = 1.0;
|
||||||
Audio.playSound(sound, options);
|
Audio.playSound(sound, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +88,7 @@ function updateWarp() {
|
||||||
var deltaPitch = MyAvatar.getHeadFinalPitch() - headStartFinalPitch;
|
var deltaPitch = MyAvatar.getHeadFinalPitch() - headStartFinalPitch;
|
||||||
deltaYaw = MyAvatar.getHeadFinalYaw() - headStartYaw;
|
deltaYaw = MyAvatar.getHeadFinalYaw() - headStartYaw;
|
||||||
|
|
||||||
willMove = (!watchAvatar && (Math.abs(deltaYaw) < MAX_WARP_YAW) && (keyDownTime > WARP_START_TIME));
|
willMove = (!watchAvatar && (keyDownTime > WARP_START_TIME));
|
||||||
|
|
||||||
if (willMove) {
|
if (willMove) {
|
||||||
//var distance = Math.pow((deltaPitch - WARP_PITCH_DEAD_ZONE) * WARP_SENSITIVITY, 2.0);
|
//var distance = Math.pow((deltaPitch - WARP_PITCH_DEAD_ZONE) * WARP_SENSITIVITY, 2.0);
|
||||||
|
|
|
@ -78,6 +78,8 @@ SelectionManager = (function() {
|
||||||
that.worldDimensions = null;
|
that.worldDimensions = null;
|
||||||
that.worldPosition = null;
|
that.worldPosition = null;
|
||||||
} else if (that.selections.length == 1) {
|
} else if (that.selections.length == 1) {
|
||||||
|
SelectionDisplay.setSpaceMode(SPACE_LOCAL);
|
||||||
|
|
||||||
var properties = Entities.getEntityProperties(that.selections[0]);
|
var properties = Entities.getEntityProperties(that.selections[0]);
|
||||||
that.localDimensions = properties.dimensions;
|
that.localDimensions = properties.dimensions;
|
||||||
that.localPosition = properties.position;
|
that.localPosition = properties.position;
|
||||||
|
@ -622,8 +624,8 @@ SelectionDisplay = (function () {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var diagonal = (Vec3.length(properties.dimensions) / 2) * 1.1;
|
var diagonal = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1;
|
||||||
var halfDimensions = Vec3.multiply(properties.dimensions, 0.5);
|
var halfDimensions = Vec3.multiply(selectionManager.worldDimensions, 0.5);
|
||||||
innerRadius = diagonal;
|
innerRadius = diagonal;
|
||||||
outerRadius = diagonal * 1.15;
|
outerRadius = diagonal * 1.15;
|
||||||
var innerActive = false;
|
var innerActive = false;
|
||||||
|
@ -843,7 +845,7 @@ SelectionDisplay = (function () {
|
||||||
|
|
||||||
Overlays.editOverlay(grabberMoveUp, { visible: translateHandlesVisible, position: { x: boundsCenter.x, y: top + grabberMoveUpOffset, z: boundsCenter.z } });
|
Overlays.editOverlay(grabberMoveUp, { visible: translateHandlesVisible, position: { x: boundsCenter.x, y: top + grabberMoveUpOffset, z: boundsCenter.z } });
|
||||||
|
|
||||||
that.updateHandles(entityID);
|
that.updateHandles();
|
||||||
|
|
||||||
|
|
||||||
Overlays.editOverlay(baseOfEntityProjectionOverlay,
|
Overlays.editOverlay(baseOfEntityProjectionOverlay,
|
||||||
|
@ -924,18 +926,17 @@ SelectionDisplay = (function () {
|
||||||
entitySelected = false;
|
entitySelected = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.updateHandles = function(entityID) {
|
that.updateHandles = function() {
|
||||||
if (!entitySelected) {
|
// print("Updating handles");
|
||||||
|
if (SelectionManager.selections.length == 0) {
|
||||||
that.setOverlaysVisible(false);
|
that.setOverlaysVisible(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = Entities.getEntityProperties(entityID);
|
|
||||||
|
|
||||||
var rotation, dimensions, position;
|
var rotation, dimensions, position;
|
||||||
|
|
||||||
if (spaceMode == SPACE_LOCAL) {
|
if (spaceMode == SPACE_LOCAL) {
|
||||||
rotation = properties.rotation;
|
rotation = SelectionManager.localRotation;
|
||||||
dimensions = SelectionManager.localDimensions;
|
dimensions = SelectionManager.localDimensions;
|
||||||
position = SelectionManager.localPosition;
|
position = SelectionManager.localPosition;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1095,6 +1096,44 @@ SelectionDisplay = (function () {
|
||||||
entitySelected = false;
|
entitySelected = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function applyEntityProperties(data) {
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
var entityID = data[i].entityID;
|
||||||
|
var properties = data[i].properties;
|
||||||
|
Entities.editEntity(entityID, properties);
|
||||||
|
}
|
||||||
|
selectionManager._update();
|
||||||
|
};
|
||||||
|
|
||||||
|
// For currently selected entities, push a command to the UndoStack that uses the current entity properties for the
|
||||||
|
// redo command, and the saved properties for the undo command.
|
||||||
|
function pushCommandForSelections() {
|
||||||
|
var undoData = [];
|
||||||
|
var redoData = [];
|
||||||
|
for (var i = 0; i < SelectionManager.selections.length; i++) {
|
||||||
|
var entityID = SelectionManager.selections[i];
|
||||||
|
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
||||||
|
var currentProperties = Entities.getEntityProperties(entityID);
|
||||||
|
undoData.push({
|
||||||
|
entityID: entityID,
|
||||||
|
properties: {
|
||||||
|
position: initialProperties.position,
|
||||||
|
rotation: initialProperties.rotation,
|
||||||
|
dimensions: initialProperties.dimensions,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
redoData.push({
|
||||||
|
entityID: entityID,
|
||||||
|
properties: {
|
||||||
|
position: currentProperties.position,
|
||||||
|
rotation: currentProperties.rotation,
|
||||||
|
dimensions: currentProperties.dimensions,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
UndoStack.pushCommand(applyEntityProperties, undoData, applyEntityProperties, redoData);
|
||||||
|
}
|
||||||
|
|
||||||
var lastXZPick = null;
|
var lastXZPick = null;
|
||||||
var translateXZTool = {
|
var translateXZTool = {
|
||||||
mode: 'TRANSLATE_XZ',
|
mode: 'TRANSLATE_XZ',
|
||||||
|
@ -1114,6 +1153,8 @@ SelectionDisplay = (function () {
|
||||||
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
||||||
Entities.editEntity(entityID, initialProperties);
|
Entities.editEntity(entityID, initialProperties);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pushCommandForSelections();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
|
@ -1172,6 +1213,8 @@ SelectionDisplay = (function () {
|
||||||
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
||||||
Entities.editEntity(entityID, initialProperties);
|
Entities.editEntity(entityID, initialProperties);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pushCommandForSelections();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
|
@ -1334,6 +1377,8 @@ SelectionDisplay = (function () {
|
||||||
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
||||||
Entities.editEntity(entityID, initialProperties);
|
Entities.editEntity(entityID, initialProperties);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pushCommandForSelections();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1496,6 +1541,8 @@ SelectionDisplay = (function () {
|
||||||
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
||||||
Entities.editEntity(entityID, initialProperties);
|
Entities.editEntity(entityID, initialProperties);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pushCommandForSelections();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
|
@ -1602,6 +1649,8 @@ SelectionDisplay = (function () {
|
||||||
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
||||||
Entities.editEntity(entityID, initialProperties);
|
Entities.editEntity(entityID, initialProperties);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pushCommandForSelections();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
|
@ -1706,6 +1755,8 @@ SelectionDisplay = (function () {
|
||||||
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
var initialProperties = SelectionManager.savedProperties[entityID.id];
|
||||||
Entities.editEntity(entityID, initialProperties);
|
Entities.editEntity(entityID, initialProperties);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pushCommandForSelections();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ var entityPropertyDialogBox = EntityPropertyDialogBox;
|
||||||
Script.include("libraries/entityCameraTool.js");
|
Script.include("libraries/entityCameraTool.js");
|
||||||
var entityCameraTool = new EntityCameraTool();
|
var entityCameraTool = new EntityCameraTool();
|
||||||
|
|
||||||
selectionManager.setEventListener(selectionDisplay.updateHandles());
|
selectionManager.setEventListener(selectionDisplay.updateHandles);
|
||||||
|
|
||||||
var windowDimensions = Controller.getViewportDimensions();
|
var windowDimensions = Controller.getViewportDimensions();
|
||||||
var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/";
|
var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/";
|
||||||
|
@ -608,9 +608,12 @@ function handeMenuEvent(menuItem) {
|
||||||
} else if (menuItem == "Delete") {
|
} else if (menuItem == "Delete") {
|
||||||
if (entitySelected) {
|
if (entitySelected) {
|
||||||
print(" Delete Entity.... selectedEntityID="+ selectedEntityID);
|
print(" Delete Entity.... selectedEntityID="+ selectedEntityID);
|
||||||
Entities.deleteEntity(selectedEntityID);
|
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||||
|
Entities.deleteEntity(selectionManager.selections[i]);
|
||||||
|
}
|
||||||
selectionDisplay.unselect(selectedEntityID);
|
selectionDisplay.unselect(selectedEntityID);
|
||||||
entitySelected = false;
|
entitySelected = false;
|
||||||
|
selectionManager.clearSelections();
|
||||||
} else {
|
} else {
|
||||||
print(" Delete Entity.... not holding...");
|
print(" Delete Entity.... not holding...");
|
||||||
}
|
}
|
||||||
|
@ -618,7 +621,7 @@ function handeMenuEvent(menuItem) {
|
||||||
// good place to put the properties dialog
|
// good place to put the properties dialog
|
||||||
|
|
||||||
editModelID = -1;
|
editModelID = -1;
|
||||||
if (entitySelected) {
|
if (selectionManager.selections.length == 1) {
|
||||||
print(" Edit Properties.... selectedEntityID="+ selectedEntityID);
|
print(" Edit Properties.... selectedEntityID="+ selectedEntityID);
|
||||||
editModelID = selectedEntityID;
|
editModelID = selectedEntityID;
|
||||||
} else {
|
} else {
|
||||||
|
@ -653,7 +656,7 @@ Controller.keyReleaseEvent.connect(function (event) {
|
||||||
if (event.text == "`") {
|
if (event.text == "`") {
|
||||||
handeMenuEvent("Edit Properties...");
|
handeMenuEvent("Edit Properties...");
|
||||||
}
|
}
|
||||||
if (event.text == "BACKSPACE") {
|
if (event.text == "BACKSPACE" || event.text == "DELETE") {
|
||||||
handeMenuEvent("Delete");
|
handeMenuEvent("Delete");
|
||||||
} else if (event.text == "TAB") {
|
} else if (event.text == "TAB") {
|
||||||
selectionDisplay.toggleSpaceMode();
|
selectionDisplay.toggleSpaceMode();
|
||||||
|
|
|
@ -172,6 +172,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_nodeBoundsDisplay(this),
|
_nodeBoundsDisplay(this),
|
||||||
_previousScriptLocation(),
|
_previousScriptLocation(),
|
||||||
_applicationOverlay(),
|
_applicationOverlay(),
|
||||||
|
_undoStack(),
|
||||||
|
_undoStackScriptingInterface(&_undoStack),
|
||||||
_runningScriptsWidget(NULL),
|
_runningScriptsWidget(NULL),
|
||||||
_runningScriptsWidgetWasVisible(false),
|
_runningScriptsWidgetWasVisible(false),
|
||||||
_trayIcon(new QSystemTrayIcon(_window)),
|
_trayIcon(new QSystemTrayIcon(_window)),
|
||||||
|
@ -3765,8 +3767,9 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser
|
||||||
// AvatarManager has some custom types
|
// AvatarManager has some custom types
|
||||||
AvatarManager::registerMetaTypes(scriptEngine);
|
AvatarManager::registerMetaTypes(scriptEngine);
|
||||||
|
|
||||||
// hook our avatar object into this script engine
|
// hook our avatar and avatar hash map object into this script engine
|
||||||
scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features
|
scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features
|
||||||
|
scriptEngine->setAvatarHashMap(&_avatarManager, "AvatarList");
|
||||||
|
|
||||||
CameraScriptableObject* cameraScriptable = new CameraScriptableObject(&_myCamera, &_viewFrustum);
|
CameraScriptableObject* cameraScriptable = new CameraScriptableObject(&_myCamera, &_viewFrustum);
|
||||||
scriptEngine->registerGlobalObject("Camera", cameraScriptable);
|
scriptEngine->registerGlobalObject("Camera", cameraScriptable);
|
||||||
|
@ -3809,6 +3812,8 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser
|
||||||
scriptEngine->registerGlobalObject("Joysticks", &JoystickScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Joysticks", &JoystickScriptingInterface::getInstance());
|
||||||
qScriptRegisterMetaType(scriptEngine, joystickToScriptValue, joystickFromScriptValue);
|
qScriptRegisterMetaType(scriptEngine, joystickToScriptValue, joystickFromScriptValue);
|
||||||
|
|
||||||
|
scriptEngine->registerGlobalObject("UndoStack", &_undoStackScriptingInterface);
|
||||||
|
|
||||||
#ifdef HAVE_RTMIDI
|
#ifdef HAVE_RTMIDI
|
||||||
scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
|
scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -91,6 +91,9 @@
|
||||||
#include "voxels/VoxelSystem.h"
|
#include "voxels/VoxelSystem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "UndoStackScriptingInterface.h"
|
||||||
|
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class QActionGroup;
|
class QActionGroup;
|
||||||
class QGLWidget;
|
class QGLWidget;
|
||||||
|
@ -450,6 +453,7 @@ private:
|
||||||
int _numChangedSettings;
|
int _numChangedSettings;
|
||||||
|
|
||||||
QUndoStack _undoStack;
|
QUndoStack _undoStack;
|
||||||
|
UndoStackScriptingInterface _undoStackScriptingInterface;
|
||||||
|
|
||||||
glm::vec3 _gravity;
|
glm::vec3 _gravity;
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,6 @@ glm::vec3 OculusManager::_calibrationPosition;
|
||||||
glm::quat OculusManager::_calibrationOrientation;
|
glm::quat OculusManager::_calibrationOrientation;
|
||||||
quint64 OculusManager::_calibrationStartTime;
|
quint64 OculusManager::_calibrationStartTime;
|
||||||
int OculusManager::_calibrationMessage = NULL;
|
int OculusManager::_calibrationMessage = NULL;
|
||||||
QString OculusManager::CALIBRATION_BILLBOARD_URL = "http://hifi-public.s3.amazonaws.com/images/hold-to-calibrate.svg";
|
|
||||||
float OculusManager::CALIBRATION_BILLBOARD_SCALE = 2.f;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -191,7 +189,7 @@ void OculusManager::disconnect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBOVR
|
#ifdef HAVE_LIBOVR
|
||||||
void OculusManager::positionCalibrationBillboard(BillboardOverlay* billboard) {
|
void OculusManager::positionCalibrationBillboard(Text3DOverlay* billboard) {
|
||||||
glm::quat headOrientation = Application::getInstance()->getAvatar()->getHeadOrientation();
|
glm::quat headOrientation = Application::getInstance()->getAvatar()->getHeadOrientation();
|
||||||
headOrientation.x = 0;
|
headOrientation.x = 0;
|
||||||
headOrientation.z = 0;
|
headOrientation.z = 0;
|
||||||
|
@ -204,8 +202,9 @@ void OculusManager::positionCalibrationBillboard(BillboardOverlay* billboard) {
|
||||||
|
|
||||||
#ifdef HAVE_LIBOVR
|
#ifdef HAVE_LIBOVR
|
||||||
void OculusManager::calibrate(glm::vec3 position, glm::quat orientation) {
|
void OculusManager::calibrate(glm::vec3 position, glm::quat orientation) {
|
||||||
|
static QString instructionMessage = "Hold still to calibrate";
|
||||||
static QString progressMessage;
|
static QString progressMessage;
|
||||||
static BillboardOverlay* billboard;
|
static Text3DOverlay* billboard;
|
||||||
|
|
||||||
switch (_calibrationState) {
|
switch (_calibrationState) {
|
||||||
|
|
||||||
|
@ -235,9 +234,13 @@ void OculusManager::calibrate(glm::vec3 position, glm::quat orientation) {
|
||||||
if (!_calibrationMessage) {
|
if (!_calibrationMessage) {
|
||||||
qDebug() << "Hold still to calibrate HMD";
|
qDebug() << "Hold still to calibrate HMD";
|
||||||
|
|
||||||
billboard = new BillboardOverlay();
|
billboard = new Text3DOverlay();
|
||||||
billboard->setURL(CALIBRATION_BILLBOARD_URL);
|
billboard->setDimensions(glm::vec2(2.0f, 1.25f));
|
||||||
billboard->setScale(CALIBRATION_BILLBOARD_SCALE);
|
billboard->setTopMargin(0.35f);
|
||||||
|
billboard->setLeftMargin(0.28f);
|
||||||
|
billboard->setText(instructionMessage);
|
||||||
|
billboard->setAlpha(0.5f);
|
||||||
|
billboard->setLineHeight(0.1f);
|
||||||
billboard->setIsFacingAvatar(false);
|
billboard->setIsFacingAvatar(false);
|
||||||
positionCalibrationBillboard(billboard);
|
positionCalibrationBillboard(billboard);
|
||||||
|
|
||||||
|
@ -275,7 +278,7 @@ void OculusManager::calibrate(glm::vec3 position, glm::quat orientation) {
|
||||||
} else {
|
} else {
|
||||||
progressMessage += ".";
|
progressMessage += ".";
|
||||||
}
|
}
|
||||||
//qDebug() << progressMessage; // Progress message ready for 3D text overlays.
|
billboard->setText(instructionMessage + "\n\n" + progressMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "renderer/ProgramObject.h"
|
#include "renderer/ProgramObject.h"
|
||||||
#include "ui/overlays/BillboardOverlay.h"
|
#include "ui/overlays/Text3DOverlay.h"
|
||||||
|
|
||||||
const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f;
|
const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ private:
|
||||||
WAITING_FOR_ZERO_HELD,
|
WAITING_FOR_ZERO_HELD,
|
||||||
CALIBRATED
|
CALIBRATED
|
||||||
};
|
};
|
||||||
static void positionCalibrationBillboard(BillboardOverlay* billboard);
|
static void positionCalibrationBillboard(Text3DOverlay* message);
|
||||||
static float CALIBRATION_DELTA_MINIMUM_LENGTH;
|
static float CALIBRATION_DELTA_MINIMUM_LENGTH;
|
||||||
static float CALIBRATION_DELTA_MINIMUM_ANGLE;
|
static float CALIBRATION_DELTA_MINIMUM_ANGLE;
|
||||||
static float CALIBRATION_ZERO_MAXIMUM_LENGTH;
|
static float CALIBRATION_ZERO_MAXIMUM_LENGTH;
|
||||||
|
@ -123,8 +123,6 @@ private:
|
||||||
static glm::quat _calibrationOrientation;
|
static glm::quat _calibrationOrientation;
|
||||||
static quint64 _calibrationStartTime;
|
static quint64 _calibrationStartTime;
|
||||||
static int _calibrationMessage;
|
static int _calibrationMessage;
|
||||||
static QString CALIBRATION_BILLBOARD_URL;
|
|
||||||
static float CALIBRATION_BILLBOARD_SCALE;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
float getTopMargin() const { return _topMargin; }
|
float getTopMargin() const { return _topMargin; }
|
||||||
float getRightMargin() const { return _rightMargin; }
|
float getRightMargin() const { return _rightMargin; }
|
||||||
float getBottomMargin() const { return _bottomMargin; }
|
float getBottomMargin() const { return _bottomMargin; }
|
||||||
|
bool getIsFacingAvatar() const { return _isFacingAvatar; }
|
||||||
xColor getBackgroundColor();
|
xColor getBackgroundColor();
|
||||||
|
|
||||||
// setters
|
// setters
|
||||||
|
@ -41,6 +42,7 @@ public:
|
||||||
void setTopMargin(float margin) { _topMargin = margin; }
|
void setTopMargin(float margin) { _topMargin = margin; }
|
||||||
void setRightMargin(float margin) { _rightMargin = margin; }
|
void setRightMargin(float margin) { _rightMargin = margin; }
|
||||||
void setBottomMargin(float margin) { _bottomMargin = margin; }
|
void setBottomMargin(float margin) { _bottomMargin = margin; }
|
||||||
|
void setIsFacingAvatar(bool isFacingAvatar) { _isFacingAvatar = isFacingAvatar; }
|
||||||
|
|
||||||
virtual void setProperties(const QScriptValue& properties);
|
virtual void setProperties(const QScriptValue& properties);
|
||||||
|
|
||||||
|
|
|
@ -381,6 +381,8 @@ private:
|
||||||
AvatarData& operator= (const AvatarData&);
|
AvatarData& operator= (const AvatarData&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(AvatarData*)
|
||||||
|
|
||||||
class JointData {
|
class JointData {
|
||||||
public:
|
public:
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
|
@ -21,6 +21,7 @@ AvatarHashMap::AvatarHashMap() :
|
||||||
connect(NodeList::getInstance(), &NodeList::uuidChanged, this, &AvatarHashMap::sessionUUIDChanged);
|
connect(NodeList::getInstance(), &NodeList::uuidChanged, this, &AvatarHashMap::sessionUUIDChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AvatarHash::iterator AvatarHashMap::erase(const AvatarHash::iterator& iterator) {
|
AvatarHash::iterator AvatarHashMap::erase(const AvatarHash::iterator& iterator) {
|
||||||
qDebug() << "Removing Avatar with UUID" << iterator.key() << "from AvatarHashMap.";
|
qDebug() << "Removing Avatar with UUID" << iterator.key() << "from AvatarHashMap.";
|
||||||
return _avatarHash.erase(iterator);
|
return _avatarHash.erase(iterator);
|
||||||
|
@ -53,29 +54,26 @@ void AvatarHashMap::processAvatarMixerDatagram(const QByteArray& datagram, const
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AvatarHashMap::containsAvatarWithDisplayName(const QString& displayName) {
|
bool AvatarHashMap::containsAvatarWithDisplayName(const QString& displayName) {
|
||||||
|
return avatarWithDisplayName(displayName) == NULL ? false : true;
|
||||||
AvatarHash::iterator avatarIterator = _avatarHash.begin();
|
}
|
||||||
while (avatarIterator != _avatarHash.end()) {
|
|
||||||
AvatarSharedPointer sharedAvatar = avatarIterator.value();
|
AvatarData* AvatarHashMap::avatarWithDisplayName(const QString& displayName) {
|
||||||
if (avatarIterator.value()->getDisplayName() == displayName) {
|
foreach(const AvatarSharedPointer& sharedAvatar, _avatarHash) {
|
||||||
|
if (sharedAvatar->getDisplayName() == displayName) {
|
||||||
// this is a match
|
// this is a match
|
||||||
// check if this avatar should still be around
|
// check if this avatar should still be around
|
||||||
if (!shouldKillAvatar(sharedAvatar)) {
|
if (!shouldKillAvatar(sharedAvatar)) {
|
||||||
// we have a match, return true
|
// we have a match, return the AvatarData
|
||||||
return true;
|
return sharedAvatar.data();
|
||||||
} else {
|
} else {
|
||||||
// we should remove this avatar, do that now
|
// we should remove this avatar, but we might not be on a thread that is allowed
|
||||||
erase(avatarIterator);
|
// so we just return NULL to the caller
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
++avatarIterator;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return false, no match
|
return NULL;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarSharedPointer AvatarHashMap::newSharedAvatar() {
|
AvatarSharedPointer AvatarHashMap::newSharedAvatar() {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "AvatarData.h"
|
#include "AvatarData.h"
|
||||||
|
|
||||||
typedef QSharedPointer<AvatarData> AvatarSharedPointer;
|
typedef QSharedPointer<AvatarData> AvatarSharedPointer;
|
||||||
|
typedef QWeakPointer<AvatarData> AvatarWeakPointer;
|
||||||
typedef QHash<QUuid, AvatarSharedPointer> AvatarHash;
|
typedef QHash<QUuid, AvatarSharedPointer> AvatarHash;
|
||||||
|
|
||||||
class AvatarHashMap : public QObject {
|
class AvatarHashMap : public QObject {
|
||||||
|
@ -34,6 +35,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void processAvatarMixerDatagram(const QByteArray& datagram, const QWeakPointer<Node>& mixerWeakPointer);
|
void processAvatarMixerDatagram(const QByteArray& datagram, const QWeakPointer<Node>& mixerWeakPointer);
|
||||||
bool containsAvatarWithDisplayName(const QString& displayName);
|
bool containsAvatarWithDisplayName(const QString& displayName);
|
||||||
|
AvatarData* avatarWithDisplayName(const QString& displayname);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID);
|
void sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID);
|
||||||
|
|
|
@ -301,10 +301,10 @@ void DatagramSequencer::clearReliableChannel(QObject* object) {
|
||||||
void DatagramSequencer::sendRecordAcknowledged(const SendRecord& record) {
|
void DatagramSequencer::sendRecordAcknowledged(const SendRecord& record) {
|
||||||
// stop acknowledging the recorded packets
|
// stop acknowledging the recorded packets
|
||||||
while (!_receiveRecords.isEmpty() && _receiveRecords.first().packetNumber <= record.lastReceivedPacketNumber) {
|
while (!_receiveRecords.isEmpty() && _receiveRecords.first().packetNumber <= record.lastReceivedPacketNumber) {
|
||||||
|
emit receiveAcknowledged(0);
|
||||||
const ReceiveRecord& received = _receiveRecords.first();
|
const ReceiveRecord& received = _receiveRecords.first();
|
||||||
_inputStream.persistReadMappings(received.mappings);
|
_inputStream.persistReadMappings(received.mappings);
|
||||||
_receivedHighPriorityMessages -= received.newHighPriorityMessages;
|
_receivedHighPriorityMessages -= received.newHighPriorityMessages;
|
||||||
emit receiveAcknowledged(0);
|
|
||||||
_receiveRecords.removeFirst();
|
_receiveRecords.removeFirst();
|
||||||
}
|
}
|
||||||
_outputStream.persistWriteMappings(record.mappings);
|
_outputStream.persistWriteMappings(record.mappings);
|
||||||
|
|
|
@ -108,6 +108,9 @@ public:
|
||||||
/// Returns the intput channel at the specified index, creating it if necessary.
|
/// Returns the intput channel at the specified index, creating it if necessary.
|
||||||
ReliableChannel* getReliableInputChannel(int index = 0);
|
ReliableChannel* getReliableInputChannel(int index = 0);
|
||||||
|
|
||||||
|
/// Returns a reference to the stored receive mappings at the specified index.
|
||||||
|
const Bitstream::ReadMappings& getReadMappings(int index) const { return _receiveRecords.at(index).mappings; }
|
||||||
|
|
||||||
/// Adds stats for all reliable channels to the referenced variables.
|
/// Adds stats for all reliable channels to the referenced variables.
|
||||||
void addReliableChannelStats(int& sendProgress, int& sendTotal, int& receiveProgress, int& receiveTotal) const;
|
void addReliableChannelStats(int& sendProgress, int& sendTotal, int& receiveProgress, int& receiveTotal) const;
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,9 @@ MetavoxelClient::MetavoxelClient(const SharedNodePointer& node, MetavoxelUpdater
|
||||||
Endpoint(node, new PacketRecord(), new PacketRecord()),
|
Endpoint(node, new PacketRecord(), new PacketRecord()),
|
||||||
_updater(updater),
|
_updater(updater),
|
||||||
_reliableDeltaChannel(NULL),
|
_reliableDeltaChannel(NULL),
|
||||||
_reliableDeltaID(0) {
|
_reliableDeltaID(0),
|
||||||
|
_dummyInputStream(_dummyDataStream),
|
||||||
|
_dummyPacketNumber(0) {
|
||||||
|
|
||||||
connect(_sequencer.getReliableInputChannel(RELIABLE_DELTA_CHANNEL_INDEX),
|
connect(_sequencer.getReliableInputChannel(RELIABLE_DELTA_CHANNEL_INDEX),
|
||||||
SIGNAL(receivedMessage(const QVariant&, Bitstream&)), SLOT(handleMessage(const QVariant&, Bitstream&)));
|
SIGNAL(receivedMessage(const QVariant&, Bitstream&)), SLOT(handleMessage(const QVariant&, Bitstream&)));
|
||||||
|
@ -234,9 +236,9 @@ PacketRecord* MetavoxelClient::getAcknowledgedReceiveRecord(int packetNumber) co
|
||||||
if (lastAcknowledged->getPacketNumber() == packetNumber) {
|
if (lastAcknowledged->getPacketNumber() == packetNumber) {
|
||||||
return lastAcknowledged;
|
return lastAcknowledged;
|
||||||
}
|
}
|
||||||
foreach (PacketRecord* record, _clearedReceiveRecords) {
|
foreach (const ClearedReceiveRecord& record, _clearedReceiveRecords) {
|
||||||
if (record->getPacketNumber() == packetNumber) {
|
if (record.first->getPacketNumber() == packetNumber) {
|
||||||
return record;
|
return record.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -257,8 +259,8 @@ void MetavoxelClient::recordReceive() {
|
||||||
}
|
}
|
||||||
_clearedSendRecords.clear();
|
_clearedSendRecords.clear();
|
||||||
|
|
||||||
foreach (PacketRecord* record, _clearedReceiveRecords) {
|
foreach (const ClearedReceiveRecord& record, _clearedReceiveRecords) {
|
||||||
delete record;
|
delete record.first;
|
||||||
}
|
}
|
||||||
_clearedReceiveRecords.clear();
|
_clearedReceiveRecords.clear();
|
||||||
}
|
}
|
||||||
|
@ -273,10 +275,16 @@ void MetavoxelClient::clearSendRecordsBefore(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetavoxelClient::clearReceiveRecordsBefore(int index) {
|
void MetavoxelClient::clearReceiveRecordsBefore(int index) {
|
||||||
|
// copy the mappings on first call per packet
|
||||||
|
if (_sequencer.getIncomingPacketNumber() > _dummyPacketNumber) {
|
||||||
|
_dummyPacketNumber = _sequencer.getIncomingPacketNumber();
|
||||||
|
_dummyInputStream.copyPersistentMappings(_sequencer.getInputStream());
|
||||||
|
}
|
||||||
|
|
||||||
// move to cleared list
|
// move to cleared list
|
||||||
QList<PacketRecord*>::iterator end = _receiveRecords.begin() + index + 1;
|
QList<PacketRecord*>::iterator end = _receiveRecords.begin() + index + 1;
|
||||||
for (QList<PacketRecord*>::const_iterator it = _receiveRecords.begin(); it != end; it++) {
|
for (QList<PacketRecord*>::const_iterator it = _receiveRecords.begin(); it != end; it++) {
|
||||||
_clearedReceiveRecords.append(*it);
|
_clearedReceiveRecords.append(ClearedReceiveRecord(*it, _sequencer.getReadMappings(index)));
|
||||||
}
|
}
|
||||||
_receiveRecords.erase(_receiveRecords.begin(), end);
|
_receiveRecords.erase(_receiveRecords.begin(), end);
|
||||||
}
|
}
|
||||||
|
@ -289,7 +297,6 @@ void MetavoxelClient::writeUpdateMessage(Bitstream& out) {
|
||||||
void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
|
void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
|
||||||
int userType = message.userType();
|
int userType = message.userType();
|
||||||
if (userType == MetavoxelDeltaMessage::Type) {
|
if (userType == MetavoxelDeltaMessage::Type) {
|
||||||
PacketRecord* receiveRecord = getLastAcknowledgedReceiveRecord();
|
|
||||||
if (_reliableDeltaChannel) {
|
if (_reliableDeltaChannel) {
|
||||||
MetavoxelData reference = _remoteData;
|
MetavoxelData reference = _remoteData;
|
||||||
MetavoxelLOD referenceLOD = _remoteDataLOD;
|
MetavoxelLOD referenceLOD = _remoteDataLOD;
|
||||||
|
@ -299,6 +306,7 @@ void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
|
||||||
_reliableDeltaChannel = NULL;
|
_reliableDeltaChannel = NULL;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
PacketRecord* receiveRecord = getLastAcknowledgedReceiveRecord();
|
||||||
_remoteData.readDelta(receiveRecord->getData(), receiveRecord->getLOD(), in,
|
_remoteData.readDelta(receiveRecord->getData(), receiveRecord->getLOD(), in,
|
||||||
_remoteDataLOD = getLastAcknowledgedSendRecord()->getLOD());
|
_remoteDataLOD = getLastAcknowledgedSendRecord()->getLOD());
|
||||||
in.reset();
|
in.reset();
|
||||||
|
@ -319,8 +327,6 @@ void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
|
||||||
MetavoxelDeltaPendingMessage pending = message.value<MetavoxelDeltaPendingMessage>();
|
MetavoxelDeltaPendingMessage pending = message.value<MetavoxelDeltaPendingMessage>();
|
||||||
if (pending.id > _reliableDeltaID) {
|
if (pending.id > _reliableDeltaID) {
|
||||||
_reliableDeltaID = pending.id;
|
_reliableDeltaID = pending.id;
|
||||||
_reliableDeltaChannel = _sequencer.getReliableInputChannel(RELIABLE_DELTA_CHANNEL_INDEX);
|
|
||||||
_reliableDeltaChannel->getBitstream().copyPersistentMappings(_sequencer.getInputStream());
|
|
||||||
PacketRecord* sendRecord = getAcknowledgedSendRecord(pending.receivedPacketNumber);
|
PacketRecord* sendRecord = getAcknowledgedSendRecord(pending.receivedPacketNumber);
|
||||||
if (!sendRecord) {
|
if (!sendRecord) {
|
||||||
qWarning() << "Missing send record for delta" << pending.receivedPacketNumber;
|
qWarning() << "Missing send record for delta" << pending.receivedPacketNumber;
|
||||||
|
@ -334,6 +340,20 @@ void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
|
||||||
}
|
}
|
||||||
_remoteDataLOD = receiveRecord->getLOD();
|
_remoteDataLOD = receiveRecord->getLOD();
|
||||||
_remoteData = receiveRecord->getData();
|
_remoteData = receiveRecord->getData();
|
||||||
|
|
||||||
|
_reliableDeltaChannel = _sequencer.getReliableInputChannel(RELIABLE_DELTA_CHANNEL_INDEX);
|
||||||
|
if (receiveRecord == getLastAcknowledgedReceiveRecord()) {
|
||||||
|
_reliableDeltaChannel->getBitstream().copyPersistentMappings(_sequencer.getInputStream());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_reliableDeltaChannel->getBitstream().copyPersistentMappings(_dummyInputStream);
|
||||||
|
foreach (const ClearedReceiveRecord& record, _clearedReceiveRecords) {
|
||||||
|
_reliableDeltaChannel->getBitstream().persistReadMappings(record.second);
|
||||||
|
if (record.first == receiveRecord) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Endpoint::handleMessage(message, in);
|
Endpoint::handleMessage(message, in);
|
||||||
|
|
|
@ -145,8 +145,13 @@ protected:
|
||||||
MetavoxelData _dataCopy;
|
MetavoxelData _dataCopy;
|
||||||
QReadWriteLock _dataCopyLock;
|
QReadWriteLock _dataCopyLock;
|
||||||
|
|
||||||
|
QDataStream _dummyDataStream;
|
||||||
|
Bitstream _dummyInputStream;
|
||||||
|
int _dummyPacketNumber;
|
||||||
QList<PacketRecord*> _clearedSendRecords;
|
QList<PacketRecord*> _clearedSendRecords;
|
||||||
QList<PacketRecord*> _clearedReceiveRecords;
|
|
||||||
|
typedef QPair<PacketRecord*, Bitstream::ReadMappings> ClearedReceiveRecord;
|
||||||
|
QList<ClearedReceiveRecord> _clearedReceiveRecords;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_MetavoxelClientManager_h
|
#endif // hifi_MetavoxelClientManager_h
|
||||||
|
|
|
@ -701,8 +701,7 @@ int VoxelMaterialSpannerEditVisitor::visit(MetavoxelInfo& info) {
|
||||||
int sizeY = (int)overlap.maximum.y - minY + 1;
|
int sizeY = (int)overlap.maximum.y - minY + 1;
|
||||||
int sizeZ = (int)overlap.maximum.z - minZ + 1;
|
int sizeZ = (int)overlap.maximum.z - minZ + 1;
|
||||||
|
|
||||||
QRgb rgb = _color.rgba();
|
bool flipped = false;
|
||||||
bool flipped = (qAlpha(rgb) == 0);
|
|
||||||
float step = 1.0f / scale;
|
float step = 1.0f / scale;
|
||||||
glm::vec3 position(0.0f, 0.0f, info.minimum.z + minZ * step);
|
glm::vec3 position(0.0f, 0.0f, info.minimum.z + minZ * step);
|
||||||
if (_spanner->hasOwnColors()) {
|
if (_spanner->hasOwnColors()) {
|
||||||
|
@ -720,6 +719,8 @@ int VoxelMaterialSpannerEditVisitor::visit(MetavoxelInfo& info) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
QRgb rgb = _color.rgba();
|
||||||
|
flipped = (qAlpha(rgb) == 0);
|
||||||
for (QRgb* destZ = colorContents.data() + minZ * VOXEL_BLOCK_AREA + minY * VOXEL_BLOCK_SAMPLES + minX,
|
for (QRgb* destZ = colorContents.data() + minZ * VOXEL_BLOCK_AREA + minY * VOXEL_BLOCK_SAMPLES + minX,
|
||||||
*endZ = destZ + sizeZ * VOXEL_BLOCK_AREA; destZ != endZ; destZ += VOXEL_BLOCK_AREA, position.z += step) {
|
*endZ = destZ + sizeZ * VOXEL_BLOCK_AREA; destZ != endZ; destZ += VOXEL_BLOCK_AREA, position.z += step) {
|
||||||
position.y = info.minimum.y + minY * step;
|
position.y = info.minimum.y + minY * step;
|
||||||
|
|
|
@ -63,7 +63,15 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){
|
||||||
return QScriptValue();
|
return QScriptValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue injectorToScriptValue(QScriptEngine *engine, AudioInjector* const &in) {
|
QScriptValue avatarDataToScriptValue(QScriptEngine* engine, AvatarData* const &in) {
|
||||||
|
return engine->newQObject(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
void avatarDataFromScriptValue(const QScriptValue &object, AvatarData* &out) {
|
||||||
|
out = qobject_cast<AvatarData*>(object.toQObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
QScriptValue injectorToScriptValue(QScriptEngine* engine, AudioInjector* const &in) {
|
||||||
return engine->newQObject(in);
|
return engine->newQObject(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +280,7 @@ void ScriptEngine::init() {
|
||||||
|
|
||||||
qScriptRegisterMetaType(this, injectorToScriptValue, injectorFromScriptValue);
|
qScriptRegisterMetaType(this, injectorToScriptValue, injectorFromScriptValue);
|
||||||
qScriptRegisterMetaType(this, inputControllerToScriptValue, inputControllerFromScriptValue);
|
qScriptRegisterMetaType(this, inputControllerToScriptValue, inputControllerFromScriptValue);
|
||||||
|
qScriptRegisterMetaType(this, avatarDataToScriptValue, avatarDataFromScriptValue);
|
||||||
qScriptRegisterMetaType(this, animationDetailsToScriptValue, animationDetailsFromScriptValue);
|
qScriptRegisterMetaType(this, animationDetailsToScriptValue, animationDetailsFromScriptValue);
|
||||||
|
|
||||||
registerGlobalObject("Script", this);
|
registerGlobalObject("Script", this);
|
||||||
|
|
58
libraries/script-engine/src/UndoStackScriptingInterface.cpp
Normal file
58
libraries/script-engine/src/UndoStackScriptingInterface.cpp
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
//
|
||||||
|
// UndoStackScriptingInterface.cpp
|
||||||
|
// libraries/script-engine/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 10/22/14.
|
||||||
|
// Copyright 2014 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 <QDebug>
|
||||||
|
#include <QScriptValue>
|
||||||
|
#include <QScriptValueList>
|
||||||
|
#include <QScriptEngine>
|
||||||
|
|
||||||
|
#include "UndoStackScriptingInterface.h"
|
||||||
|
|
||||||
|
UndoStackScriptingInterface::UndoStackScriptingInterface(QUndoStack* undoStack) : _undoStack(undoStack) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoStackScriptingInterface::pushCommand(QScriptValue undoFunction, QScriptValue undoData,
|
||||||
|
QScriptValue redoFunction, QScriptValue redoData) {
|
||||||
|
if (undoFunction.engine()) {
|
||||||
|
ScriptUndoCommand* undoCommand = new ScriptUndoCommand(undoFunction, undoData, redoFunction, redoData);
|
||||||
|
undoCommand->moveToThread(undoFunction.engine()->thread());
|
||||||
|
_undoStack->push(undoCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptUndoCommand::ScriptUndoCommand(QScriptValue undoFunction, QScriptValue undoData,
|
||||||
|
QScriptValue redoFunction, QScriptValue redoData) :
|
||||||
|
_undoFunction(undoFunction),
|
||||||
|
_undoData(undoData),
|
||||||
|
_redoFunction(redoFunction),
|
||||||
|
_redoData(redoData) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptUndoCommand::undo() {
|
||||||
|
QMetaObject::invokeMethod(this, "doUndo");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptUndoCommand::redo() {
|
||||||
|
QMetaObject::invokeMethod(this, "doRedo");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptUndoCommand::doUndo() {
|
||||||
|
QScriptValueList args;
|
||||||
|
args << _undoData;
|
||||||
|
_undoFunction.call(QScriptValue(), args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ScriptUndoCommand::doRedo() {
|
||||||
|
QScriptValueList args;
|
||||||
|
args << _redoData;
|
||||||
|
_redoFunction.call(QScriptValue(), args);
|
||||||
|
}
|
52
libraries/script-engine/src/UndoStackScriptingInterface.h
Normal file
52
libraries/script-engine/src/UndoStackScriptingInterface.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
//
|
||||||
|
// UndoStackScriptingInterface.h
|
||||||
|
// libraries/script-engine/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 10/22/14.
|
||||||
|
// Copyright 2014 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_UndoStackScriptingInterface_h
|
||||||
|
#define hifi_UndoStackScriptingInterface_h
|
||||||
|
|
||||||
|
#include <QUndoCommand>
|
||||||
|
#include <QUndoStack>
|
||||||
|
#include <QScriptValue>
|
||||||
|
|
||||||
|
class UndoStackScriptingInterface : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
UndoStackScriptingInterface(QUndoStack* undoStack);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void pushCommand(QScriptValue undoFunction, QScriptValue undoData, QScriptValue redoFunction, QScriptValue redoData);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QUndoStack* _undoStack;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ScriptUndoCommand : public QObject, public QUndoCommand {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ScriptUndoCommand(QScriptValue undoFunction, QScriptValue undoData, QScriptValue redoFunction, QScriptValue redoData);
|
||||||
|
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
virtual bool mergeWith(const QUndoCommand* command) { return false; }
|
||||||
|
virtual int id() const { return -1; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void doUndo();
|
||||||
|
void doRedo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QScriptValue _undoFunction;
|
||||||
|
QScriptValue _undoData;
|
||||||
|
QScriptValue _redoFunction;
|
||||||
|
QScriptValue _redoData;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_UndoStackScriptingInterface_h
|
Loading…
Reference in a new issue