mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 16:18:03 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into red
This commit is contained in:
commit
edbcef20d4
18 changed files with 318 additions and 299 deletions
|
@ -551,7 +551,9 @@ void AudioMixer::handleNodeAudioPacket(QSharedPointer<ReceivedMessage> message,
|
||||||
void AudioMixer::handleMuteEnvironmentPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
void AudioMixer::handleMuteEnvironmentPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
if (sendingNode->getCanAdjustLocks()) {
|
if (sendingNode->isAllowedEditor()) {
|
||||||
|
qDebug() << "Received a mute environment packet of" << message->getSize() << "bytes";
|
||||||
|
|
||||||
auto newPacket = NLPacket::create(PacketType::MuteEnvironment, message->getSize());
|
auto newPacket = NLPacket::create(PacketType::MuteEnvironment, message->getSize());
|
||||||
// Copy payload
|
// Copy payload
|
||||||
newPacket->write(message->getRawMessage(), message->getSize());
|
newPacket->write(message->getRawMessage(), message->getSize());
|
||||||
|
|
|
@ -155,7 +155,7 @@ SharedNodePointer DomainGatekeeper::processAssignmentConnectRequest(const NodeCo
|
||||||
_pendingAssignedNodes.erase(it);
|
_pendingAssignedNodes.erase(it);
|
||||||
|
|
||||||
// always allow assignment clients to create and destroy entities
|
// always allow assignment clients to create and destroy entities
|
||||||
newNode->setCanAdjustLocks(true);
|
newNode->setIsAllowedEditor(true);
|
||||||
newNode->setCanRez(true);
|
newNode->setCanRez(true);
|
||||||
|
|
||||||
return newNode;
|
return newNode;
|
||||||
|
@ -219,13 +219,13 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if this user is in the editors list (or if the editors list is empty) set the user's node's canAdjustLocks to true
|
// if this user is in the editors list (or if the editors list is empty) set the user's node's isAllowedEditor to true
|
||||||
const QVariant* allowedEditorsVariant =
|
const QVariant* allowedEditorsVariant =
|
||||||
valueForKeyPath(_server->_settingsManager.getSettingsMap(), ALLOWED_EDITORS_SETTINGS_KEYPATH);
|
valueForKeyPath(_server->_settingsManager.getSettingsMap(), ALLOWED_EDITORS_SETTINGS_KEYPATH);
|
||||||
QStringList allowedEditors = allowedEditorsVariant ? allowedEditorsVariant->toStringList() : QStringList();
|
QStringList allowedEditors = allowedEditorsVariant ? allowedEditorsVariant->toStringList() : QStringList();
|
||||||
|
|
||||||
// if the allowed editors list is empty then everyone can adjust locks
|
// if the allowed editors list is empty then everyone can adjust locks
|
||||||
bool canAdjustLocks = allowedEditors.empty();
|
bool isAllowedEditor = allowedEditors.empty();
|
||||||
|
|
||||||
if (allowedEditors.contains(username, Qt::CaseInsensitive)) {
|
if (allowedEditors.contains(username, Qt::CaseInsensitive)) {
|
||||||
// we have a non-empty allowed editors list - check if this user is verified to be in it
|
// we have a non-empty allowed editors list - check if this user is verified to be in it
|
||||||
|
@ -238,10 +238,10 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
|
||||||
<< "will be given edit rights to avoid a thrasing of public key requests and connect requests.";
|
<< "will be given edit rights to avoid a thrasing of public key requests and connect requests.";
|
||||||
}
|
}
|
||||||
|
|
||||||
canAdjustLocks = true;
|
isAllowedEditor = true;
|
||||||
} else {
|
} else {
|
||||||
// already verified this user and they are in the allowed editors list
|
// already verified this user and they are in the allowed editors list
|
||||||
canAdjustLocks = true;
|
isAllowedEditor = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,14 +256,14 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
|
||||||
|
|
||||||
bool canRez = true;
|
bool canRez = true;
|
||||||
if (onlyEditorsAreRezzers) {
|
if (onlyEditorsAreRezzers) {
|
||||||
canRez = canAdjustLocks;
|
canRez = isAllowedEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the new node
|
// add the new node
|
||||||
SharedNodePointer newNode = addVerifiedNodeFromConnectRequest(nodeConnection);
|
SharedNodePointer newNode = addVerifiedNodeFromConnectRequest(nodeConnection);
|
||||||
|
|
||||||
// set the edit rights for this user
|
// set the edit rights for this user
|
||||||
newNode->setCanAdjustLocks(canAdjustLocks);
|
newNode->setIsAllowedEditor(isAllowedEditor);
|
||||||
newNode->setCanRez(canRez);
|
newNode->setCanRez(canRez);
|
||||||
|
|
||||||
// grab the linked data for our new node so we can set the username
|
// grab the linked data for our new node so we can set the username
|
||||||
|
|
|
@ -744,7 +744,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
||||||
|
|
||||||
extendedHeaderStream << limitedNodeList->getSessionUUID();
|
extendedHeaderStream << limitedNodeList->getSessionUUID();
|
||||||
extendedHeaderStream << node->getUUID();
|
extendedHeaderStream << node->getUUID();
|
||||||
extendedHeaderStream << (quint8) node->getCanAdjustLocks();
|
extendedHeaderStream << (quint8) node->isAllowedEditor();
|
||||||
extendedHeaderStream << (quint8) node->getCanRez();
|
extendedHeaderStream << (quint8) node->getCanRez();
|
||||||
|
|
||||||
auto domainListPackets = NLPacketList::create(PacketType::DomainList, extendedHeader);
|
auto domainListPackets = NLPacketList::create(PacketType::DomainList, extendedHeader);
|
||||||
|
|
|
@ -39,10 +39,10 @@ var lightOverlayManager = new LightOverlayManager();
|
||||||
var cameraManager = new CameraManager();
|
var cameraManager = new CameraManager();
|
||||||
|
|
||||||
var grid = Grid();
|
var grid = Grid();
|
||||||
gridTool = GridTool({
|
// gridTool = GridTool({
|
||||||
horizontalGrid: grid
|
// horizontalGrid: grid
|
||||||
});
|
// });
|
||||||
gridTool.setVisible(false);
|
// gridTool.setVisible(false);
|
||||||
|
|
||||||
var entityListTool = EntityListTool();
|
var entityListTool = EntityListTool();
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ var toolBar = (function() {
|
||||||
isActive = active;
|
isActive = active;
|
||||||
if (!isActive) {
|
if (!isActive) {
|
||||||
entityListTool.setVisible(false);
|
entityListTool.setVisible(false);
|
||||||
gridTool.setVisible(false);
|
// gridTool.setVisible(false);
|
||||||
grid.setEnabled(false);
|
grid.setEnabled(false);
|
||||||
propertiesTool.setVisible(false);
|
propertiesTool.setVisible(false);
|
||||||
selectionManager.clearSelections();
|
selectionManager.clearSelections();
|
||||||
|
@ -344,7 +344,7 @@ var toolBar = (function() {
|
||||||
} else {
|
} else {
|
||||||
hasShownPropertiesTool = false;
|
hasShownPropertiesTool = false;
|
||||||
entityListTool.setVisible(true);
|
entityListTool.setVisible(true);
|
||||||
gridTool.setVisible(true);
|
// gridTool.setVisible(true);
|
||||||
grid.setEnabled(true);
|
grid.setEnabled(true);
|
||||||
propertiesTool.setVisible(true);
|
propertiesTool.setVisible(true);
|
||||||
Window.setFocus();
|
Window.setFocus();
|
||||||
|
|
|
@ -1362,6 +1362,9 @@ void Application::paintGL() {
|
||||||
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE;
|
||||||
renderArgs._blitFramebuffer = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer();
|
renderArgs._blitFramebuffer = DependencyManager::get<FramebufferCache>()->getSelfieFramebuffer();
|
||||||
|
|
||||||
|
auto inputs = AvatarInputs::getInstance();
|
||||||
|
_mirrorViewRect.moveTo(inputs->x(), inputs->y());
|
||||||
|
|
||||||
renderRearViewMirror(&renderArgs, _mirrorViewRect);
|
renderRearViewMirror(&renderArgs, _mirrorViewRect);
|
||||||
|
|
||||||
renderArgs._blitFramebuffer.reset();
|
renderArgs._blitFramebuffer.reset();
|
||||||
|
|
|
@ -29,7 +29,7 @@ EntityScriptingInterface::EntityScriptingInterface() :
|
||||||
_entityTree(NULL)
|
_entityTree(NULL)
|
||||||
{
|
{
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
connect(nodeList.data(), &NodeList::canAdjustLocksChanged, this, &EntityScriptingInterface::canAdjustLocksChanged);
|
connect(nodeList.data(), &NodeList::isAllowedEditorChanged, this, &EntityScriptingInterface::canAdjustLocksChanged);
|
||||||
connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptingInterface::canRezChanged);
|
connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptingInterface::canRezChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ void EntityScriptingInterface::queueEntityMessage(PacketType packetType,
|
||||||
|
|
||||||
bool EntityScriptingInterface::canAdjustLocks() {
|
bool EntityScriptingInterface::canAdjustLocks() {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
return nodeList->getThisNodeCanAdjustLocks();
|
return nodeList->isAllowedEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityScriptingInterface::canRez() {
|
bool EntityScriptingInterface::canRez() {
|
||||||
|
|
|
@ -124,10 +124,10 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
|
||||||
QUuid senderID;
|
QUuid senderID;
|
||||||
if (senderNode.isNull()) {
|
if (senderNode.isNull()) {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
allowLockChange = nodeList->getThisNodeCanAdjustLocks();
|
allowLockChange = nodeList->isAllowedEditor();
|
||||||
senderID = nodeList->getSessionUUID();
|
senderID = nodeList->getSessionUUID();
|
||||||
} else {
|
} else {
|
||||||
allowLockChange = senderNode->getCanAdjustLocks();
|
allowLockChange = senderNode->isAllowedEditor();
|
||||||
senderID = senderNode->getUUID();
|
senderID = senderNode->getUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short
|
||||||
_numCollectedPackets(0),
|
_numCollectedPackets(0),
|
||||||
_numCollectedBytes(0),
|
_numCollectedBytes(0),
|
||||||
_packetStatTimer(),
|
_packetStatTimer(),
|
||||||
_thisNodeCanAdjustLocks(false),
|
|
||||||
_thisNodeCanRez(true)
|
_thisNodeCanRez(true)
|
||||||
{
|
{
|
||||||
static bool firstCall = true;
|
static bool firstCall = true;
|
||||||
|
@ -131,10 +130,10 @@ void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitedNodeList::setThisNodeCanAdjustLocks(bool canAdjustLocks) {
|
void LimitedNodeList::setIsAllowedEditor(bool isAllowedEditor) {
|
||||||
if (_thisNodeCanAdjustLocks != canAdjustLocks) {
|
if (_isAllowedEditor != isAllowedEditor) {
|
||||||
_thisNodeCanAdjustLocks = canAdjustLocks;
|
_isAllowedEditor = isAllowedEditor;
|
||||||
emit canAdjustLocksChanged(canAdjustLocks);
|
emit isAllowedEditorChanged(isAllowedEditor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,7 +514,7 @@ void LimitedNodeList::handleNodeKill(const SharedNodePointer& node) {
|
||||||
|
|
||||||
SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
||||||
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
||||||
bool canAdjustLocks, bool canRez,
|
bool isAllowedEditor, bool canRez,
|
||||||
const QUuid& connectionSecret) {
|
const QUuid& connectionSecret) {
|
||||||
NodeHash::const_iterator it = _nodeHash.find(uuid);
|
NodeHash::const_iterator it = _nodeHash.find(uuid);
|
||||||
|
|
||||||
|
@ -524,14 +523,14 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
||||||
|
|
||||||
matchingNode->setPublicSocket(publicSocket);
|
matchingNode->setPublicSocket(publicSocket);
|
||||||
matchingNode->setLocalSocket(localSocket);
|
matchingNode->setLocalSocket(localSocket);
|
||||||
matchingNode->setCanAdjustLocks(canAdjustLocks);
|
matchingNode->setIsAllowedEditor(isAllowedEditor);
|
||||||
matchingNode->setCanRez(canRez);
|
matchingNode->setCanRez(canRez);
|
||||||
matchingNode->setConnectionSecret(connectionSecret);
|
matchingNode->setConnectionSecret(connectionSecret);
|
||||||
|
|
||||||
return matchingNode;
|
return matchingNode;
|
||||||
} else {
|
} else {
|
||||||
// we didn't have this node, so add them
|
// we didn't have this node, so add them
|
||||||
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket, canAdjustLocks, canRez, connectionSecret, this);
|
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket, isAllowedEditor, canRez, connectionSecret, this);
|
||||||
|
|
||||||
if (nodeType == NodeType::AudioMixer) {
|
if (nodeType == NodeType::AudioMixer) {
|
||||||
LimitedNodeList::flagTimeForConnectionStep(LimitedNodeList::AddedAudioMixer);
|
LimitedNodeList::flagTimeForConnectionStep(LimitedNodeList::AddedAudioMixer);
|
||||||
|
|
|
@ -104,8 +104,8 @@ public:
|
||||||
const QUuid& getSessionUUID() const { return _sessionUUID; }
|
const QUuid& getSessionUUID() const { return _sessionUUID; }
|
||||||
void setSessionUUID(const QUuid& sessionUUID);
|
void setSessionUUID(const QUuid& sessionUUID);
|
||||||
|
|
||||||
bool getThisNodeCanAdjustLocks() const { return _thisNodeCanAdjustLocks; }
|
bool isAllowedEditor() const { return _isAllowedEditor; }
|
||||||
void setThisNodeCanAdjustLocks(bool canAdjustLocks);
|
void setIsAllowedEditor(bool isAllowedEditor);
|
||||||
|
|
||||||
bool getThisNodeCanRez() const { return _thisNodeCanRez; }
|
bool getThisNodeCanRez() const { return _thisNodeCanRez; }
|
||||||
void setThisNodeCanRez(bool canRez);
|
void setThisNodeCanRez(bool canRez);
|
||||||
|
@ -137,7 +137,7 @@ public:
|
||||||
|
|
||||||
SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
||||||
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
||||||
bool canAdjustLocks = false, bool canRez = false,
|
bool isAllowedEditor = false, bool canRez = false,
|
||||||
const QUuid& connectionSecret = QUuid());
|
const QUuid& connectionSecret = QUuid());
|
||||||
|
|
||||||
bool hasCompletedInitialSTUN() const { return _hasCompletedInitialSTUN; }
|
bool hasCompletedInitialSTUN() const { return _hasCompletedInitialSTUN; }
|
||||||
|
@ -244,7 +244,7 @@ signals:
|
||||||
void localSockAddrChanged(const HifiSockAddr& localSockAddr);
|
void localSockAddrChanged(const HifiSockAddr& localSockAddr);
|
||||||
void publicSockAddrChanged(const HifiSockAddr& publicSockAddr);
|
void publicSockAddrChanged(const HifiSockAddr& publicSockAddr);
|
||||||
|
|
||||||
void canAdjustLocksChanged(bool canAdjustLocks);
|
void isAllowedEditorChanged(bool isAllowedEditor);
|
||||||
void canRezChanged(bool canRez);
|
void canRezChanged(bool canRez);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -289,7 +289,7 @@ protected:
|
||||||
int _numCollectedBytes;
|
int _numCollectedBytes;
|
||||||
|
|
||||||
QElapsedTimer _packetStatTimer;
|
QElapsedTimer _packetStatTimer;
|
||||||
bool _thisNodeCanAdjustLocks;
|
bool _isAllowedEditor { false };
|
||||||
bool _thisNodeCanRez;
|
bool _thisNodeCanRez;
|
||||||
|
|
||||||
QPointer<QTimer> _initialSTUNTimer;
|
QPointer<QTimer> _initialSTUNTimer;
|
||||||
|
|
|
@ -47,7 +47,7 @@ const QString& NodeType::getNodeTypeName(NodeType_t nodeType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket,
|
Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket,
|
||||||
const HifiSockAddr& localSocket, bool canAdjustLocks, bool canRez, const QUuid& connectionSecret,
|
const HifiSockAddr& localSocket, bool isAllowedEditor, bool canRez, const QUuid& connectionSecret,
|
||||||
QObject* parent) :
|
QObject* parent) :
|
||||||
NetworkPeer(uuid, publicSocket, localSocket, parent),
|
NetworkPeer(uuid, publicSocket, localSocket, parent),
|
||||||
_type(type),
|
_type(type),
|
||||||
|
@ -57,7 +57,7 @@ Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket,
|
||||||
_clockSkewUsec(0),
|
_clockSkewUsec(0),
|
||||||
_mutex(),
|
_mutex(),
|
||||||
_clockSkewMovingPercentile(30, 0.8f), // moving 80th percentile of 30 samples
|
_clockSkewMovingPercentile(30, 0.8f), // moving 80th percentile of 30 samples
|
||||||
_canAdjustLocks(canAdjustLocks),
|
_isAllowedEditor(isAllowedEditor),
|
||||||
_canRez(canRez)
|
_canRez(canRez)
|
||||||
{
|
{
|
||||||
// Update socket's object name
|
// Update socket's object name
|
||||||
|
@ -84,7 +84,7 @@ QDataStream& operator<<(QDataStream& out, const Node& node) {
|
||||||
out << node._uuid;
|
out << node._uuid;
|
||||||
out << node._publicSocket;
|
out << node._publicSocket;
|
||||||
out << node._localSocket;
|
out << node._localSocket;
|
||||||
out << node._canAdjustLocks;
|
out << node._isAllowedEditor;
|
||||||
out << node._canRez;
|
out << node._canRez;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
@ -95,7 +95,7 @@ QDataStream& operator>>(QDataStream& in, Node& node) {
|
||||||
in >> node._uuid;
|
in >> node._uuid;
|
||||||
in >> node._publicSocket;
|
in >> node._publicSocket;
|
||||||
in >> node._localSocket;
|
in >> node._localSocket;
|
||||||
in >> node._canAdjustLocks;
|
in >> node._isAllowedEditor;
|
||||||
in >> node._canRez;
|
in >> node._canRez;
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Node : public NetworkPeer {
|
||||||
public:
|
public:
|
||||||
Node(const QUuid& uuid, NodeType_t type,
|
Node(const QUuid& uuid, NodeType_t type,
|
||||||
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
||||||
bool canAdjustLocks, bool canRez, const QUuid& connectionSecret = QUuid(),
|
bool isAllowedEditor, bool canRez, const QUuid& connectionSecret = QUuid(),
|
||||||
QObject* parent = 0);
|
QObject* parent = 0);
|
||||||
|
|
||||||
bool operator==(const Node& otherNode) const { return _uuid == otherNode._uuid; }
|
bool operator==(const Node& otherNode) const { return _uuid == otherNode._uuid; }
|
||||||
|
@ -58,8 +58,8 @@ public:
|
||||||
void updateClockSkewUsec(int clockSkewSample);
|
void updateClockSkewUsec(int clockSkewSample);
|
||||||
QMutex& getMutex() { return _mutex; }
|
QMutex& getMutex() { return _mutex; }
|
||||||
|
|
||||||
void setCanAdjustLocks(bool canAdjustLocks) { _canAdjustLocks = canAdjustLocks; }
|
void setIsAllowedEditor(bool isAllowedEditor) { _isAllowedEditor = isAllowedEditor; }
|
||||||
bool getCanAdjustLocks() { return _canAdjustLocks; }
|
bool isAllowedEditor() { return _isAllowedEditor; }
|
||||||
|
|
||||||
void setCanRez(bool canRez) { _canRez = canRez; }
|
void setCanRez(bool canRez) { _canRez = canRez; }
|
||||||
bool getCanRez() { return _canRez; }
|
bool getCanRez() { return _canRez; }
|
||||||
|
@ -81,7 +81,7 @@ private:
|
||||||
int _clockSkewUsec;
|
int _clockSkewUsec;
|
||||||
QMutex _mutex;
|
QMutex _mutex;
|
||||||
MovingPercentile _clockSkewMovingPercentile;
|
MovingPercentile _clockSkewMovingPercentile;
|
||||||
bool _canAdjustLocks;
|
bool _isAllowedEditor;
|
||||||
bool _canRez;
|
bool _canRez;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -512,9 +512,9 @@ void NodeList::processDomainServerList(QSharedPointer<ReceivedMessage> message)
|
||||||
packetStream >> newUUID;
|
packetStream >> newUUID;
|
||||||
setSessionUUID(newUUID);
|
setSessionUUID(newUUID);
|
||||||
|
|
||||||
quint8 thisNodeCanAdjustLocks;
|
quint8 isAllowedEditor;
|
||||||
packetStream >> thisNodeCanAdjustLocks;
|
packetStream >> isAllowedEditor;
|
||||||
setThisNodeCanAdjustLocks((bool) thisNodeCanAdjustLocks);
|
setIsAllowedEditor((bool) isAllowedEditor);
|
||||||
|
|
||||||
quint8 thisNodeCanRez;
|
quint8 thisNodeCanRez;
|
||||||
packetStream >> thisNodeCanRez;
|
packetStream >> thisNodeCanRez;
|
||||||
|
@ -546,10 +546,10 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
|
||||||
qint8 nodeType;
|
qint8 nodeType;
|
||||||
QUuid nodeUUID, connectionUUID;
|
QUuid nodeUUID, connectionUUID;
|
||||||
HifiSockAddr nodePublicSocket, nodeLocalSocket;
|
HifiSockAddr nodePublicSocket, nodeLocalSocket;
|
||||||
bool canAdjustLocks;
|
bool isAllowedEditor;
|
||||||
bool canRez;
|
bool canRez;
|
||||||
|
|
||||||
packetStream >> nodeType >> nodeUUID >> nodePublicSocket >> nodeLocalSocket >> canAdjustLocks >> canRez;
|
packetStream >> nodeType >> nodeUUID >> nodePublicSocket >> nodeLocalSocket >> isAllowedEditor >> canRez;
|
||||||
|
|
||||||
// if the public socket address is 0 then it's reachable at the same IP
|
// if the public socket address is 0 then it's reachable at the same IP
|
||||||
// as the domain server
|
// as the domain server
|
||||||
|
@ -560,7 +560,7 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
|
||||||
packetStream >> connectionUUID;
|
packetStream >> connectionUUID;
|
||||||
|
|
||||||
SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket,
|
SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket,
|
||||||
nodeLocalSocket, canAdjustLocks, canRez,
|
nodeLocalSocket, isAllowedEditor, canRez,
|
||||||
connectionUUID);
|
connectionUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// render-utils/src/
|
// render-utils/src/
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 5/29/15.
|
// Created by Sam Gateau on 5/29/15.
|
||||||
// Copyright 20154 High Fidelity, Inc.
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -15,7 +15,6 @@
|
||||||
#include <RenderArgs.h>
|
#include <RenderArgs.h>
|
||||||
#include <ViewFrustum.h>
|
#include <ViewFrustum.h>
|
||||||
#include <gpu/Context.h>
|
#include <gpu/Context.h>
|
||||||
#include <gpu/StandardShaderLib.h>
|
|
||||||
|
|
||||||
#include "DebugDeferredBuffer.h"
|
#include "DebugDeferredBuffer.h"
|
||||||
#include "DeferredLightingEffect.h"
|
#include "DeferredLightingEffect.h"
|
||||||
|
@ -32,34 +31,11 @@
|
||||||
|
|
||||||
#include "RenderDeferredTask.h"
|
#include "RenderDeferredTask.h"
|
||||||
|
|
||||||
#include "model_vert.h"
|
|
||||||
#include "model_shadow_vert.h"
|
|
||||||
#include "model_normal_map_vert.h"
|
|
||||||
#include "model_lightmap_vert.h"
|
|
||||||
#include "model_lightmap_normal_map_vert.h"
|
|
||||||
#include "skin_model_vert.h"
|
|
||||||
#include "skin_model_shadow_vert.h"
|
|
||||||
#include "skin_model_normal_map_vert.h"
|
|
||||||
|
|
||||||
#include "model_frag.h"
|
|
||||||
#include "model_shadow_frag.h"
|
|
||||||
#include "model_normal_map_frag.h"
|
|
||||||
#include "model_normal_specular_map_frag.h"
|
|
||||||
#include "model_specular_map_frag.h"
|
|
||||||
#include "model_lightmap_frag.h"
|
|
||||||
#include "model_lightmap_normal_map_frag.h"
|
|
||||||
#include "model_lightmap_normal_specular_map_frag.h"
|
|
||||||
#include "model_lightmap_specular_map_frag.h"
|
|
||||||
#include "model_translucent_frag.h"
|
|
||||||
|
|
||||||
#include "overlay3D_vert.h"
|
|
||||||
#include "overlay3D_frag.h"
|
|
||||||
|
|
||||||
#include "drawOpaqueStencil_frag.h"
|
|
||||||
|
|
||||||
using namespace render;
|
using namespace render;
|
||||||
|
|
||||||
void initDeferredPipelines(render::ShapePlumber& plumber);
|
extern void initStencilPipeline(gpu::PipelinePointer& pipeline);
|
||||||
|
extern void initOverlay3DPipelines(render::ShapePlumber& plumber);
|
||||||
|
extern void initDeferredPipelines(render::ShapePlumber& plumber);
|
||||||
|
|
||||||
void PrepareDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
void PrepareDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
||||||
DependencyManager::get<DeferredLightingEffect>()->prepare(renderContext->args);
|
DependencyManager::get<DeferredLightingEffect>()->prepare(renderContext->args);
|
||||||
|
@ -136,7 +112,7 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
||||||
addJob<DrawStatus>("DrawStatus", opaques, DrawStatus(statusIconMap));
|
addJob<DrawStatus>("DrawStatus", opaques, DrawStatus(statusIconMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
addJob<DrawOverlay3D>("DrawOverlay3D", shapePlumber);
|
addJob<DrawOverlay3D>("DrawOverlay3D");
|
||||||
|
|
||||||
addJob<HitEffect>("HitEffect");
|
addJob<HitEffect>("HitEffect");
|
||||||
|
|
||||||
|
@ -189,22 +165,8 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this to the shapePlumber
|
DrawOverlay3D::DrawOverlay3D() : _shapePlumber{ std::make_shared<ShapePlumber>() } {
|
||||||
gpu::PipelinePointer DrawOverlay3D::_opaquePipeline;
|
initOverlay3DPipelines(*_shapePlumber);
|
||||||
const gpu::PipelinePointer& DrawOverlay3D::getOpaquePipeline() {
|
|
||||||
if (!_opaquePipeline) {
|
|
||||||
auto vs = gpu::Shader::createVertex(std::string(overlay3D_vert));
|
|
||||||
auto ps = gpu::Shader::createPixel(std::string(overlay3D_frag));
|
|
||||||
auto program = gpu::Shader::createProgram(vs, ps);
|
|
||||||
|
|
||||||
auto state = std::make_shared<gpu::State>();
|
|
||||||
state->setDepthTest(false);
|
|
||||||
// additive blending
|
|
||||||
state->setBlendFunction(true, gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
|
||||||
|
|
||||||
_opaquePipeline = gpu::Pipeline::create(program, state);
|
|
||||||
}
|
|
||||||
return _opaquePipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
||||||
|
@ -255,9 +217,8 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon
|
||||||
batch.setViewTransform(viewMat);
|
batch.setViewTransform(viewMat);
|
||||||
batch.setViewportTransform(args->_viewport);
|
batch.setViewportTransform(args->_viewport);
|
||||||
batch.setStateScissorRect(args->_viewport);
|
batch.setStateScissorRect(args->_viewport);
|
||||||
|
|
||||||
batch.setPipeline(getOpaquePipeline());
|
|
||||||
batch.setResourceTexture(0, args->_whiteTexture);
|
batch.setResourceTexture(0, args->_whiteTexture);
|
||||||
|
|
||||||
renderShapes(sceneContext, renderContext, _shapePlumber, inItems, _maxDrawn);
|
renderShapes(sceneContext, renderContext, _shapePlumber, inItems, _maxDrawn);
|
||||||
});
|
});
|
||||||
args->_batch = nullptr;
|
args->_batch = nullptr;
|
||||||
|
@ -268,20 +229,7 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon
|
||||||
gpu::PipelinePointer DrawStencilDeferred::_opaquePipeline;
|
gpu::PipelinePointer DrawStencilDeferred::_opaquePipeline;
|
||||||
const gpu::PipelinePointer& DrawStencilDeferred::getOpaquePipeline() {
|
const gpu::PipelinePointer& DrawStencilDeferred::getOpaquePipeline() {
|
||||||
if (!_opaquePipeline) {
|
if (!_opaquePipeline) {
|
||||||
const gpu::int8 STENCIL_OPAQUE = 1;
|
initStencilPipeline(_opaquePipeline);
|
||||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
|
||||||
auto ps = gpu::Shader::createPixel(std::string(drawOpaqueStencil_frag));
|
|
||||||
auto program = gpu::Shader::createProgram(vs, ps);
|
|
||||||
|
|
||||||
|
|
||||||
gpu::Shader::makeProgram((*program));
|
|
||||||
|
|
||||||
auto state = std::make_shared<gpu::State>();
|
|
||||||
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
|
||||||
state->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_OPAQUE, 0xFF, gpu::ALWAYS, gpu::State::STENCIL_OP_REPLACE, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_REPLACE));
|
|
||||||
state->setColorWriteMask(0);
|
|
||||||
|
|
||||||
_opaquePipeline = gpu::Pipeline::create(program, state);
|
|
||||||
}
|
}
|
||||||
return _opaquePipeline;
|
return _opaquePipeline;
|
||||||
}
|
}
|
||||||
|
@ -422,166 +370,3 @@ void Blit::run(const SceneContextPointer& sceneContext, const RenderContextPoint
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void pipelineBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) {
|
|
||||||
if (pipeline.locations->normalFittingMapUnit > -1) {
|
|
||||||
batch.setResourceTexture(pipeline.locations->normalFittingMapUnit,
|
|
||||||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void initDeferredPipelines(render::ShapePlumber& plumber) {
|
|
||||||
using Key = render::ShapeKey;
|
|
||||||
using ShaderPointer = gpu::ShaderPointer;
|
|
||||||
|
|
||||||
auto addPipeline = [&plumber](const Key& key, const ShaderPointer& vertexShader, const ShaderPointer& pixelShader) {
|
|
||||||
auto state = std::make_shared<gpu::State>();
|
|
||||||
|
|
||||||
// Cull backface
|
|
||||||
state->setCullMode(gpu::State::CULL_BACK);
|
|
||||||
|
|
||||||
// Z test depends on transparency
|
|
||||||
state->setDepthTest(true, !key.isTranslucent(), gpu::LESS_EQUAL);
|
|
||||||
|
|
||||||
// Blend if transparent
|
|
||||||
state->setBlendFunction(key.isTranslucent(),
|
|
||||||
// For transparency, keep the highlight intensity
|
|
||||||
gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
|
||||||
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
|
||||||
|
|
||||||
ShaderPointer program = gpu::Shader::createProgram(vertexShader, pixelShader);
|
|
||||||
plumber.addPipeline(key, program, state, &pipelineBatchSetter);
|
|
||||||
|
|
||||||
// Add a wireframe version
|
|
||||||
if (!key.isWireFrame()) {
|
|
||||||
auto wireFrameKey = Key::Builder(key).withWireframe();
|
|
||||||
auto wireFrameState = std::make_shared<gpu::State>(state->getValues());
|
|
||||||
|
|
||||||
wireFrameState->setFillMode(gpu::State::FILL_LINE);
|
|
||||||
|
|
||||||
plumber.addPipeline(wireFrameKey, program, wireFrameState, &pipelineBatchSetter);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Vertex shaders
|
|
||||||
auto modelVertex = gpu::Shader::createVertex(std::string(model_vert));
|
|
||||||
auto modelNormalMapVertex = gpu::Shader::createVertex(std::string(model_normal_map_vert));
|
|
||||||
auto modelLightmapVertex = gpu::Shader::createVertex(std::string(model_lightmap_vert));
|
|
||||||
auto modelLightmapNormalMapVertex = gpu::Shader::createVertex(std::string(model_lightmap_normal_map_vert));
|
|
||||||
auto modelShadowVertex = gpu::Shader::createVertex(std::string(model_shadow_vert));
|
|
||||||
auto skinModelVertex = gpu::Shader::createVertex(std::string(skin_model_vert));
|
|
||||||
auto skinModelNormalMapVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_vert));
|
|
||||||
auto skinModelShadowVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert));
|
|
||||||
|
|
||||||
// Pixel shaders
|
|
||||||
auto modelPixel = gpu::Shader::createPixel(std::string(model_frag));
|
|
||||||
auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(model_normal_map_frag));
|
|
||||||
auto modelSpecularMapPixel = gpu::Shader::createPixel(std::string(model_specular_map_frag));
|
|
||||||
auto modelNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_normal_specular_map_frag));
|
|
||||||
auto modelTranslucentPixel = gpu::Shader::createPixel(std::string(model_translucent_frag));
|
|
||||||
auto modelShadowPixel = gpu::Shader::createPixel(std::string(model_shadow_frag));
|
|
||||||
auto modelLightmapPixel = gpu::Shader::createPixel(std::string(model_lightmap_frag));
|
|
||||||
auto modelLightmapNormalMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_map_frag));
|
|
||||||
auto modelLightmapSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_specular_map_frag));
|
|
||||||
auto modelLightmapNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_frag));
|
|
||||||
|
|
||||||
// Fill the pipelineLib
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder(),
|
|
||||||
modelVertex, modelPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withTangents(),
|
|
||||||
modelNormalMapVertex, modelNormalMapPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSpecular(),
|
|
||||||
modelVertex, modelSpecularMapPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withTangents().withSpecular(),
|
|
||||||
modelNormalMapVertex, modelNormalSpecularMapPixel);
|
|
||||||
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withTranslucent(),
|
|
||||||
modelVertex, modelTranslucentPixel);
|
|
||||||
// FIXME Ignore lightmap for translucents meshpart
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withTranslucent().withLightmap(),
|
|
||||||
modelVertex, modelTranslucentPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withTangents().withTranslucent(),
|
|
||||||
modelNormalMapVertex, modelTranslucentPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSpecular().withTranslucent(),
|
|
||||||
modelVertex, modelTranslucentPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withTangents().withSpecular().withTranslucent(),
|
|
||||||
modelNormalMapVertex, modelTranslucentPixel);
|
|
||||||
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withLightmap(),
|
|
||||||
modelLightmapVertex, modelLightmapPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withLightmap().withTangents(),
|
|
||||||
modelLightmapNormalMapVertex, modelLightmapNormalMapPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withLightmap().withSpecular(),
|
|
||||||
modelLightmapVertex, modelLightmapSpecularMapPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withLightmap().withTangents().withSpecular(),
|
|
||||||
modelLightmapNormalMapVertex, modelLightmapNormalSpecularMapPixel);
|
|
||||||
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSkinned(),
|
|
||||||
skinModelVertex, modelPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSkinned().withTangents(),
|
|
||||||
skinModelNormalMapVertex, modelNormalMapPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSkinned().withSpecular(),
|
|
||||||
skinModelVertex, modelSpecularMapPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSkinned().withTangents().withSpecular(),
|
|
||||||
skinModelNormalMapVertex, modelNormalSpecularMapPixel);
|
|
||||||
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSkinned().withTranslucent(),
|
|
||||||
skinModelVertex, modelTranslucentPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSkinned().withTangents().withTranslucent(),
|
|
||||||
skinModelNormalMapVertex, modelTranslucentPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSkinned().withSpecular().withTranslucent(),
|
|
||||||
skinModelVertex, modelTranslucentPixel);
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSkinned().withTangents().withSpecular().withTranslucent(),
|
|
||||||
skinModelNormalMapVertex, modelTranslucentPixel);
|
|
||||||
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withDepthOnly(),
|
|
||||||
modelShadowVertex, modelShadowPixel);
|
|
||||||
|
|
||||||
|
|
||||||
addPipeline(
|
|
||||||
Key::Builder().withSkinned().withDepthOnly(),
|
|
||||||
skinModelShadowVertex, modelShadowPixel);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -69,11 +69,10 @@ protected:
|
||||||
|
|
||||||
class DrawStencilDeferred {
|
class DrawStencilDeferred {
|
||||||
public:
|
public:
|
||||||
static const gpu::PipelinePointer& getOpaquePipeline();
|
using JobModel = render::Job::Model<DrawStencilDeferred>;
|
||||||
|
|
||||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||||
|
static const gpu::PipelinePointer& getOpaquePipeline();
|
||||||
using JobModel = render::Job::Model<DrawStencilDeferred>;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable
|
static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable
|
||||||
|
@ -107,15 +106,12 @@ public:
|
||||||
using Config = DrawOverlay3DConfig;
|
using Config = DrawOverlay3DConfig;
|
||||||
using JobModel = render::Job::Model<DrawOverlay3D, Config>;
|
using JobModel = render::Job::Model<DrawOverlay3D, Config>;
|
||||||
|
|
||||||
DrawOverlay3D(render::ShapePlumberPointer shapePlumber) : _shapePlumber{ shapePlumber } {}
|
DrawOverlay3D();
|
||||||
|
|
||||||
void configure(const Config& config) { _maxDrawn = config.maxDrawn; }
|
void configure(const Config& config) { _maxDrawn = config.maxDrawn; }
|
||||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||||
|
|
||||||
static const gpu::PipelinePointer& getOpaquePipeline();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable
|
|
||||||
render::ShapePlumberPointer _shapePlumber;
|
render::ShapePlumberPointer _shapePlumber;
|
||||||
int _maxDrawn; // initialized by Config
|
int _maxDrawn; // initialized by Config
|
||||||
};
|
};
|
||||||
|
|
234
libraries/render-utils/src/RenderPipelines.cpp
Normal file
234
libraries/render-utils/src/RenderPipelines.cpp
Normal file
|
@ -0,0 +1,234 @@
|
||||||
|
|
||||||
|
//
|
||||||
|
// RenderPipelines.cpp
|
||||||
|
// render-utils/src/
|
||||||
|
//
|
||||||
|
// Created by Zach Pomerantz on 1/28/2016.
|
||||||
|
// Copyright 2016 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 <gpu/Context.h>
|
||||||
|
#include <gpu/StandardShaderLib.h>
|
||||||
|
|
||||||
|
#include "TextureCache.h"
|
||||||
|
#include "render/DrawTask.h"
|
||||||
|
|
||||||
|
#include "model_vert.h"
|
||||||
|
#include "model_shadow_vert.h"
|
||||||
|
#include "model_normal_map_vert.h"
|
||||||
|
#include "model_lightmap_vert.h"
|
||||||
|
#include "model_lightmap_normal_map_vert.h"
|
||||||
|
#include "skin_model_vert.h"
|
||||||
|
#include "skin_model_shadow_vert.h"
|
||||||
|
#include "skin_model_normal_map_vert.h"
|
||||||
|
|
||||||
|
#include "model_frag.h"
|
||||||
|
#include "model_shadow_frag.h"
|
||||||
|
#include "model_normal_map_frag.h"
|
||||||
|
#include "model_normal_specular_map_frag.h"
|
||||||
|
#include "model_specular_map_frag.h"
|
||||||
|
#include "model_lightmap_frag.h"
|
||||||
|
#include "model_lightmap_normal_map_frag.h"
|
||||||
|
#include "model_lightmap_normal_specular_map_frag.h"
|
||||||
|
#include "model_lightmap_specular_map_frag.h"
|
||||||
|
#include "model_translucent_frag.h"
|
||||||
|
|
||||||
|
#include "overlay3D_vert.h"
|
||||||
|
#include "overlay3D_frag.h"
|
||||||
|
|
||||||
|
#include "drawOpaqueStencil_frag.h"
|
||||||
|
|
||||||
|
using namespace render;
|
||||||
|
|
||||||
|
void initStencilPipeline(gpu::PipelinePointer& pipeline) {
|
||||||
|
const gpu::int8 STENCIL_OPAQUE = 1;
|
||||||
|
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||||
|
auto ps = gpu::Shader::createPixel(std::string(drawOpaqueStencil_frag));
|
||||||
|
auto program = gpu::Shader::createProgram(vs, ps);
|
||||||
|
gpu::Shader::makeProgram((*program));
|
||||||
|
|
||||||
|
auto state = std::make_shared<gpu::State>();
|
||||||
|
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
||||||
|
state->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_OPAQUE, 0xFF, gpu::ALWAYS, gpu::State::STENCIL_OP_REPLACE, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_REPLACE));
|
||||||
|
state->setColorWriteMask(0);
|
||||||
|
|
||||||
|
pipeline = gpu::Pipeline::create(program, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void initOverlay3DPipelines(ShapePlumber& plumber) {
|
||||||
|
auto vs = gpu::Shader::createVertex(std::string(overlay3D_vert));
|
||||||
|
auto ps = gpu::Shader::createPixel(std::string(overlay3D_frag));
|
||||||
|
auto program = gpu::Shader::createProgram(vs, ps);
|
||||||
|
|
||||||
|
auto opaqueState = std::make_shared<gpu::State>();
|
||||||
|
opaqueState->setDepthTest(false);
|
||||||
|
opaqueState->setBlendFunction(false);
|
||||||
|
|
||||||
|
plumber.addPipeline(ShapeKey::Filter::Builder().withOpaque(), program, opaqueState);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pipelineBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) {
|
||||||
|
if (pipeline.locations->normalFittingMapUnit > -1) {
|
||||||
|
batch.setResourceTexture(pipeline.locations->normalFittingMapUnit,
|
||||||
|
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void initDeferredPipelines(render::ShapePlumber& plumber) {
|
||||||
|
using Key = render::ShapeKey;
|
||||||
|
using ShaderPointer = gpu::ShaderPointer;
|
||||||
|
|
||||||
|
auto addPipeline = [&plumber](const Key& key, const ShaderPointer& vertexShader, const ShaderPointer& pixelShader) {
|
||||||
|
auto state = std::make_shared<gpu::State>();
|
||||||
|
|
||||||
|
// Cull backface
|
||||||
|
state->setCullMode(gpu::State::CULL_BACK);
|
||||||
|
|
||||||
|
// Z test depends on transparency
|
||||||
|
state->setDepthTest(true, !key.isTranslucent(), gpu::LESS_EQUAL);
|
||||||
|
|
||||||
|
// Blend if transparent
|
||||||
|
state->setBlendFunction(key.isTranslucent(),
|
||||||
|
// For transparency, keep the highlight intensity
|
||||||
|
gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||||
|
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||||
|
|
||||||
|
ShaderPointer program = gpu::Shader::createProgram(vertexShader, pixelShader);
|
||||||
|
plumber.addPipeline(key, program, state, &pipelineBatchSetter);
|
||||||
|
|
||||||
|
// Add a wireframe version
|
||||||
|
if (!key.isWireFrame()) {
|
||||||
|
auto wireFrameKey = Key::Builder(key).withWireframe();
|
||||||
|
auto wireFrameState = std::make_shared<gpu::State>(state->getValues());
|
||||||
|
|
||||||
|
wireFrameState->setFillMode(gpu::State::FILL_LINE);
|
||||||
|
|
||||||
|
plumber.addPipeline(wireFrameKey, program, wireFrameState, &pipelineBatchSetter);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Vertex shaders
|
||||||
|
auto modelVertex = gpu::Shader::createVertex(std::string(model_vert));
|
||||||
|
auto modelNormalMapVertex = gpu::Shader::createVertex(std::string(model_normal_map_vert));
|
||||||
|
auto modelLightmapVertex = gpu::Shader::createVertex(std::string(model_lightmap_vert));
|
||||||
|
auto modelLightmapNormalMapVertex = gpu::Shader::createVertex(std::string(model_lightmap_normal_map_vert));
|
||||||
|
auto modelShadowVertex = gpu::Shader::createVertex(std::string(model_shadow_vert));
|
||||||
|
auto skinModelVertex = gpu::Shader::createVertex(std::string(skin_model_vert));
|
||||||
|
auto skinModelNormalMapVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_vert));
|
||||||
|
auto skinModelShadowVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert));
|
||||||
|
|
||||||
|
// Pixel shaders
|
||||||
|
auto modelPixel = gpu::Shader::createPixel(std::string(model_frag));
|
||||||
|
auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(model_normal_map_frag));
|
||||||
|
auto modelSpecularMapPixel = gpu::Shader::createPixel(std::string(model_specular_map_frag));
|
||||||
|
auto modelNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_normal_specular_map_frag));
|
||||||
|
auto modelTranslucentPixel = gpu::Shader::createPixel(std::string(model_translucent_frag));
|
||||||
|
auto modelShadowPixel = gpu::Shader::createPixel(std::string(model_shadow_frag));
|
||||||
|
auto modelLightmapPixel = gpu::Shader::createPixel(std::string(model_lightmap_frag));
|
||||||
|
auto modelLightmapNormalMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_map_frag));
|
||||||
|
auto modelLightmapSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_specular_map_frag));
|
||||||
|
auto modelLightmapNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_frag));
|
||||||
|
|
||||||
|
// Fill the pipelineLib
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder(),
|
||||||
|
modelVertex, modelPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withTangents(),
|
||||||
|
modelNormalMapVertex, modelNormalMapPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSpecular(),
|
||||||
|
modelVertex, modelSpecularMapPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withTangents().withSpecular(),
|
||||||
|
modelNormalMapVertex, modelNormalSpecularMapPixel);
|
||||||
|
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withTranslucent(),
|
||||||
|
modelVertex, modelTranslucentPixel);
|
||||||
|
// FIXME Ignore lightmap for translucents meshpart
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withTranslucent().withLightmap(),
|
||||||
|
modelVertex, modelTranslucentPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withTangents().withTranslucent(),
|
||||||
|
modelNormalMapVertex, modelTranslucentPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSpecular().withTranslucent(),
|
||||||
|
modelVertex, modelTranslucentPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withTangents().withSpecular().withTranslucent(),
|
||||||
|
modelNormalMapVertex, modelTranslucentPixel);
|
||||||
|
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withLightmap(),
|
||||||
|
modelLightmapVertex, modelLightmapPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withLightmap().withTangents(),
|
||||||
|
modelLightmapNormalMapVertex, modelLightmapNormalMapPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withLightmap().withSpecular(),
|
||||||
|
modelLightmapVertex, modelLightmapSpecularMapPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withLightmap().withTangents().withSpecular(),
|
||||||
|
modelLightmapNormalMapVertex, modelLightmapNormalSpecularMapPixel);
|
||||||
|
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSkinned(),
|
||||||
|
skinModelVertex, modelPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSkinned().withTangents(),
|
||||||
|
skinModelNormalMapVertex, modelNormalMapPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSkinned().withSpecular(),
|
||||||
|
skinModelVertex, modelSpecularMapPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSkinned().withTangents().withSpecular(),
|
||||||
|
skinModelNormalMapVertex, modelNormalSpecularMapPixel);
|
||||||
|
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSkinned().withTranslucent(),
|
||||||
|
skinModelVertex, modelTranslucentPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSkinned().withTangents().withTranslucent(),
|
||||||
|
skinModelNormalMapVertex, modelTranslucentPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSkinned().withSpecular().withTranslucent(),
|
||||||
|
skinModelVertex, modelTranslucentPixel);
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSkinned().withTangents().withSpecular().withTranslucent(),
|
||||||
|
skinModelNormalMapVertex, modelTranslucentPixel);
|
||||||
|
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withDepthOnly(),
|
||||||
|
modelShadowVertex, modelShadowPixel);
|
||||||
|
|
||||||
|
|
||||||
|
addPipeline(
|
||||||
|
Key::Builder().withSkinned().withDepthOnly(),
|
||||||
|
skinModelShadowVertex, modelShadowPixel);
|
||||||
|
}
|
||||||
|
|
|
@ -257,7 +257,13 @@ public:
|
||||||
QConfigPointer config = _jobs.back().getConfiguration();
|
QConfigPointer config = _jobs.back().getConfiguration();
|
||||||
config->setParent(_config.get());
|
config->setParent(_config.get());
|
||||||
config->setObjectName(name.c_str());
|
config->setObjectName(name.c_str());
|
||||||
QObject::connect(config.get(), SIGNAL(dirty()), _config.get(), SLOT(refresh()));
|
|
||||||
|
// Connect dirty->refresh if defined
|
||||||
|
static const char* DIRTY_SIGNAL = "dirty()";
|
||||||
|
if (config->metaObject()->indexOfSignal(DIRTY_SIGNAL) != -1) {
|
||||||
|
QObject::connect(config.get(), SIGNAL(dirty()), _config.get(), SLOT(refresh()));
|
||||||
|
}
|
||||||
|
|
||||||
return _jobs.back().getOutput();
|
return _jobs.back().getOutput();
|
||||||
}
|
}
|
||||||
template <class T, class... A> const Varying addJob(std::string name, A&&... args) {
|
template <class T, class... A> const Varying addJob(std::string name, A&&... args) {
|
||||||
|
|
|
@ -220,18 +220,7 @@ QmlWindowClass::QmlWindowClass(QObject* qmlWindow)
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlWindowClass::~QmlWindowClass() {
|
QmlWindowClass::~QmlWindowClass() {
|
||||||
if (_qmlWindow) {
|
close();
|
||||||
if (_toolWindow) {
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
auto toolWindow = offscreenUi->getToolWindow();
|
|
||||||
auto invokeResult = QMetaObject::invokeMethod(toolWindow, "removeTabForUrl", Qt::QueuedConnection,
|
|
||||||
Q_ARG(QVariant, _source));
|
|
||||||
Q_ASSERT(invokeResult);
|
|
||||||
} else {
|
|
||||||
_qmlWindow->deleteLater();
|
|
||||||
}
|
|
||||||
_qmlWindow = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlWindowClass::registerObject(const QString& name, QObject* object) {
|
void QmlWindowClass::registerObject(const QString& name, QObject* object) {
|
||||||
|
@ -331,14 +320,18 @@ void QmlWindowClass::setTitle(const QString& title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlWindowClass::close() {
|
void QmlWindowClass::close() {
|
||||||
DependencyManager::get<OffscreenUi>()->executeOnUiThread([this] {
|
if (_qmlWindow) {
|
||||||
if (_qmlWindow) {
|
if (_toolWindow) {
|
||||||
_qmlWindow->setProperty("destroyOnInvisible", true);
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
_qmlWindow->setProperty("visible", false);
|
auto toolWindow = offscreenUi->getToolWindow();
|
||||||
|
auto invokeResult = QMetaObject::invokeMethod(toolWindow, "removeTabForUrl", Qt::QueuedConnection,
|
||||||
|
Q_ARG(QVariant, _source));
|
||||||
|
Q_ASSERT(invokeResult);
|
||||||
|
} else {
|
||||||
_qmlWindow->deleteLater();
|
_qmlWindow->deleteLater();
|
||||||
_qmlWindow = nullptr;
|
|
||||||
}
|
}
|
||||||
});
|
_qmlWindow = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlWindowClass::hasClosed() {
|
void QmlWindowClass::hasClosed() {
|
||||||
|
|
|
@ -282,8 +282,8 @@ void SixenseManager::InputDevice::setDebugDrawCalibrated(bool flag) {
|
||||||
|
|
||||||
// the calibration sequence is:
|
// the calibration sequence is:
|
||||||
// (1) reach arm straight out to the sides (xAxis is to the left)
|
// (1) reach arm straight out to the sides (xAxis is to the left)
|
||||||
// (2) press BUTTON_FWD on both hands and hold for one second
|
// (2) press either BUTTON_1 or BUTTON_2 on both hands and hold for one second
|
||||||
// (3) release both BUTTON_FWDs
|
// (3) release both buttons
|
||||||
//
|
//
|
||||||
// The code will:
|
// The code will:
|
||||||
// (4) assume that the orb is on a flat surface (yAxis is UP)
|
// (4) assume that the orb is on a flat surface (yAxis is UP)
|
||||||
|
@ -294,7 +294,8 @@ static const float MAXIMUM_NOISE_LEVEL = 0.05f; // meters
|
||||||
static const quint64 LOCK_DURATION = USECS_PER_SECOND / 4; // time for lock to be acquired
|
static const quint64 LOCK_DURATION = USECS_PER_SECOND / 4; // time for lock to be acquired
|
||||||
|
|
||||||
static bool calibrationRequested(SixenseControllerData* controllers) {
|
static bool calibrationRequested(SixenseControllerData* controllers) {
|
||||||
return (controllers[0].buttons == BUTTON_FWD && controllers[1].buttons == BUTTON_FWD);
|
return (((controllers[0].buttons == BUTTON_1) || (controllers[0].buttons == BUTTON_2)) &&
|
||||||
|
((controllers[1].buttons == BUTTON_1) || (controllers[1].buttons == BUTTON_2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SixenseManager::InputDevice::updateCalibration(SixenseControllerData* controllers) {
|
void SixenseManager::InputDevice::updateCalibration(SixenseControllerData* controllers) {
|
||||||
|
|
Loading…
Reference in a new issue