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

This commit is contained in:
NissimHadar 2018-03-05 11:36:39 -08:00
commit 1eb0dde3d2
14 changed files with 196 additions and 43 deletions

View file

@ -405,7 +405,7 @@ void DomainServer::restart() {
exit(DomainServer::EXIT_CODE_REBOOT); exit(DomainServer::EXIT_CODE_REBOOT);
} }
const QUuid& DomainServer::getID() { QUuid DomainServer::getID() {
return DependencyManager::get<LimitedNodeList>()->getSessionUUID(); return DependencyManager::get<LimitedNodeList>()->getSessionUUID();
} }

View file

@ -135,7 +135,7 @@ signals:
void userDisconnected(); void userDisconnected();
private: private:
const QUuid& getID(); QUuid getID();
void parseCommandLine(); void parseCommandLine();
QString getContentBackupDir(); QString getContentBackupDir();

View file

@ -6146,6 +6146,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
scriptEngine->registerGlobalObject("Selection", DependencyManager::get<SelectionScriptingInterface>().data()); scriptEngine->registerGlobalObject("Selection", DependencyManager::get<SelectionScriptingInterface>().data());
scriptEngine->registerGlobalObject("ContextOverlay", DependencyManager::get<ContextOverlayInterface>().data()); scriptEngine->registerGlobalObject("ContextOverlay", DependencyManager::get<ContextOverlayInterface>().data());
scriptEngine->registerGlobalObject("Wallet", DependencyManager::get<WalletScriptingInterface>().data()); scriptEngine->registerGlobalObject("Wallet", DependencyManager::get<WalletScriptingInterface>().data());
scriptEngine->registerGlobalObject("AddressManager", DependencyManager::get<AddressManager>().data());
qScriptRegisterMetaType(scriptEngine.data(), OverlayIDtoScriptValue, OverlayIDfromScriptValue); qScriptRegisterMetaType(scriptEngine.data(), OverlayIDtoScriptValue, OverlayIDfromScriptValue);

View file

@ -49,19 +49,8 @@ const std::set<NodeType_t> SOLO_NODE_TYPES = {
}; };
LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) : LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) :
_sessionUUID(),
_nodeHash(),
_nodeMutex(QReadWriteLock::Recursive),
_nodeSocket(this), _nodeSocket(this),
_dtlsSocket(NULL), _packetReceiver(new PacketReceiver(this))
_localSockAddr(),
_publicSockAddr(),
_stunSockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT),
_packetReceiver(new PacketReceiver(this)),
_numCollectedPackets(0),
_numCollectedBytes(0),
_packetStatTimer(),
_permissions(NodePermissions())
{ {
qRegisterMetaType<ConnectionStep>("ConnectionStep"); qRegisterMetaType<ConnectionStep>("ConnectionStep");
auto port = (socketListenPort != INVALID_PORT) ? socketListenPort : LIMITED_NODELIST_LOCAL_PORT.get(); auto port = (socketListenPort != INVALID_PORT) ? socketListenPort : LIMITED_NODELIST_LOCAL_PORT.get();
@ -122,13 +111,22 @@ LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) :
} }
} }
QUuid LimitedNodeList::getSessionUUID() const {
QReadLocker lock { &_sessionUUIDLock };
return _sessionUUID;
}
void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) { void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) {
QUuid oldUUID = _sessionUUID; QUuid oldUUID;
_sessionUUID = sessionUUID; {
QWriteLocker lock { &_sessionUUIDLock };
oldUUID = _sessionUUID;
_sessionUUID = sessionUUID;
}
if (sessionUUID != oldUUID) { if (sessionUUID != oldUUID) {
qCDebug(networking) << "NodeList UUID changed from" << uuidStringWithoutCurlyBraces(oldUUID) qCDebug(networking) << "NodeList UUID changed from" << uuidStringWithoutCurlyBraces(oldUUID)
<< "to" << uuidStringWithoutCurlyBraces(_sessionUUID); << "to" << uuidStringWithoutCurlyBraces(sessionUUID);
emit uuidChanged(sessionUUID, oldUUID); emit uuidChanged(sessionUUID, oldUUID);
} }
} }

View file

@ -104,7 +104,7 @@ public:
}; };
Q_ENUM(ConnectionStep); Q_ENUM(ConnectionStep);
const QUuid& getSessionUUID() const { return _sessionUUID; } QUuid getSessionUUID() const;
void setSessionUUID(const QUuid& sessionUUID); void setSessionUUID(const QUuid& sessionUUID);
void setPermissions(const NodePermissions& newPermissions); void setPermissions(const NodePermissions& newPermissions);
@ -380,20 +380,19 @@ protected:
bool sockAddrBelongsToNode(const HifiSockAddr& sockAddr) { return findNodeWithAddr(sockAddr) != SharedNodePointer(); } bool sockAddrBelongsToNode(const HifiSockAddr& sockAddr) { return findNodeWithAddr(sockAddr) != SharedNodePointer(); }
QUuid _sessionUUID;
NodeHash _nodeHash; NodeHash _nodeHash;
mutable QReadWriteLock _nodeMutex; mutable QReadWriteLock _nodeMutex { QReadWriteLock::Recursive };
udt::Socket _nodeSocket; udt::Socket _nodeSocket;
QUdpSocket* _dtlsSocket; QUdpSocket* _dtlsSocket { nullptr };
HifiSockAddr _localSockAddr; HifiSockAddr _localSockAddr;
HifiSockAddr _publicSockAddr; HifiSockAddr _publicSockAddr;
HifiSockAddr _stunSockAddr; HifiSockAddr _stunSockAddr { STUN_SERVER_HOSTNAME, STUN_SERVER_PORT };
bool _hasTCPCheckedLocalSocket { false }; bool _hasTCPCheckedLocalSocket { false };
PacketReceiver* _packetReceiver; PacketReceiver* _packetReceiver;
std::atomic<int> _numCollectedPackets; std::atomic<int> _numCollectedPackets { 0 };
std::atomic<int> _numCollectedBytes; std::atomic<int> _numCollectedBytes { 0 };
QElapsedTimer _packetStatTimer; QElapsedTimer _packetStatTimer;
NodePermissions _permissions; NodePermissions _permissions;
@ -424,6 +423,10 @@ private slots:
void flagTimeForConnectionStep(ConnectionStep connectionStep, quint64 timestamp); void flagTimeForConnectionStep(ConnectionStep connectionStep, quint64 timestamp);
void possiblyTimeoutSTUNAddressLookup(); void possiblyTimeoutSTUNAddressLookup();
void addSTUNHandlerToUnfiltered(); // called once STUN socket known void addSTUNHandlerToUnfiltered(); // called once STUN socket known
private:
mutable QReadWriteLock _sessionUUIDLock;
QUuid _sessionUUID;
}; };
#endif // hifi_LimitedNodeList_h #endif // hifi_LimitedNodeList_h

View file

@ -798,7 +798,7 @@ void NodeList::sendIgnoreRadiusStateToNode(const SharedNodePointer& destinationN
void NodeList::ignoreNodeBySessionID(const QUuid& nodeID, bool ignoreEnabled) { void NodeList::ignoreNodeBySessionID(const QUuid& nodeID, bool ignoreEnabled) {
// enumerate the nodes to send a reliable ignore packet to each that can leverage it // enumerate the nodes to send a reliable ignore packet to each that can leverage it
if (!nodeID.isNull() && _sessionUUID != nodeID) { if (!nodeID.isNull() && getSessionUUID() != nodeID) {
eachMatchingNode([](const SharedNodePointer& node)->bool { eachMatchingNode([](const SharedNodePointer& node)->bool {
if (node->getType() == NodeType::AudioMixer || node->getType() == NodeType::AvatarMixer) { if (node->getType() == NodeType::AudioMixer || node->getType() == NodeType::AvatarMixer) {
return true; return true;
@ -851,7 +851,7 @@ void NodeList::ignoreNodeBySessionID(const QUuid& nodeID, bool ignoreEnabled) {
void NodeList::removeFromIgnoreMuteSets(const QUuid& nodeID) { void NodeList::removeFromIgnoreMuteSets(const QUuid& nodeID) {
// don't remove yourself, or nobody // don't remove yourself, or nobody
if (!nodeID.isNull() && _sessionUUID != nodeID) { if (!nodeID.isNull() && getSessionUUID() != nodeID) {
{ {
QWriteLocker ignoredSetLocker{ &_ignoredSetLock }; QWriteLocker ignoredSetLocker{ &_ignoredSetLock };
_ignoredNodeIDs.unsafe_erase(nodeID); _ignoredNodeIDs.unsafe_erase(nodeID);
@ -870,7 +870,7 @@ bool NodeList::isIgnoringNode(const QUuid& nodeID) const {
void NodeList::personalMuteNodeBySessionID(const QUuid& nodeID, bool muteEnabled) { void NodeList::personalMuteNodeBySessionID(const QUuid& nodeID, bool muteEnabled) {
// cannot personal mute yourself, or nobody // cannot personal mute yourself, or nobody
if (!nodeID.isNull() && _sessionUUID != nodeID) { if (!nodeID.isNull() && getSessionUUID() != nodeID) {
auto audioMixer = soloNodeOfType(NodeType::AudioMixer); auto audioMixer = soloNodeOfType(NodeType::AudioMixer);
if (audioMixer) { if (audioMixer) {
if (isIgnoringNode(nodeID)) { if (isIgnoringNode(nodeID)) {
@ -970,7 +970,7 @@ void NodeList::maybeSendIgnoreSetToNode(SharedNodePointer newNode) {
void NodeList::setAvatarGain(const QUuid& nodeID, float gain) { void NodeList::setAvatarGain(const QUuid& nodeID, float gain) {
// cannot set gain of yourself // cannot set gain of yourself
if (_sessionUUID != nodeID) { if (getSessionUUID() != nodeID) {
auto audioMixer = soloNodeOfType(NodeType::AudioMixer); auto audioMixer = soloNodeOfType(NodeType::AudioMixer);
if (audioMixer) { if (audioMixer) {
// setup the packet // setup the packet
@ -1013,7 +1013,7 @@ void NodeList::kickNodeBySessionID(const QUuid& nodeID) {
// send a request to domain-server to kick the node with the given session ID // send a request to domain-server to kick the node with the given session ID
// the domain-server will handle the persistence of the kick (via username or IP) // the domain-server will handle the persistence of the kick (via username or IP)
if (!nodeID.isNull() && _sessionUUID != nodeID ) { if (!nodeID.isNull() && getSessionUUID() != nodeID ) {
if (getThisNodeCanKick()) { if (getThisNodeCanKick()) {
// setup the packet // setup the packet
auto kickPacket = NLPacket::create(PacketType::NodeKickRequest, NUM_BYTES_RFC4122_UUID, true); auto kickPacket = NLPacket::create(PacketType::NodeKickRequest, NUM_BYTES_RFC4122_UUID, true);
@ -1036,7 +1036,7 @@ void NodeList::kickNodeBySessionID(const QUuid& nodeID) {
void NodeList::muteNodeBySessionID(const QUuid& nodeID) { void NodeList::muteNodeBySessionID(const QUuid& nodeID) {
// cannot mute yourself, or nobody // cannot mute yourself, or nobody
if (!nodeID.isNull() && _sessionUUID != nodeID ) { if (!nodeID.isNull() && getSessionUUID() != nodeID ) {
if (getThisNodeCanKick()) { if (getThisNodeCanKick()) {
auto audioMixer = soloNodeOfType(NodeType::AudioMixer); auto audioMixer = soloNodeOfType(NodeType::AudioMixer);
if (audioMixer) { if (audioMixer) {

View file

@ -87,6 +87,7 @@
#include "model_shadow_vert.h" #include "model_shadow_vert.h"
#include "skin_model_shadow_vert.h" #include "skin_model_shadow_vert.h"
#include "skin_model_shadow_dq_vert.h" #include "skin_model_shadow_dq_vert.h"
#include "skin_model_shadow_fade_dq_vert.h"
#include "model_shadow_frag.h" #include "model_shadow_frag.h"
#include "skin_model_shadow_frag.h" #include "skin_model_shadow_frag.h"
@ -204,6 +205,7 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
auto skinModelDualQuatVertex = skin_model_dq_vert::getShader(); auto skinModelDualQuatVertex = skin_model_dq_vert::getShader();
auto skinModelNormalMapDualQuatVertex = skin_model_normal_map_dq_vert::getShader(); auto skinModelNormalMapDualQuatVertex = skin_model_normal_map_dq_vert::getShader();
auto skinModelShadowDualQuatVertex = skin_model_shadow_dq_vert::getShader(); auto skinModelShadowDualQuatVertex = skin_model_shadow_dq_vert::getShader();
auto skinModelShadowFadeDualQuatVertex = skin_model_shadow_fade_dq_vert::getShader();
auto skinModelFadeDualQuatVertex = skin_model_fade_dq_vert::getShader(); auto skinModelFadeDualQuatVertex = skin_model_fade_dq_vert::getShader();
auto skinModelNormalMapFadeDualQuatVertex = skin_model_normal_map_fade_dq_vert::getShader(); auto skinModelNormalMapFadeDualQuatVertex = skin_model_normal_map_fade_dq_vert::getShader();
auto skinModelTranslucentDualQuatVertex = skinModelFadeDualQuatVertex; // We use the same because it ouputs world position per vertex auto skinModelTranslucentDualQuatVertex = skinModelFadeDualQuatVertex; // We use the same because it ouputs world position per vertex
@ -390,7 +392,7 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
// Same thing but with Fade on // Same thing but with Fade on
addPipeline( addPipeline(
Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withTranslucent().withFade(), Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withTranslucent().withFade(),
skinModelFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter); skinModelFadeDualQuatVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
addPipeline( addPipeline(
Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withTranslucent().withTangents().withFade(), Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withTranslucent().withTangents().withFade(),
skinModelNormalMapFadeDualQuatVertex, modelTranslucentFadePixel, batchSetter, itemSetter); skinModelNormalMapFadeDualQuatVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
@ -409,6 +411,16 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
addPipeline( addPipeline(
Key::Builder().withSkinned().withDepthOnly().withFade(), Key::Builder().withSkinned().withDepthOnly().withFade(),
skinModelShadowFadeVertex, modelShadowFadePixel, batchSetter, itemSetter); skinModelShadowFadeVertex, modelShadowFadePixel, batchSetter, itemSetter);
// Now repeat for dual quaternion
// Depth-only
addPipeline(
Key::Builder().withSkinned().withDualQuatSkinned().withDepthOnly(),
skinModelShadowDualQuatVertex, modelShadowPixel, nullptr, nullptr);
// Same thing but with Fade on
addPipeline(
Key::Builder().withSkinned().withDualQuatSkinned().withDepthOnly().withFade(),
skinModelShadowFadeDualQuatVertex, modelShadowFadePixel, batchSetter, itemSetter);
} }
void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) { void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) {
@ -418,6 +430,9 @@ void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::Ba
auto skinModelVertex = skin_model_vert::getShader(); auto skinModelVertex = skin_model_vert::getShader();
auto skinModelNormalMapVertex = skin_model_normal_map_vert::getShader(); auto skinModelNormalMapVertex = skin_model_normal_map_vert::getShader();
auto skinModelDualQuatVertex = skin_model_dq_vert::getShader();
auto skinModelNormalMapDualQuatVertex = skin_model_normal_map_dq_vert::getShader();
// Pixel shaders // Pixel shaders
auto modelPixel = forward_model_frag::getShader(); auto modelPixel = forward_model_frag::getShader();
auto modelUnlitPixel = forward_model_unlit_frag::getShader(); auto modelUnlitPixel = forward_model_unlit_frag::getShader();
@ -445,6 +460,8 @@ void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::Ba
// Skinned Opaques // Skinned Opaques
addPipeline(Key::Builder().withMaterial().withSkinned(), skinModelVertex, modelPixel); addPipeline(Key::Builder().withMaterial().withSkinned(), skinModelVertex, modelPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withTangents(), skinModelNormalMapVertex, modelNormalMapPixel); addPipeline(Key::Builder().withMaterial().withSkinned().withTangents(), skinModelNormalMapVertex, modelNormalMapPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withDualQuatSkinned(), skinModelDualQuatVertex, modelPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withTangents().withDualQuatSkinned(), skinModelNormalMapDualQuatVertex, modelNormalMapPixel);
// Translucents // Translucents
addPipeline(Key::Builder().withMaterial().withTranslucent(), modelVertex, modelTranslucentPixel); addPipeline(Key::Builder().withMaterial().withTranslucent(), modelVertex, modelTranslucentPixel);
@ -453,6 +470,8 @@ void initForwardPipelines(ShapePlumber& plumber, const render::ShapePipeline::Ba
// Skinned Translucents // Skinned Translucents
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent(), skinModelVertex, modelTranslucentPixel); addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent(), skinModelVertex, modelTranslucentPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents(), skinModelNormalMapVertex, modelTranslucentPixel); addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents(), skinModelNormalMapVertex, modelTranslucentPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withDualQuatSkinned(), skinModelDualQuatVertex, modelTranslucentPixel);
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withDualQuatSkinned(), skinModelNormalMapDualQuatVertex, modelTranslucentPixel);
forceLightBatchSetter = false; forceLightBatchSetter = false;
} }
@ -559,7 +578,7 @@ void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state) {
auto skinPixel = skin_model_shadow_frag::getShader(); auto skinPixel = skin_model_shadow_frag::getShader();
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skinVertex, skinPixel); gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skinVertex, skinPixel);
shapePlumber.addPipeline( shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned().withoutFade(), ShapeKey::Filter::Builder().withSkinned().withoutDualQuatSkinned().withoutFade(),
skinProgram, state); skinProgram, state);
auto modelFadeVertex = model_shadow_fade_vert::getShader(); auto modelFadeVertex = model_shadow_fade_vert::getShader();
@ -573,8 +592,21 @@ void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state) {
auto skinFadePixel = skin_model_shadow_fade_frag::getShader(); auto skinFadePixel = skin_model_shadow_fade_frag::getShader();
gpu::ShaderPointer skinFadeProgram = gpu::Shader::createProgram(skinFadeVertex, skinFadePixel); gpu::ShaderPointer skinFadeProgram = gpu::Shader::createProgram(skinFadeVertex, skinFadePixel);
shapePlumber.addPipeline( shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned().withFade(), ShapeKey::Filter::Builder().withSkinned().withoutDualQuatSkinned().withFade(),
skinFadeProgram, state); skinFadeProgram, state);
//Added for dual quaternions
auto skinModelShadowDualQuatVertex = skin_model_shadow_dq_vert::getShader();
gpu::ShaderPointer skinModelShadowDualQuatProgram = gpu::Shader::createProgram(skinModelShadowDualQuatVertex, skinPixel);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned().withDualQuatSkinned().withoutFade(),
skinModelShadowDualQuatProgram, state);
auto skinModelShadowFadeDualQuatVertex = skin_model_shadow_fade_dq_vert::getShader();
gpu::ShaderPointer skinModelShadowFadeDualQuatProgram = gpu::Shader::createProgram(skinModelShadowFadeDualQuatVertex, skinFadePixel);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withSkinned().withDualQuatSkinned().withFade(),
skinModelShadowFadeDualQuatProgram, state);
} }
#include "RenderPipelines.h" #include "RenderPipelines.h"

View file

@ -163,8 +163,10 @@ void RenderShadowMap::run(const render::RenderContextPointer& renderContext, con
auto shadowPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder); auto shadowPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder);
auto shadowSkinnedPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withSkinned()); auto shadowSkinnedPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withSkinned());
auto shadowSkinnedDQPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withSkinned().withDualQuatSkinned());
std::vector<ShapeKey> skinnedShapeKeys{}; std::vector<ShapeKey> skinnedShapeKeys{};
std::vector<ShapeKey> skinnedDQShapeKeys{};
std::vector<ShapeKey> ownPipelineShapeKeys{}; std::vector<ShapeKey> ownPipelineShapeKeys{};
// Iterate through all inShapes and render the unskinned // Iterate through all inShapes and render the unskinned
@ -172,7 +174,11 @@ void RenderShadowMap::run(const render::RenderContextPointer& renderContext, con
batch.setPipeline(shadowPipeline->pipeline); batch.setPipeline(shadowPipeline->pipeline);
for (auto items : inShapes) { for (auto items : inShapes) {
if (items.first.isSkinned()) { if (items.first.isSkinned()) {
skinnedShapeKeys.push_back(items.first); if (items.first.isDualQuatSkinned()) {
skinnedDQShapeKeys.push_back(items.first);
} else {
skinnedShapeKeys.push_back(items.first);
}
} else if (!items.first.hasOwnPipeline()) { } else if (!items.first.hasOwnPipeline()) {
renderItems(renderContext, items.second); renderItems(renderContext, items.second);
} else { } else {
@ -187,6 +193,13 @@ void RenderShadowMap::run(const render::RenderContextPointer& renderContext, con
renderItems(renderContext, inShapes.at(key)); renderItems(renderContext, inShapes.at(key));
} }
// Reiterate to render the DQ skinned
args->_shapePipeline = shadowSkinnedDQPipeline;
batch.setPipeline(shadowSkinnedDQPipeline->pipeline);
for (const auto& key : skinnedDQShapeKeys) {
renderItems(renderContext, inShapes.at(key));
}
// Finally render the items with their own pipeline last to prevent them from breaking the // Finally render the items with their own pipeline last to prevent them from breaking the
// render state. This is probably a temporary code as there is probably something better // render state. This is probably a temporary code as there is probably something better
// to do in the render call of objects that have their own pipeline. // to do in the render call of objects that have their own pipeline.

View file

@ -30,6 +30,7 @@ out vec3 _normal;
out vec3 _tangent; out vec3 _tangent;
out vec3 _color; out vec3 _color;
out float _alpha; out float _alpha;
out vec4 _worldPosition;
void main(void) { void main(void) {
vec4 position = vec4(0.0, 0.0, 0.0, 0.0); vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
@ -53,6 +54,7 @@ void main(void) {
TransformCamera cam = getTransformCamera(); TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject(); TransformObject obj = getTransformObject();
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$> <$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
<$transformModelToWorldPos(obj, position, _worldPosition)$>
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$> <$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
<$transformModelToWorldDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$> <$transformModelToWorldDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$>

View file

@ -130,8 +130,8 @@ public:
Builder& withSkinned() { _flags.set(SKINNED); _mask.set(SKINNED); return (*this); } Builder& withSkinned() { _flags.set(SKINNED); _mask.set(SKINNED); return (*this); }
Builder& withoutSkinned() { _flags.reset(SKINNED); _mask.set(SKINNED); return (*this); } Builder& withoutSkinned() { _flags.reset(SKINNED); _mask.set(SKINNED); return (*this); }
Builder& withDualQuatSkinned() { _flags.set(DUAL_QUAT_SKINNED); _mask.set(SKINNED); return (*this); } Builder& withDualQuatSkinned() { _flags.set(DUAL_QUAT_SKINNED); _mask.set(DUAL_QUAT_SKINNED); return (*this); }
Builder& withoutDualQuatSkinned() { _flags.reset(DUAL_QUAT_SKINNED); _mask.set(SKINNED); return (*this); } Builder& withoutDualQuatSkinned() { _flags.reset(DUAL_QUAT_SKINNED); _mask.set(DUAL_QUAT_SKINNED); return (*this); }
Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); _mask.set(DEPTH_ONLY); return (*this); } Builder& withDepthOnly() { _flags.set(DEPTH_ONLY); _mask.set(DEPTH_ONLY); return (*this); }
Builder& withoutDepthOnly() { _flags.reset(DEPTH_ONLY); _mask.set(DEPTH_ONLY); return (*this); } Builder& withoutDepthOnly() { _flags.reset(DEPTH_ONLY); _mask.set(DEPTH_ONLY); return (*this); }
@ -170,6 +170,7 @@ public:
bool isUnlit() const { return _flags[UNLIT]; } bool isUnlit() const { return _flags[UNLIT]; }
bool isTranslucent() const { return _flags[TRANSLUCENT]; } bool isTranslucent() const { return _flags[TRANSLUCENT]; }
bool isSkinned() const { return _flags[SKINNED]; } bool isSkinned() const { return _flags[SKINNED]; }
bool isDualQuatSkinned() const { return _flags[DUAL_QUAT_SKINNED]; }
bool isDepthOnly() const { return _flags[DEPTH_ONLY]; } bool isDepthOnly() const { return _flags[DEPTH_ONLY]; }
bool isDepthBiased() const { return _flags[DEPTH_BIAS]; } bool isDepthBiased() const { return _flags[DEPTH_BIAS]; }
bool isWireframe() const { return _flags[WIREFRAME]; } bool isWireframe() const { return _flags[WIREFRAME]; }
@ -209,6 +210,7 @@ inline QDebug operator<<(QDebug debug, const ShapeKey& key) {
<< "isUnlit:" << key.isUnlit() << "isUnlit:" << key.isUnlit()
<< "isTranslucent:" << key.isTranslucent() << "isTranslucent:" << key.isTranslucent()
<< "isSkinned:" << key.isSkinned() << "isSkinned:" << key.isSkinned()
<< "isDualQuatSkinned:" << key.isDualQuatSkinned()
<< "isDepthOnly:" << key.isDepthOnly() << "isDepthOnly:" << key.isDepthOnly()
<< "isDepthBiased:" << key.isDepthBiased() << "isDepthBiased:" << key.isDepthBiased()
<< "isWireframe:" << key.isWireframe() << "isWireframe:" << key.isWireframe()

View file

@ -14,7 +14,7 @@
PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI
Picks, makeLaserLockInfo Xform, makeLaserParams Picks, makeLaserLockInfo Xform, makeLaserParams, AddressManager, getEntityParents
*/ */
Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@ -375,7 +375,7 @@ Script.include("/~/system/libraries/Xform.js");
return true; return true;
} }
return false; return false;
} };
this.isReady = function (controllerData) { this.isReady = function (controllerData) {
if (HMD.active) { if (HMD.active) {
@ -449,11 +449,16 @@ Script.include("/~/system/libraries/Xform.js");
if (rayPickInfo.type === Picks.INTERSECTED_ENTITY) { if (rayPickInfo.type === Picks.INTERSECTED_ENTITY) {
if (controllerData.triggerClicks[this.hand]) { if (controllerData.triggerClicks[this.hand]) {
var entityID = rayPickInfo.objectID; var entityID = rayPickInfo.objectID;
var targetProps = Entities.getEntityProperties(entityID, [ var targetProps = Entities.getEntityProperties(entityID, [
"dynamic", "shapeType", "position", "dynamic", "shapeType", "position",
"rotation", "dimensions", "density", "rotation", "dimensions", "density",
"userData", "locked", "type" "userData", "locked", "type", "href"
]); ]);
if (targetProps.href !== "") {
AddressManager.handleLookupString(targetProps.href);
return makeRunningValues(false, [], []);
}
this.targetObject = new TargetObject(entityID, targetProps); this.targetObject = new TargetObject(entityID, targetProps);
this.targetObject.parentProps = getEntityParents(targetProps); this.targetObject.parentProps = getEntityParents(targetProps);
@ -480,7 +485,8 @@ Script.include("/~/system/libraries/Xform.js");
this.grabbedDistance = rayPickInfo.distance; this.grabbedDistance = rayPickInfo.distance;
} }
if (otherFarGrabModule.grabbedThingID === this.grabbedThingID && otherFarGrabModule.distanceHolding) { if (otherFarGrabModule.grabbedThingID === this.grabbedThingID &&
otherFarGrabModule.distanceHolding) {
this.prepareDistanceRotatingData(controllerData); this.prepareDistanceRotatingData(controllerData);
this.distanceRotate(otherFarGrabModule); this.distanceRotate(otherFarGrabModule);
} else { } else {

View file

@ -0,0 +1,95 @@
"use strict";
// nearGrabHyperLinkEntity.js
//
// Created by Dante Ruiz on 03/02/2018
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,
getControllerJointIndex, getGrabbableData, enableDispatcherModule, disableDispatcherModule,
propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable,
Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues,
TRIGGER_OFF_VALUE, NEAR_GRAB_RADIUS, findGroupParent, entityIsCloneable, propsAreCloneDynamic, cloneEntity,
HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, AddressManager
*/
(function() {
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
Script.include("/~/system/libraries/controllers.js");
function NearGrabHyperLinkEntity(hand) {
this.hand = hand;
this.targetEntityID = null;
this.hyperlink = "";
this.parameters = makeDispatcherModuleParameters(
485,
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
[],
100);
this.getTargetProps = function(controllerData) {
var nearbyEntitiesProperties = controllerData.nearbyEntityProperties[this.hand];
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
for (var i = 0; i < nearbyEntitiesProperties.length; i++) {
var props = nearbyEntitiesProperties[i];
if (props.distance > NEAR_GRAB_RADIUS * sensorScaleFactor) {
continue;
}
if (props.href !== "" && props.href !== undefined) {
return props;
}
}
return null;
};
this.isReady = function(controllerData) {
this.targetEntityID = null;
if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE &&
controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {
return makeRunningValues(false, [], []);
}
var targetProps = this.getTargetProps(controllerData);
if (targetProps) {
this.hyperlink = targetProps.href;
this.targetEntityID = targetProps.id;
return makeRunningValues(true, [], []);
}
return makeRunningValues(false, [], []);
};
this.run = function(controllerData) {
if ((controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE &&
controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) || this.hyperlink === "") {
return makeRunningValues(false, [], []);
}
if (controllerData.triggerClicks[this.hand] ||
controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) {
AddressManager.handleLookupString(this.hyperlink);
return makeRunningValues(false, [], []);
}
return makeRunningValues(true, [], []);
};
}
var leftNearGrabHyperLinkEntity = new NearGrabHyperLinkEntity(LEFT_HAND);
var rightNearGrabHyperLinkEntity = new NearGrabHyperLinkEntity(RIGHT_HAND);
enableDispatcherModule("LeftNearGrabHyperLink", leftNearGrabHyperLinkEntity);
enableDispatcherModule("RightNearGrabHyperLink", rightNearGrabHyperLinkEntity);
function cleanup() {
disableDispatcherModule("LeftNearGrabHyperLink");
disableDispatcherModule("RightNearGrabHyperLink");
}
Script.scriptEnding.connect(cleanup);
}());

View file

@ -31,7 +31,8 @@ var CONTOLLER_SCRIPTS = [
"controllerModules/scaleAvatar.js", "controllerModules/scaleAvatar.js",
"controllerModules/hudOverlayPointer.js", "controllerModules/hudOverlayPointer.js",
"controllerModules/mouseHMD.js", "controllerModules/mouseHMD.js",
"controllerModules/scaleEntity.js" "controllerModules/scaleEntity.js",
"controllerModules/nearGrabHyperLinkEntity.js"
]; ];
var DEBUG_MENU_ITEM = "Debug defaultScripts.js"; var DEBUG_MENU_ITEM = "Debug defaultScripts.js";

View file

@ -105,7 +105,8 @@ DISPATCHER_PROPERTIES = [
"density", "density",
"dimensions", "dimensions",
"userData", "userData",
"type" "type",
"href"
]; ];
// priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step // priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step
@ -233,7 +234,6 @@ entityIsDistanceGrabbable = function(props) {
return true; return true;
}; };
getControllerJointIndex = function (hand) { getControllerJointIndex = function (hand) {
if (HMD.isHandControllerAvailable()) { if (HMD.isHandControllerAvailable()) {
var controllerJointIndex = -1; var controllerJointIndex = -1;