Merge branch 'master' of https://github.com/highfidelity/hifi into 20143

This commit is contained in:
stojce 2014-10-23 14:26:13 +02:00
commit 4e75837a64
21 changed files with 278 additions and 63 deletions

View file

@ -237,8 +237,7 @@ void MetavoxelSession::update() {
// go back to the beginning with the current packet and note that there's a delta pending
_sequencer.getOutputStream().getUnderlying().device()->seek(start);
MetavoxelDeltaPendingMessage msg = { ++_reliableDeltaID, sendRecord->getPacketNumber(),
_sequencer.getIncomingPacketNumber() };
MetavoxelDeltaPendingMessage msg = { ++_reliableDeltaID, sendRecord->getPacketNumber(), _lodPacketNumber };
out << (_reliableDeltaMessage = QVariant::fromValue(msg));
_sequencer.endPacket();
@ -265,7 +264,8 @@ void MetavoxelSession::handleMessage(const QVariant& message) {
if (userType == ClientStateMessage::Type) {
ClientStateMessage state = message.value<ClientStateMessage>();
_lod = state.lod;
_lodPacketNumber = _sequencer.getIncomingPacketNumber();
} else if (userType == MetavoxelEditMessage::Type) {
QMetaObject::invokeMethod(_sender->getServer(), "applyEdit", Q_ARG(const MetavoxelEditMessage&,
message.value<MetavoxelEditMessage>()));

View file

@ -127,6 +127,7 @@ private:
MetavoxelSender* _sender;
MetavoxelLOD _lod;
int _lodPacketNumber;
ReliableChannel* _reliableDeltaChannel;
int _reliableDeltaReceivedOffset;

View file

@ -64,7 +64,6 @@ function activateWarp() {
var TRIGGER_PULLBACK_DISTANCE = 0.04;
var WATCH_AVATAR_DISTANCE = 1.5;
var MAX_WARP_YAW = 40.0;
var MAX_PULLBACK_YAW = 5.0;
var sound = new Sound("http://public.highfidelity.io/sounds/Footsteps/FootstepW2Right-12db.wav");
@ -72,7 +71,7 @@ function playSound() {
var options = new AudioInjectionOptions();
var position = MyAvatar.position;
options.position = position;
options.volume = 0.5;
options.volume = 1.0;
Audio.playSound(sound, options);
}
@ -89,7 +88,7 @@ function updateWarp() {
var deltaPitch = MyAvatar.getHeadFinalPitch() - headStartFinalPitch;
deltaYaw = MyAvatar.getHeadFinalYaw() - headStartYaw;
willMove = (!watchAvatar && (Math.abs(deltaYaw) < MAX_WARP_YAW) && (keyDownTime > WARP_START_TIME));
willMove = (!watchAvatar && (keyDownTime > WARP_START_TIME));
if (willMove) {
//var distance = Math.pow((deltaPitch - WARP_PITCH_DEAD_ZONE) * WARP_SENSITIVITY, 2.0);

View file

@ -78,6 +78,8 @@ SelectionManager = (function() {
that.worldDimensions = null;
that.worldPosition = null;
} else if (that.selections.length == 1) {
SelectionDisplay.setSpaceMode(SPACE_LOCAL);
var properties = Entities.getEntityProperties(that.selections[0]);
that.localDimensions = properties.dimensions;
that.localPosition = properties.position;
@ -622,8 +624,8 @@ SelectionDisplay = (function () {
}
var diagonal = (Vec3.length(properties.dimensions) / 2) * 1.1;
var halfDimensions = Vec3.multiply(properties.dimensions, 0.5);
var diagonal = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1;
var halfDimensions = Vec3.multiply(selectionManager.worldDimensions, 0.5);
innerRadius = diagonal;
outerRadius = diagonal * 1.15;
var innerActive = false;
@ -843,7 +845,7 @@ SelectionDisplay = (function () {
Overlays.editOverlay(grabberMoveUp, { visible: translateHandlesVisible, position: { x: boundsCenter.x, y: top + grabberMoveUpOffset, z: boundsCenter.z } });
that.updateHandles(entityID);
that.updateHandles();
Overlays.editOverlay(baseOfEntityProjectionOverlay,
@ -924,18 +926,17 @@ SelectionDisplay = (function () {
entitySelected = false;
};
that.updateHandles = function(entityID) {
if (!entitySelected) {
that.updateHandles = function() {
// print("Updating handles");
if (SelectionManager.selections.length == 0) {
that.setOverlaysVisible(false);
return;
}
var properties = Entities.getEntityProperties(entityID);
var rotation, dimensions, position;
if (spaceMode == SPACE_LOCAL) {
rotation = properties.rotation;
rotation = SelectionManager.localRotation;
dimensions = SelectionManager.localDimensions;
position = SelectionManager.localPosition;
} else {
@ -1095,6 +1096,44 @@ SelectionDisplay = (function () {
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 translateXZTool = {
mode: 'TRANSLATE_XZ',
@ -1114,6 +1153,8 @@ SelectionDisplay = (function () {
var initialProperties = SelectionManager.savedProperties[entityID.id];
Entities.editEntity(entityID, initialProperties);
}
} else {
pushCommandForSelections();
}
},
onMove: function(event) {
@ -1172,6 +1213,8 @@ SelectionDisplay = (function () {
var initialProperties = SelectionManager.savedProperties[entityID.id];
Entities.editEntity(entityID, initialProperties);
}
} else {
pushCommandForSelections();
}
},
onMove: function(event) {
@ -1334,6 +1377,8 @@ SelectionDisplay = (function () {
var initialProperties = SelectionManager.savedProperties[entityID.id];
Entities.editEntity(entityID, initialProperties);
}
} else {
pushCommandForSelections();
}
};
@ -1496,6 +1541,8 @@ SelectionDisplay = (function () {
var initialProperties = SelectionManager.savedProperties[entityID.id];
Entities.editEntity(entityID, initialProperties);
}
} else {
pushCommandForSelections();
}
},
onMove: function(event) {
@ -1602,6 +1649,8 @@ SelectionDisplay = (function () {
var initialProperties = SelectionManager.savedProperties[entityID.id];
Entities.editEntity(entityID, initialProperties);
}
} else {
pushCommandForSelections();
}
},
onMove: function(event) {
@ -1706,6 +1755,8 @@ SelectionDisplay = (function () {
var initialProperties = SelectionManager.savedProperties[entityID.id];
Entities.editEntity(entityID, initialProperties);
}
} else {
pushCommandForSelections();
}
},
onMove: function(event) {

View file

@ -35,7 +35,7 @@ var entityPropertyDialogBox = EntityPropertyDialogBox;
Script.include("libraries/entityCameraTool.js");
var entityCameraTool = new EntityCameraTool();
selectionManager.setEventListener(selectionDisplay.updateHandles());
selectionManager.setEventListener(selectionDisplay.updateHandles);
var windowDimensions = Controller.getViewportDimensions();
var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/";
@ -608,9 +608,12 @@ function handeMenuEvent(menuItem) {
} else if (menuItem == "Delete") {
if (entitySelected) {
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);
entitySelected = false;
selectionManager.clearSelections();
} else {
print(" Delete Entity.... not holding...");
}
@ -618,7 +621,7 @@ function handeMenuEvent(menuItem) {
// good place to put the properties dialog
editModelID = -1;
if (entitySelected) {
if (selectionManager.selections.length == 1) {
print(" Edit Properties.... selectedEntityID="+ selectedEntityID);
editModelID = selectedEntityID;
} else {
@ -653,7 +656,7 @@ Controller.keyReleaseEvent.connect(function (event) {
if (event.text == "`") {
handeMenuEvent("Edit Properties...");
}
if (event.text == "BACKSPACE") {
if (event.text == "BACKSPACE" || event.text == "DELETE") {
handeMenuEvent("Delete");
} else if (event.text == "TAB") {
selectionDisplay.toggleSpaceMode();

View file

@ -172,6 +172,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_nodeBoundsDisplay(this),
_previousScriptLocation(),
_applicationOverlay(),
_undoStack(),
_undoStackScriptingInterface(&_undoStack),
_runningScriptsWidget(NULL),
_runningScriptsWidgetWasVisible(false),
_trayIcon(new QSystemTrayIcon(_window)),
@ -3765,8 +3767,9 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser
// AvatarManager has some custom types
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->setAvatarHashMap(&_avatarManager, "AvatarList");
CameraScriptableObject* cameraScriptable = new CameraScriptableObject(&_myCamera, &_viewFrustum);
scriptEngine->registerGlobalObject("Camera", cameraScriptable);
@ -3809,6 +3812,8 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser
scriptEngine->registerGlobalObject("Joysticks", &JoystickScriptingInterface::getInstance());
qScriptRegisterMetaType(scriptEngine, joystickToScriptValue, joystickFromScriptValue);
scriptEngine->registerGlobalObject("UndoStack", &_undoStackScriptingInterface);
#ifdef HAVE_RTMIDI
scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
#endif

View file

@ -91,6 +91,9 @@
#include "voxels/VoxelSystem.h"
#include "UndoStackScriptingInterface.h"
class QAction;
class QActionGroup;
class QGLWidget;
@ -450,6 +453,7 @@ private:
int _numChangedSettings;
QUndoStack _undoStack;
UndoStackScriptingInterface _undoStackScriptingInterface;
glm::vec3 _gravity;

View file

@ -66,8 +66,6 @@ glm::vec3 OculusManager::_calibrationPosition;
glm::quat OculusManager::_calibrationOrientation;
quint64 OculusManager::_calibrationStartTime;
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
@ -191,7 +189,7 @@ void OculusManager::disconnect() {
}
#ifdef HAVE_LIBOVR
void OculusManager::positionCalibrationBillboard(BillboardOverlay* billboard) {
void OculusManager::positionCalibrationBillboard(Text3DOverlay* billboard) {
glm::quat headOrientation = Application::getInstance()->getAvatar()->getHeadOrientation();
headOrientation.x = 0;
headOrientation.z = 0;
@ -204,8 +202,9 @@ void OculusManager::positionCalibrationBillboard(BillboardOverlay* billboard) {
#ifdef HAVE_LIBOVR
void OculusManager::calibrate(glm::vec3 position, glm::quat orientation) {
static QString instructionMessage = "Hold still to calibrate";
static QString progressMessage;
static BillboardOverlay* billboard;
static Text3DOverlay* billboard;
switch (_calibrationState) {
@ -235,9 +234,13 @@ void OculusManager::calibrate(glm::vec3 position, glm::quat orientation) {
if (!_calibrationMessage) {
qDebug() << "Hold still to calibrate HMD";
billboard = new BillboardOverlay();
billboard->setURL(CALIBRATION_BILLBOARD_URL);
billboard->setScale(CALIBRATION_BILLBOARD_SCALE);
billboard = new Text3DOverlay();
billboard->setDimensions(glm::vec2(2.0f, 1.25f));
billboard->setTopMargin(0.35f);
billboard->setLeftMargin(0.28f);
billboard->setText(instructionMessage);
billboard->setAlpha(0.5f);
billboard->setLineHeight(0.1f);
billboard->setIsFacingAvatar(false);
positionCalibrationBillboard(billboard);
@ -275,7 +278,7 @@ void OculusManager::calibrate(glm::vec3 position, glm::quat orientation) {
} else {
progressMessage += ".";
}
//qDebug() << progressMessage; // Progress message ready for 3D text overlays.
billboard->setText(instructionMessage + "\n\n" + progressMessage);
}
}
} else {

View file

@ -18,7 +18,7 @@
#endif
#include "renderer/ProgramObject.h"
#include "ui/overlays/BillboardOverlay.h"
#include "ui/overlays/Text3DOverlay.h"
const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f;
@ -111,7 +111,7 @@ private:
WAITING_FOR_ZERO_HELD,
CALIBRATED
};
static void positionCalibrationBillboard(BillboardOverlay* billboard);
static void positionCalibrationBillboard(Text3DOverlay* message);
static float CALIBRATION_DELTA_MINIMUM_LENGTH;
static float CALIBRATION_DELTA_MINIMUM_ANGLE;
static float CALIBRATION_ZERO_MAXIMUM_LENGTH;
@ -123,8 +123,6 @@ private:
static glm::quat _calibrationOrientation;
static quint64 _calibrationStartTime;
static int _calibrationMessage;
static QString CALIBRATION_BILLBOARD_URL;
static float CALIBRATION_BILLBOARD_SCALE;
#endif

View file

@ -32,6 +32,7 @@ public:
float getTopMargin() const { return _topMargin; }
float getRightMargin() const { return _rightMargin; }
float getBottomMargin() const { return _bottomMargin; }
bool getIsFacingAvatar() const { return _isFacingAvatar; }
xColor getBackgroundColor();
// setters
@ -41,6 +42,7 @@ public:
void setTopMargin(float margin) { _topMargin = margin; }
void setRightMargin(float margin) { _rightMargin = margin; }
void setBottomMargin(float margin) { _bottomMargin = margin; }
void setIsFacingAvatar(bool isFacingAvatar) { _isFacingAvatar = isFacingAvatar; }
virtual void setProperties(const QScriptValue& properties);

View file

@ -381,6 +381,8 @@ private:
AvatarData& operator= (const AvatarData&);
};
Q_DECLARE_METATYPE(AvatarData*)
class JointData {
public:
bool valid;

View file

@ -21,6 +21,7 @@ AvatarHashMap::AvatarHashMap() :
connect(NodeList::getInstance(), &NodeList::uuidChanged, this, &AvatarHashMap::sessionUUIDChanged);
}
AvatarHash::iterator AvatarHashMap::erase(const AvatarHash::iterator& iterator) {
qDebug() << "Removing Avatar with UUID" << iterator.key() << "from AvatarHashMap.";
return _avatarHash.erase(iterator);
@ -53,29 +54,26 @@ void AvatarHashMap::processAvatarMixerDatagram(const QByteArray& datagram, const
}
bool AvatarHashMap::containsAvatarWithDisplayName(const QString& displayName) {
AvatarHash::iterator avatarIterator = _avatarHash.begin();
while (avatarIterator != _avatarHash.end()) {
AvatarSharedPointer sharedAvatar = avatarIterator.value();
if (avatarIterator.value()->getDisplayName() == displayName) {
return avatarWithDisplayName(displayName) == NULL ? false : true;
}
AvatarData* AvatarHashMap::avatarWithDisplayName(const QString& displayName) {
foreach(const AvatarSharedPointer& sharedAvatar, _avatarHash) {
if (sharedAvatar->getDisplayName() == displayName) {
// this is a match
// check if this avatar should still be around
if (!shouldKillAvatar(sharedAvatar)) {
// we have a match, return true
return true;
// we have a match, return the AvatarData
return sharedAvatar.data();
} else {
// we should remove this avatar, do that now
erase(avatarIterator);
// we should remove this avatar, but we might not be on a thread that is allowed
// so we just return NULL to the caller
return NULL;
}
break;
} else {
++avatarIterator;
}
}
// return false, no match
return false;
return NULL;
}
AvatarSharedPointer AvatarHashMap::newSharedAvatar() {

View file

@ -21,6 +21,7 @@
#include "AvatarData.h"
typedef QSharedPointer<AvatarData> AvatarSharedPointer;
typedef QWeakPointer<AvatarData> AvatarWeakPointer;
typedef QHash<QUuid, AvatarSharedPointer> AvatarHash;
class AvatarHashMap : public QObject {
@ -34,6 +35,7 @@ public:
public slots:
void processAvatarMixerDatagram(const QByteArray& datagram, const QWeakPointer<Node>& mixerWeakPointer);
bool containsAvatarWithDisplayName(const QString& displayName);
AvatarData* avatarWithDisplayName(const QString& displayname);
private slots:
void sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID);

View file

@ -301,10 +301,10 @@ void DatagramSequencer::clearReliableChannel(QObject* object) {
void DatagramSequencer::sendRecordAcknowledged(const SendRecord& record) {
// stop acknowledging the recorded packets
while (!_receiveRecords.isEmpty() && _receiveRecords.first().packetNumber <= record.lastReceivedPacketNumber) {
emit receiveAcknowledged(0);
const ReceiveRecord& received = _receiveRecords.first();
_inputStream.persistReadMappings(received.mappings);
_receivedHighPriorityMessages -= received.newHighPriorityMessages;
emit receiveAcknowledged(0);
_receiveRecords.removeFirst();
}
_outputStream.persistWriteMappings(record.mappings);

View file

@ -108,6 +108,9 @@ public:
/// Returns the intput channel at the specified index, creating it if necessary.
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.
void addReliableChannelStats(int& sendProgress, int& sendTotal, int& receiveProgress, int& receiveTotal) const;

View file

@ -188,7 +188,9 @@ MetavoxelClient::MetavoxelClient(const SharedNodePointer& node, MetavoxelUpdater
Endpoint(node, new PacketRecord(), new PacketRecord()),
_updater(updater),
_reliableDeltaChannel(NULL),
_reliableDeltaID(0) {
_reliableDeltaID(0),
_dummyInputStream(_dummyDataStream),
_dummyPacketNumber(0) {
connect(_sequencer.getReliableInputChannel(RELIABLE_DELTA_CHANNEL_INDEX),
SIGNAL(receivedMessage(const QVariant&, Bitstream&)), SLOT(handleMessage(const QVariant&, Bitstream&)));
@ -234,9 +236,9 @@ PacketRecord* MetavoxelClient::getAcknowledgedReceiveRecord(int packetNumber) co
if (lastAcknowledged->getPacketNumber() == packetNumber) {
return lastAcknowledged;
}
foreach (PacketRecord* record, _clearedReceiveRecords) {
if (record->getPacketNumber() == packetNumber) {
return record;
foreach (const ClearedReceiveRecord& record, _clearedReceiveRecords) {
if (record.first->getPacketNumber() == packetNumber) {
return record.first;
}
}
return NULL;
@ -257,8 +259,8 @@ void MetavoxelClient::recordReceive() {
}
_clearedSendRecords.clear();
foreach (PacketRecord* record, _clearedReceiveRecords) {
delete record;
foreach (const ClearedReceiveRecord& record, _clearedReceiveRecords) {
delete record.first;
}
_clearedReceiveRecords.clear();
}
@ -273,10 +275,16 @@ void MetavoxelClient::clearSendRecordsBefore(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
QList<PacketRecord*>::iterator end = _receiveRecords.begin() + index + 1;
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);
}
@ -289,7 +297,6 @@ void MetavoxelClient::writeUpdateMessage(Bitstream& out) {
void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
int userType = message.userType();
if (userType == MetavoxelDeltaMessage::Type) {
PacketRecord* receiveRecord = getLastAcknowledgedReceiveRecord();
if (_reliableDeltaChannel) {
MetavoxelData reference = _remoteData;
MetavoxelLOD referenceLOD = _remoteDataLOD;
@ -299,6 +306,7 @@ void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
_reliableDeltaChannel = NULL;
} else {
PacketRecord* receiveRecord = getLastAcknowledgedReceiveRecord();
_remoteData.readDelta(receiveRecord->getData(), receiveRecord->getLOD(), in,
_remoteDataLOD = getLastAcknowledgedSendRecord()->getLOD());
in.reset();
@ -319,8 +327,6 @@ void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
MetavoxelDeltaPendingMessage pending = message.value<MetavoxelDeltaPendingMessage>();
if (pending.id > _reliableDeltaID) {
_reliableDeltaID = pending.id;
_reliableDeltaChannel = _sequencer.getReliableInputChannel(RELIABLE_DELTA_CHANNEL_INDEX);
_reliableDeltaChannel->getBitstream().copyPersistentMappings(_sequencer.getInputStream());
PacketRecord* sendRecord = getAcknowledgedSendRecord(pending.receivedPacketNumber);
if (!sendRecord) {
qWarning() << "Missing send record for delta" << pending.receivedPacketNumber;
@ -334,6 +340,20 @@ void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
}
_remoteDataLOD = receiveRecord->getLOD();
_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 {
Endpoint::handleMessage(message, in);

View file

@ -145,8 +145,13 @@ protected:
MetavoxelData _dataCopy;
QReadWriteLock _dataCopyLock;
QDataStream _dummyDataStream;
Bitstream _dummyInputStream;
int _dummyPacketNumber;
QList<PacketRecord*> _clearedSendRecords;
QList<PacketRecord*> _clearedReceiveRecords;
typedef QPair<PacketRecord*, Bitstream::ReadMappings> ClearedReceiveRecord;
QList<ClearedReceiveRecord> _clearedReceiveRecords;
};
#endif // hifi_MetavoxelClientManager_h

View file

@ -701,8 +701,7 @@ int VoxelMaterialSpannerEditVisitor::visit(MetavoxelInfo& info) {
int sizeY = (int)overlap.maximum.y - minY + 1;
int sizeZ = (int)overlap.maximum.z - minZ + 1;
QRgb rgb = _color.rgba();
bool flipped = (qAlpha(rgb) == 0);
bool flipped = false;
float step = 1.0f / scale;
glm::vec3 position(0.0f, 0.0f, info.minimum.z + minZ * step);
if (_spanner->hasOwnColors()) {
@ -720,6 +719,8 @@ int VoxelMaterialSpannerEditVisitor::visit(MetavoxelInfo& info) {
}
}
} else {
QRgb rgb = _color.rgba();
flipped = (qAlpha(rgb) == 0);
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) {
position.y = info.minimum.y + minY * step;

View file

@ -63,7 +63,15 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){
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);
}
@ -272,7 +280,7 @@ void ScriptEngine::init() {
qScriptRegisterMetaType(this, injectorToScriptValue, injectorFromScriptValue);
qScriptRegisterMetaType(this, inputControllerToScriptValue, inputControllerFromScriptValue);
qScriptRegisterMetaType(this, avatarDataToScriptValue, avatarDataFromScriptValue);
qScriptRegisterMetaType(this, animationDetailsToScriptValue, animationDetailsFromScriptValue);
registerGlobalObject("Script", this);

View 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);
}

View 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