mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 05:04:14 +02:00
Merge remote-tracking branch 'upstream/master' into android_new_login
This commit is contained in:
commit
1330132a32
114 changed files with 1316 additions and 821 deletions
assignment-client/src
domain-server/resources/web/wizard
interface
resources/qml/hifi/commerce/purchases
src
Application.cppApplication.hAvatarBookmarks.hCrashpad.cppLODManager.hSpeechRecognizer.h
audio
avatar
commerce
devices
raypick
scripting
AccountServicesScriptingInterface.hAudio.hClipboardScriptingInterface.hControllerScriptingInterface.hGooglePolyScriptingInterface.hHMDScriptingInterface.hMenuScriptingInterface.hSelectionScriptingInterface.hSettingsScriptingInterface.hWindowScriptingInterface.h
ui
libraries
animation/src
audio-client/src
audio/src
avatars/src
controllers/src/controllers/impl
display-plugins/src/display-plugins
entities-renderer/src
EntityTreeRenderer.cppEntityTreeRenderer.hRenderableParticleEffectEntityItem.cppRenderablePolyLineEntityItem.cpp
entities/src
gpu-gl-common/src/gpu/gl
gpu/src/gpu
graphics-scripting/src/graphics-scripting
model-networking/src/model-networking
networking/src
octree/src
Octree.hOctreeQuery.cppOctreeQuery.hOctreeQueryNode.cppOctreeQueryNode.hOctreeUtils.cppOctreeUtils.h
render-utils/src
script-engine/src
AssetScriptingInterface.hQuat.hRecordingScriptingInterface.hSceneScriptingInterface.hScriptEngine.hScriptEngines.hScriptUUID.hScriptsModel.hScriptsModelFilter.hUsersScriptingInterface.hVec3.h
shared/src
|
@ -548,16 +548,21 @@ void Agent::setIsAvatar(bool isAvatar) {
|
|||
if (_isAvatar && !_avatarIdentityTimer) {
|
||||
// set up the avatar timers
|
||||
_avatarIdentityTimer = new QTimer(this);
|
||||
_avatarViewTimer = new QTimer(this);
|
||||
|
||||
// connect our slot
|
||||
connect(_avatarIdentityTimer, &QTimer::timeout, this, &Agent::sendAvatarIdentityPacket);
|
||||
connect(_avatarViewTimer, &QTimer::timeout, this, &Agent::sendAvatarViewFrustum);
|
||||
|
||||
static const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS = 1000;
|
||||
static const int AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS = 1000;
|
||||
|
||||
// start the timers
|
||||
_avatarIdentityTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); // FIXME - we shouldn't really need to constantly send identity packets
|
||||
_avatarViewTimer->start(AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS);
|
||||
|
||||
// tell the avatarAudioTimer to start ticking
|
||||
QMetaObject::invokeMethod(&_avatarAudioTimer, "start");
|
||||
|
||||
}
|
||||
|
||||
if (!_isAvatar) {
|
||||
|
@ -567,6 +572,10 @@ void Agent::setIsAvatar(bool isAvatar) {
|
|||
delete _avatarIdentityTimer;
|
||||
_avatarIdentityTimer = nullptr;
|
||||
|
||||
_avatarViewTimer->stop();
|
||||
delete _avatarViewTimer;
|
||||
_avatarViewTimer = nullptr;
|
||||
|
||||
// The avatar mixer never times out a connection (e.g., based on identity or data packets)
|
||||
// but rather keeps avatars in its list as long as "connected". As a result, clients timeout
|
||||
// when we stop sending identity, but then get woken up again by the mixer itself, which sends
|
||||
|
@ -585,6 +594,7 @@ void Agent::setIsAvatar(bool isAvatar) {
|
|||
nodeList->sendPacket(std::move(packet), *node);
|
||||
});
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(&_avatarAudioTimer, "stop");
|
||||
}
|
||||
}
|
||||
|
@ -597,6 +607,25 @@ void Agent::sendAvatarIdentityPacket() {
|
|||
}
|
||||
}
|
||||
|
||||
void Agent::sendAvatarViewFrustum() {
|
||||
auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>();
|
||||
|
||||
ViewFrustum view;
|
||||
view.setPosition(scriptedAvatar->getWorldPosition());
|
||||
view.setOrientation(scriptedAvatar->getHeadOrientation());
|
||||
view.calculate();
|
||||
|
||||
uint8_t numFrustums = 1;
|
||||
auto viewFrustumByteArray = view.toByteArray();
|
||||
|
||||
auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size() + sizeof(numFrustums));
|
||||
avatarPacket->writePrimitive(numFrustums);
|
||||
avatarPacket->write(viewFrustumByteArray);
|
||||
|
||||
DependencyManager::get<NodeList>()->broadcastToNodes(std::move(avatarPacket),
|
||||
{ NodeType::AvatarMixer });
|
||||
}
|
||||
|
||||
void Agent::processAgentAvatar() {
|
||||
if (!_scriptEngine->isFinished() && _isAvatar) {
|
||||
auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>();
|
||||
|
|
|
@ -97,6 +97,7 @@ private:
|
|||
void setAvatarSound(SharedSoundPointer avatarSound) { _avatarSound = avatarSound; }
|
||||
|
||||
void sendAvatarIdentityPacket();
|
||||
void sendAvatarViewFrustum();
|
||||
|
||||
QString _scriptContents;
|
||||
QTimer* _scriptRequestTimeout { nullptr };
|
||||
|
@ -106,6 +107,7 @@ private:
|
|||
int _numAvatarSoundSentBytes = 0;
|
||||
bool _isAvatar = false;
|
||||
QTimer* _avatarIdentityTimer = nullptr;
|
||||
QTimer* _avatarViewTimer = nullptr;
|
||||
QHash<QUuid, quint16> _outgoingScriptAudioSequenceNumbers;
|
||||
|
||||
AudioGate _audioGate;
|
||||
|
|
|
@ -521,11 +521,9 @@ void AvatarMixer::handleViewFrustumPacket(QSharedPointer<ReceivedMessage> messag
|
|||
auto start = usecTimestampNow();
|
||||
getOrCreateClientData(senderNode);
|
||||
|
||||
if (senderNode->getLinkedData()) {
|
||||
AvatarMixerClientData* nodeData = dynamic_cast<AvatarMixerClientData*>(senderNode->getLinkedData());
|
||||
if (nodeData != nullptr) {
|
||||
nodeData->readViewFrustumPacket(message->getMessage());
|
||||
}
|
||||
AvatarMixerClientData* nodeData = dynamic_cast<AvatarMixerClientData*>(senderNode->getLinkedData());
|
||||
if (nodeData) {
|
||||
nodeData->readViewFrustumPacket(message->getMessage());
|
||||
}
|
||||
|
||||
auto end = usecTimestampNow();
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
AvatarMixerClientData::AvatarMixerClientData(const QUuid& nodeID) :
|
||||
NodeData(nodeID)
|
||||
{
|
||||
_currentViewFrustum.invalidate();
|
||||
|
||||
// in case somebody calls getSessionUUID on the AvatarData instance, make sure it has the right ID
|
||||
_avatar->setID(nodeID);
|
||||
}
|
||||
|
@ -128,12 +126,27 @@ void AvatarMixerClientData::removeFromRadiusIgnoringSet(SharedNodePointer self,
|
|||
}
|
||||
}
|
||||
|
||||
void AvatarMixerClientData::readViewFrustumPacket(const QByteArray& message) {
|
||||
_currentViewFrustum.fromByteArray(message);
|
||||
void AvatarMixerClientData::readViewFrustumPacket(QByteArray message) {
|
||||
_currentViewFrustums.clear();
|
||||
|
||||
uint8_t numFrustums = 0;
|
||||
memcpy(&numFrustums, message.constData(), sizeof(numFrustums));
|
||||
message.remove(0, sizeof(numFrustums));
|
||||
|
||||
for (uint8_t i = 0; i < numFrustums; ++i) {
|
||||
ViewFrustum frustum;
|
||||
auto bytesRead = frustum.fromByteArray(message);
|
||||
message.remove(0, bytesRead);
|
||||
|
||||
_currentViewFrustums.push_back(frustum);
|
||||
}
|
||||
}
|
||||
|
||||
bool AvatarMixerClientData::otherAvatarInView(const AABox& otherAvatarBox) {
|
||||
return _currentViewFrustum.boxIntersectsKeyhole(otherAvatarBox);
|
||||
return std::any_of(std::begin(_currentViewFrustums), std::end(_currentViewFrustums),
|
||||
[&](const ViewFrustum& viewFrustum) {
|
||||
return viewFrustum.boxIntersectsKeyhole(otherAvatarBox);
|
||||
});
|
||||
}
|
||||
|
||||
void AvatarMixerClientData::loadJSONStats(QJsonObject& jsonObject) const {
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
void removeFromRadiusIgnoringSet(SharedNodePointer self, const QUuid& other);
|
||||
void ignoreOther(SharedNodePointer self, SharedNodePointer other);
|
||||
|
||||
void readViewFrustumPacket(const QByteArray& message);
|
||||
void readViewFrustumPacket(QByteArray message);
|
||||
|
||||
bool otherAvatarInView(const AABox& otherAvatarBox);
|
||||
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
bool getRequestsDomainListData() { return _requestsDomainListData; }
|
||||
void setRequestsDomainListData(bool requesting) { _requestsDomainListData = requesting; }
|
||||
|
||||
ViewFrustum getViewFrustum() const { return _currentViewFrustum; }
|
||||
const ViewFrustums& getViewFrustums() const { return _currentViewFrustums; }
|
||||
|
||||
uint64_t getLastOtherAvatarEncodeTime(QUuid otherAvatar) const;
|
||||
void setLastOtherAvatarEncodeTime(const QUuid& otherAvatar, uint64_t time);
|
||||
|
@ -150,7 +150,7 @@ private:
|
|||
|
||||
SimpleMovingAverage _avgOtherAvatarDataRate;
|
||||
std::unordered_set<QUuid> _radiusIgnoredOthers;
|
||||
ViewFrustum _currentViewFrustum;
|
||||
ViewFrustums _currentViewFrustums;
|
||||
|
||||
int _recentOtherAvatarsInView { 0 };
|
||||
int _recentOtherAvatarsOutOfView { 0 };
|
||||
|
|
|
@ -222,8 +222,8 @@ void AvatarMixerSlave::broadcastAvatarDataToAgent(const SharedNodePointer& node)
|
|||
};
|
||||
|
||||
// prepare to sort
|
||||
ViewFrustum cameraView = nodeData->getViewFrustum();
|
||||
PrioritySortUtil::PriorityQueue<SortableAvatar> sortedAvatars(cameraView,
|
||||
const auto& cameraViews = nodeData->getViewFrustums();
|
||||
PrioritySortUtil::PriorityQueue<SortableAvatar> sortedAvatars(cameraViews,
|
||||
AvatarData::_avatarSortCoefficientSize,
|
||||
AvatarData::_avatarSortCoefficientCenter,
|
||||
AvatarData::_avatarSortCoefficientAge);
|
||||
|
|
|
@ -15,7 +15,7 @@ const float PrioritizedEntity::DO_NOT_SEND = -1.0e-6f;
|
|||
const float PrioritizedEntity::FORCE_REMOVE = -1.0e-5f;
|
||||
const float PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY = 1.0f;
|
||||
|
||||
void ConicalView::set(const ViewFrustum& viewFrustum) {
|
||||
void ConicalViewFrustum::set(const ViewFrustum& viewFrustum) {
|
||||
// The ConicalView has two parts: a central sphere (same as ViewFrustum) and a circular cone that bounds the frustum part.
|
||||
// Why? Because approximate intersection tests are much faster to compute for a cone than for a frustum.
|
||||
_position = viewFrustum.getPosition();
|
||||
|
@ -31,7 +31,7 @@ void ConicalView::set(const ViewFrustum& viewFrustum) {
|
|||
_radius = viewFrustum.getCenterRadius();
|
||||
}
|
||||
|
||||
float ConicalView::computePriority(const AACube& cube) const {
|
||||
float ConicalViewFrustum::computePriority(const AACube& cube) const {
|
||||
glm::vec3 p = cube.calcCenter() - _position; // position of bounding sphere in view-frame
|
||||
float d = glm::length(p); // distance to center of bounding sphere
|
||||
float r = 0.5f * cube.getScale(); // radius of bounding sphere
|
||||
|
@ -51,3 +51,26 @@ float ConicalView::computePriority(const AACube& cube) const {
|
|||
}
|
||||
return PrioritizedEntity::DO_NOT_SEND;
|
||||
}
|
||||
|
||||
|
||||
void ConicalView::set(const DiffTraversal::View& view) {
|
||||
auto size = view.viewFrustums.size();
|
||||
_conicalViewFrustums.resize(size);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
_conicalViewFrustums[i].set(view.viewFrustums[i]);
|
||||
}
|
||||
}
|
||||
|
||||
float ConicalView::computePriority(const AACube& cube) const {
|
||||
if (_conicalViewFrustums.empty()) {
|
||||
return PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY;
|
||||
}
|
||||
|
||||
float priority = PrioritizedEntity::DO_NOT_SEND;
|
||||
|
||||
for (const auto& view : _conicalViewFrustums) {
|
||||
priority = std::max(priority, view.computePriority(cube));
|
||||
}
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
|
|
@ -13,18 +13,20 @@
|
|||
#define hifi_EntityPriorityQueue_h
|
||||
|
||||
#include <queue>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <AACube.h>
|
||||
#include <DiffTraversal.h>
|
||||
#include <EntityTreeElement.h>
|
||||
|
||||
const float SQRT_TWO_OVER_TWO = 0.7071067811865f;
|
||||
const float DEFAULT_VIEW_RADIUS = 10.0f;
|
||||
|
||||
// ConicalView is an approximation of a ViewFrustum for fast calculation of sort priority.
|
||||
class ConicalView {
|
||||
// ConicalViewFrustum is an approximation of a ViewFrustum for fast calculation of sort priority.
|
||||
class ConicalViewFrustum {
|
||||
public:
|
||||
ConicalView() {}
|
||||
ConicalView(const ViewFrustum& viewFrustum) { set(viewFrustum); }
|
||||
ConicalViewFrustum() {}
|
||||
ConicalViewFrustum(const ViewFrustum& viewFrustum) { set(viewFrustum); }
|
||||
void set(const ViewFrustum& viewFrustum);
|
||||
float computePriority(const AACube& cube) const;
|
||||
private:
|
||||
|
@ -35,6 +37,16 @@ private:
|
|||
float _radius { DEFAULT_VIEW_RADIUS };
|
||||
};
|
||||
|
||||
// Simple wrapper around a set of conical view frustums
|
||||
class ConicalView {
|
||||
public:
|
||||
ConicalView() {}
|
||||
void set(const DiffTraversal::View& view);
|
||||
float computePriority(const AACube& cube) const;
|
||||
private:
|
||||
std::vector<ConicalViewFrustum> _conicalViewFrustums;
|
||||
};
|
||||
|
||||
// PrioritizedEntity is a placeholder in a sorted queue.
|
||||
class PrioritizedEntity {
|
||||
public:
|
||||
|
@ -61,6 +73,50 @@ private:
|
|||
bool _forceRemove;
|
||||
};
|
||||
|
||||
using EntityPriorityQueue = std::priority_queue< PrioritizedEntity, std::vector<PrioritizedEntity>, PrioritizedEntity::Compare >;
|
||||
class EntityPriorityQueue {
|
||||
public:
|
||||
inline bool empty() const {
|
||||
assert(_queue.empty() == _entities.empty());
|
||||
return _queue.empty();
|
||||
}
|
||||
|
||||
inline const PrioritizedEntity& top() const {
|
||||
assert(!_queue.empty());
|
||||
return _queue.top();
|
||||
}
|
||||
|
||||
inline bool contains(const EntityItem* entity) const {
|
||||
return _entities.find(entity) != std::end(_entities);
|
||||
}
|
||||
|
||||
inline void emplace(const EntityItemPointer& entity, float priority, bool forceRemove = false) {
|
||||
assert(entity && !contains(entity.get()));
|
||||
_queue.emplace(entity, priority, forceRemove);
|
||||
_entities.insert(entity.get());
|
||||
assert(_queue.size() == _entities.size());
|
||||
}
|
||||
|
||||
inline void pop() {
|
||||
assert(!empty());
|
||||
_entities.erase(_queue.top().getRawEntityPointer());
|
||||
_queue.pop();
|
||||
assert(_queue.size() == _entities.size());
|
||||
}
|
||||
|
||||
inline void swap(EntityPriorityQueue& other) {
|
||||
std::swap(_queue, other._queue);
|
||||
std::swap(_entities, other._entities);
|
||||
}
|
||||
|
||||
private:
|
||||
using PriorityQueue = std::priority_queue<PrioritizedEntity,
|
||||
std::vector<PrioritizedEntity>,
|
||||
PrioritizedEntity::Compare>;
|
||||
|
||||
PriorityQueue _queue;
|
||||
// Keep dictionary of all the entities in the queue for fast contain checks.
|
||||
std::unordered_set<const EntityItem*> _entities;
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_EntityPriorityQueue_h
|
||||
|
|
|
@ -103,48 +103,58 @@ void EntityTreeSendThread::preDistributionProcessing() {
|
|||
void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, OctreeQueryNode* nodeData,
|
||||
bool viewFrustumChanged, bool isFullScene) {
|
||||
if (viewFrustumChanged || _traversal.finished()) {
|
||||
ViewFrustum viewFrustum;
|
||||
nodeData->copyCurrentViewFrustum(viewFrustum);
|
||||
EntityTreeElementPointer root = std::dynamic_pointer_cast<EntityTreeElement>(_myServer->getOctree()->getRoot());
|
||||
|
||||
|
||||
DiffTraversal::View newView;
|
||||
|
||||
ViewFrustum viewFrustum;
|
||||
if (nodeData->hasMainViewFrustum()) {
|
||||
nodeData->copyCurrentMainViewFrustum(viewFrustum);
|
||||
newView.viewFrustums.push_back(viewFrustum);
|
||||
}
|
||||
if (nodeData->hasSecondaryViewFrustum()) {
|
||||
nodeData->copyCurrentSecondaryViewFrustum(viewFrustum);
|
||||
newView.viewFrustums.push_back(viewFrustum);
|
||||
}
|
||||
|
||||
int32_t lodLevelOffset = nodeData->getBoundaryLevelAdjust() + (viewFrustumChanged ? LOW_RES_MOVING_ADJUST : NO_BOUNDARY_ADJUST);
|
||||
startNewTraversal(viewFrustum, root, lodLevelOffset, nodeData->getUsesFrustum());
|
||||
newView.lodScaleFactor = powf(2.0f, lodLevelOffset);
|
||||
|
||||
startNewTraversal(newView, root);
|
||||
|
||||
// When the viewFrustum changed the sort order may be incorrect, so we re-sort
|
||||
// and also use the opportunity to cull anything no longer in view
|
||||
if (viewFrustumChanged && !_sendQueue.empty()) {
|
||||
EntityPriorityQueue prevSendQueue;
|
||||
_sendQueue.swap(prevSendQueue);
|
||||
_entitiesInQueue.clear();
|
||||
std::swap(_sendQueue, prevSendQueue);
|
||||
assert(_sendQueue.empty());
|
||||
|
||||
// Re-add elements from previous traversal if they still need to be sent
|
||||
float lodScaleFactor = _traversal.getCurrentLODScaleFactor();
|
||||
glm::vec3 viewPosition = _traversal.getCurrentView().getPosition();
|
||||
while (!prevSendQueue.empty()) {
|
||||
EntityItemPointer entity = prevSendQueue.top().getEntity();
|
||||
bool forceRemove = prevSendQueue.top().shouldForceRemove();
|
||||
prevSendQueue.pop();
|
||||
if (entity) {
|
||||
if (!forceRemove) {
|
||||
float priority = PrioritizedEntity::DO_NOT_SEND;
|
||||
|
||||
if (forceRemove) {
|
||||
priority = PrioritizedEntity::FORCE_REMOVE;
|
||||
} else {
|
||||
bool success = false;
|
||||
AACube cube = entity->getQueryAACube(success);
|
||||
if (success) {
|
||||
if (_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) {
|
||||
float priority = _conicalView.computePriority(cube);
|
||||
if (priority != PrioritizedEntity::DO_NOT_SEND) {
|
||||
float distance = glm::distance(cube.calcCenter(), viewPosition) + MIN_VISIBLE_DISTANCE;
|
||||
float angularDiameter = cube.getScale() / distance;
|
||||
if (angularDiameter > MIN_ENTITY_ANGULAR_DIAMETER * lodScaleFactor) {
|
||||
_sendQueue.push(PrioritizedEntity(entity, priority));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
}
|
||||
}
|
||||
const auto& view = _traversal.getCurrentView();
|
||||
if (view.intersects(cube) && view.isBigEnough(cube)) {
|
||||
priority = _conicalView.computePriority(cube);
|
||||
}
|
||||
} else {
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY;
|
||||
}
|
||||
} else {
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::FORCE_REMOVE, true));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
}
|
||||
|
||||
if (priority != PrioritizedEntity::DO_NOT_SEND) {
|
||||
_sendQueue.emplace(entity, priority, forceRemove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -215,10 +225,9 @@ bool EntityTreeSendThread::addDescendantsToExtraFlaggedEntities(const QUuid& fil
|
|||
return hasNewChild || hasNewDescendants;
|
||||
}
|
||||
|
||||
void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTreeElementPointer root, int32_t lodLevelOffset,
|
||||
bool usesViewFrustum) {
|
||||
void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root) {
|
||||
|
||||
DiffTraversal::Type type = _traversal.prepareNewTraversal(view, root, lodLevelOffset, usesViewFrustum);
|
||||
DiffTraversal::Type type = _traversal.prepareNewTraversal(view, root);
|
||||
// there are three types of traversal:
|
||||
//
|
||||
// (1) FirstTime = at login --> find everything in view
|
||||
|
@ -236,161 +245,114 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree
|
|||
case DiffTraversal::First:
|
||||
// When we get to a First traversal, clear the _knownState
|
||||
_knownState.clear();
|
||||
if (usesViewFrustum) {
|
||||
float lodScaleFactor = _traversal.getCurrentLODScaleFactor();
|
||||
glm::vec3 viewPosition = _traversal.getCurrentView().getPosition();
|
||||
_traversal.setScanCallback([=](DiffTraversal::VisibleElement& next) {
|
||||
next.element->forEachEntity([=](EntityItemPointer entity) {
|
||||
// Bail early if we've already checked this entity this frame
|
||||
if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) {
|
||||
return;
|
||||
}
|
||||
bool success = false;
|
||||
AACube cube = entity->getQueryAACube(success);
|
||||
if (success) {
|
||||
if (_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) {
|
||||
// Check the size of the entity, it's possible that a "too small to see" entity is included in a
|
||||
// larger octree cell because of its position (for example if it crosses the boundary of a cell it
|
||||
// pops to the next higher cell. So we want to check to see that the entity is large enough to be seen
|
||||
// before we consider including it.
|
||||
float distance = glm::distance(cube.calcCenter(), viewPosition) + MIN_VISIBLE_DISTANCE;
|
||||
float angularDiameter = cube.getScale() / distance;
|
||||
if (angularDiameter > MIN_ENTITY_ANGULAR_DIAMETER * lodScaleFactor) {
|
||||
float priority = _conicalView.computePriority(cube);
|
||||
_sendQueue.push(PrioritizedEntity(entity, priority));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
_traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) {
|
||||
next.element->forEachEntity([this](EntityItemPointer entity) {
|
||||
// Bail early if we've already checked this entity this frame
|
||||
if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) {
|
||||
return;
|
||||
}
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
});
|
||||
});
|
||||
}
|
||||
break;
|
||||
case DiffTraversal::Repeat:
|
||||
if (usesViewFrustum) {
|
||||
float lodScaleFactor = _traversal.getCurrentLODScaleFactor();
|
||||
glm::vec3 viewPosition = _traversal.getCurrentView().getPosition();
|
||||
_traversal.setScanCallback([=](DiffTraversal::VisibleElement& next) {
|
||||
uint64_t startOfCompletedTraversal = _traversal.getStartOfCompletedTraversal();
|
||||
if (next.element->getLastChangedContent() > startOfCompletedTraversal) {
|
||||
next.element->forEachEntity([=](EntityItemPointer entity) {
|
||||
// Bail early if we've already checked this entity this frame
|
||||
if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) {
|
||||
return;
|
||||
}
|
||||
auto knownTimestamp = _knownState.find(entity.get());
|
||||
if (knownTimestamp == _knownState.end()) {
|
||||
bool success = false;
|
||||
AACube cube = entity->getQueryAACube(success);
|
||||
if (success) {
|
||||
if (next.intersection == ViewFrustum::INSIDE || _traversal.getCurrentView().cubeIntersectsKeyhole(cube)) {
|
||||
// See the DiffTraversal::First case for an explanation of the "entity is too small" check
|
||||
float distance = glm::distance(cube.calcCenter(), viewPosition) + MIN_VISIBLE_DISTANCE;
|
||||
float angularDiameter = cube.getScale() / distance;
|
||||
if (angularDiameter > MIN_ENTITY_ANGULAR_DIAMETER * lodScaleFactor) {
|
||||
float priority = _conicalView.computePriority(cube);
|
||||
_sendQueue.push(PrioritizedEntity(entity, priority));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
}
|
||||
} else if (entity->getLastEdited() > knownTimestamp->second
|
||||
|| entity->getLastChangedOnServer() > knownTimestamp->second) {
|
||||
// it is known and it changed --> put it on the queue with any priority
|
||||
// TODO: sort these correctly
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
_traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) {
|
||||
uint64_t startOfCompletedTraversal = _traversal.getStartOfCompletedTraversal();
|
||||
if (next.element->getLastChangedContent() > startOfCompletedTraversal) {
|
||||
next.element->forEachEntity([this](EntityItemPointer entity) {
|
||||
// Bail early if we've already checked this entity this frame
|
||||
if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) {
|
||||
return;
|
||||
}
|
||||
auto knownTimestamp = _knownState.find(entity.get());
|
||||
if (knownTimestamp == _knownState.end()
|
||||
|| entity->getLastEdited() > knownTimestamp->second
|
||||
|| entity->getLastChangedOnServer() > knownTimestamp->second) {
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case DiffTraversal::Differential:
|
||||
assert(usesViewFrustum);
|
||||
float lodScaleFactor = _traversal.getCurrentLODScaleFactor();
|
||||
glm::vec3 viewPosition = _traversal.getCurrentView().getPosition();
|
||||
float completedLODScaleFactor = _traversal.getCompletedLODScaleFactor();
|
||||
glm::vec3 completedViewPosition = _traversal.getCompletedView().getPosition();
|
||||
_traversal.setScanCallback([=] (DiffTraversal::VisibleElement& next) {
|
||||
next.element->forEachEntity([=](EntityItemPointer entity) {
|
||||
_traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) {
|
||||
next.element->forEachEntity([&](EntityItemPointer entity) {
|
||||
// Bail early if we've already checked this entity this frame
|
||||
if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) {
|
||||
if (_sendQueue.contains(entity.get())) {
|
||||
return;
|
||||
}
|
||||
float priority = PrioritizedEntity::DO_NOT_SEND;
|
||||
|
||||
|
||||
bool success = false;
|
||||
AACube cube = entity->getQueryAACube(success);
|
||||
if (success) {
|
||||
const auto& view = _traversal.getCurrentView();
|
||||
// Check the size of the entity, it's possible that a "too small to see" entity is included in a
|
||||
// larger octree cell because of its position (for example if it crosses the boundary of a cell it
|
||||
// pops to the next higher cell. So we want to check to see that the entity is large enough to be seen
|
||||
// before we consider including it.
|
||||
if ((next.intersection == ViewFrustum::INSIDE || view.intersects(cube)) &&
|
||||
view.isBigEnough(cube)) {
|
||||
priority = _conicalView.computePriority(cube);
|
||||
}
|
||||
} else {
|
||||
priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY;
|
||||
}
|
||||
|
||||
|
||||
if (priority != PrioritizedEntity::DO_NOT_SEND) {
|
||||
_sendQueue.emplace(entity, priority);
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
case DiffTraversal::Repeat:
|
||||
_traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) {
|
||||
uint64_t startOfCompletedTraversal = _traversal.getStartOfCompletedTraversal();
|
||||
if (next.element->getLastChangedContent() > startOfCompletedTraversal) {
|
||||
next.element->forEachEntity([&](EntityItemPointer entity) {
|
||||
// Bail early if we've already checked this entity this frame
|
||||
if (_sendQueue.contains(entity.get())) {
|
||||
return;
|
||||
}
|
||||
float priority = PrioritizedEntity::DO_NOT_SEND;
|
||||
|
||||
|
||||
auto knownTimestamp = _knownState.find(entity.get());
|
||||
if (knownTimestamp == _knownState.end()) {
|
||||
bool success = false;
|
||||
AACube cube = entity->getQueryAACube(success);
|
||||
if (success) {
|
||||
const auto& view = _traversal.getCurrentView();
|
||||
// See the DiffTraversal::First case for an explanation of the "entity is too small" check
|
||||
if ((next.intersection == ViewFrustum::INSIDE || view.intersects(cube)) &&
|
||||
view.isBigEnough(cube)) {
|
||||
priority = _conicalView.computePriority(cube);
|
||||
}
|
||||
} else {
|
||||
priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY;
|
||||
}
|
||||
} else if (entity->getLastEdited() > knownTimestamp->second ||
|
||||
entity->getLastChangedOnServer() > knownTimestamp->second) {
|
||||
// it is known and it changed --> put it on the queue with any priority
|
||||
// TODO: sort these correctly
|
||||
priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY;
|
||||
}
|
||||
|
||||
|
||||
if (priority != PrioritizedEntity::DO_NOT_SEND) {
|
||||
_sendQueue.emplace(entity, priority);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case DiffTraversal::Differential:
|
||||
assert(view.usesViewFrustums());
|
||||
_traversal.setScanCallback([this] (DiffTraversal::VisibleElement& next) {
|
||||
next.element->forEachEntity([&](EntityItemPointer entity) {
|
||||
// Bail early if we've already checked this entity this frame
|
||||
if (_sendQueue.contains(entity.get())) {
|
||||
return;
|
||||
}
|
||||
float priority = PrioritizedEntity::DO_NOT_SEND;
|
||||
|
||||
|
||||
auto knownTimestamp = _knownState.find(entity.get());
|
||||
if (knownTimestamp == _knownState.end()) {
|
||||
bool success = false;
|
||||
AACube cube = entity->getQueryAACube(success);
|
||||
if (success) {
|
||||
if (_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) {
|
||||
// See the DiffTraversal::First case for an explanation of the "entity is too small" check
|
||||
float distance = glm::distance(cube.calcCenter(), viewPosition) + MIN_VISIBLE_DISTANCE;
|
||||
float angularDiameter = cube.getScale() / distance;
|
||||
if (angularDiameter > MIN_ENTITY_ANGULAR_DIAMETER * lodScaleFactor) {
|
||||
if (!_traversal.getCompletedView().cubeIntersectsKeyhole(cube)) {
|
||||
float priority = _conicalView.computePriority(cube);
|
||||
_sendQueue.push(PrioritizedEntity(entity, priority));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
} else {
|
||||
// If this entity was skipped last time because it was too small, we still need to send it
|
||||
distance = glm::distance(cube.calcCenter(), completedViewPosition) + MIN_VISIBLE_DISTANCE;
|
||||
angularDiameter = cube.getScale() / distance;
|
||||
if (angularDiameter <= MIN_ENTITY_ANGULAR_DIAMETER * completedLODScaleFactor) {
|
||||
// this object was skipped in last completed traversal
|
||||
float priority = _conicalView.computePriority(cube);
|
||||
_sendQueue.push(PrioritizedEntity(entity, priority));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
const auto& view = _traversal.getCurrentView();
|
||||
// See the DiffTraversal::First case for an explanation of the "entity is too small" check
|
||||
if ((next.intersection == ViewFrustum::INSIDE || view.intersects(cube)) &&
|
||||
view.isBigEnough(cube)) {
|
||||
priority = _conicalView.computePriority(cube);
|
||||
}
|
||||
} else {
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY;
|
||||
}
|
||||
} else if (entity->getLastEdited() > knownTimestamp->second
|
||||
|| entity->getLastChangedOnServer() > knownTimestamp->second) {
|
||||
} else if (entity->getLastEdited() > knownTimestamp->second ||
|
||||
entity->getLastChangedOnServer() > knownTimestamp->second) {
|
||||
// it is known and it changed --> put it on the queue with any priority
|
||||
// TODO: sort these correctly
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY;
|
||||
}
|
||||
|
||||
|
||||
if (priority != PrioritizedEntity::DO_NOT_SEND) {
|
||||
_sendQueue.emplace(entity, priority);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -479,11 +441,10 @@ bool EntityTreeSendThread::traverseTreeAndBuildNextPacketPayload(EncodeBitstream
|
|||
}
|
||||
}
|
||||
_sendQueue.pop();
|
||||
_entitiesInQueue.erase(entity.get());
|
||||
}
|
||||
nodeData->stats.encodeStopped();
|
||||
if (_sendQueue.empty()) {
|
||||
assert(_entitiesInQueue.empty());
|
||||
assert(_sendQueue.empty());
|
||||
params.stopReason = EncodeBitstreamParams::FINISHED;
|
||||
_extraEncodeData->entities.clear();
|
||||
}
|
||||
|
@ -501,18 +462,16 @@ bool EntityTreeSendThread::traverseTreeAndBuildNextPacketPayload(EncodeBitstream
|
|||
|
||||
void EntityTreeSendThread::editingEntityPointer(const EntityItemPointer& entity) {
|
||||
if (entity) {
|
||||
if (_entitiesInQueue.find(entity.get()) == _entitiesInQueue.end() && _knownState.find(entity.get()) != _knownState.end()) {
|
||||
if (!_sendQueue.contains(entity.get()) && _knownState.find(entity.get()) != _knownState.end()) {
|
||||
bool success = false;
|
||||
AACube cube = entity->getQueryAACube(success);
|
||||
if (success) {
|
||||
// We can force a removal from _knownState if the current view is used and entity is out of view
|
||||
if (_traversal.doesCurrentUseViewFrustum() && !_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) {
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::FORCE_REMOVE, true));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
if (_traversal.doesCurrentUseViewFrustum() && !_traversal.getCurrentView().intersects(cube)) {
|
||||
_sendQueue.emplace(entity, PrioritizedEntity::FORCE_REMOVE, true);
|
||||
}
|
||||
} else {
|
||||
_sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY, true));
|
||||
_entitiesInQueue.insert(entity.get());
|
||||
_sendQueue.emplace(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,7 @@ private:
|
|||
bool addAncestorsToExtraFlaggedEntities(const QUuid& filteredEntityID, EntityItem& entityItem, EntityNodeData& nodeData);
|
||||
bool addDescendantsToExtraFlaggedEntities(const QUuid& filteredEntityID, EntityItem& entityItem, EntityNodeData& nodeData);
|
||||
|
||||
void startNewTraversal(const ViewFrustum& viewFrustum, EntityTreeElementPointer root, int32_t lodLevelOffset,
|
||||
bool usesViewFrustum);
|
||||
void startNewTraversal(const DiffTraversal::View& viewFrustum, EntityTreeElementPointer root);
|
||||
bool traverseTreeAndBuildNextPacketPayload(EncodeBitstreamParams& params, const QJsonObject& jsonFilters) override;
|
||||
|
||||
void preDistributionProcessing() override;
|
||||
|
@ -51,7 +50,6 @@ private:
|
|||
|
||||
DiffTraversal _traversal;
|
||||
EntityPriorityQueue _sendQueue;
|
||||
std::unordered_set<EntityItem*> _entitiesInQueue;
|
||||
std::unordered_map<EntityItem*, uint64_t> _knownState;
|
||||
ConicalView _conicalView; // cached optimized view for fast priority calculations
|
||||
|
||||
|
|
|
@ -14,32 +14,18 @@
|
|||
#include <NodeList.h>
|
||||
#include <OctreeLogging.h>
|
||||
|
||||
|
||||
OctreeHeadlessViewer::OctreeHeadlessViewer() {
|
||||
_viewFrustum.setProjection(glm::perspective(glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES), DEFAULT_ASPECT_RATIO, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));
|
||||
}
|
||||
|
||||
void OctreeHeadlessViewer::queryOctree() {
|
||||
char serverType = getMyNodeType();
|
||||
PacketType packetType = getMyQueryMessageType();
|
||||
|
||||
_octreeQuery.setCameraPosition(_viewFrustum.getPosition());
|
||||
_octreeQuery.setCameraOrientation(_viewFrustum.getOrientation());
|
||||
_octreeQuery.setCameraFov(_viewFrustum.getFieldOfView());
|
||||
_octreeQuery.setCameraAspectRatio(_viewFrustum.getAspectRatio());
|
||||
_octreeQuery.setCameraNearClip(_viewFrustum.getNearClip());
|
||||
_octreeQuery.setCameraFarClip(_viewFrustum.getFarClip());
|
||||
_octreeQuery.setCameraEyeOffsetPosition(glm::vec3());
|
||||
_octreeQuery.setCameraCenterRadius(_viewFrustum.getCenterRadius());
|
||||
_octreeQuery.setOctreeSizeScale(_voxelSizeScale);
|
||||
_octreeQuery.setBoundaryLevelAdjust(_boundaryLevelAdjust);
|
||||
if (_hasViewFrustum) {
|
||||
_octreeQuery.setMainViewFrustum(_viewFrustum);
|
||||
}
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
auto node = nodeList->soloNodeOfType(serverType);
|
||||
if (node && node->getActiveSocket()) {
|
||||
_octreeQuery.setMaxQueryPacketsPerSecond(getMaxPacketsPerSecond());
|
||||
|
||||
auto queryPacket = NLPacket::create(packetType);
|
||||
|
||||
// encode the query data
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
class OctreeHeadlessViewer : public OctreeProcessor {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OctreeHeadlessViewer();
|
||||
virtual ~OctreeHeadlessViewer() {};
|
||||
|
||||
OctreeQuery& getOctreeQuery() { return _octreeQuery; }
|
||||
|
||||
static int parseOctreeStats(QSharedPointer<ReceivedMessage> message, SharedNodePointer sourceNode);
|
||||
|
@ -32,34 +29,32 @@ public slots:
|
|||
void queryOctree();
|
||||
|
||||
// setters for camera attributes
|
||||
void setPosition(const glm::vec3& position) { _viewFrustum.setPosition(position); }
|
||||
void setOrientation(const glm::quat& orientation) { _viewFrustum.setOrientation(orientation); }
|
||||
void setCenterRadius(float radius) { _viewFrustum.setCenterRadius(radius); }
|
||||
void setKeyholeRadius(float radius) { _viewFrustum.setCenterRadius(radius); } // TODO: remove this legacy support
|
||||
void setPosition(const glm::vec3& position) { _hasViewFrustum = true; _viewFrustum.setPosition(position); }
|
||||
void setOrientation(const glm::quat& orientation) { _hasViewFrustum = true; _viewFrustum.setOrientation(orientation); }
|
||||
void setCenterRadius(float radius) { _hasViewFrustum = true; _viewFrustum.setCenterRadius(radius); }
|
||||
void setKeyholeRadius(float radius) { _hasViewFrustum = true; _viewFrustum.setCenterRadius(radius); } // TODO: remove this legacy support
|
||||
|
||||
// setters for LOD and PPS
|
||||
void setVoxelSizeScale(float sizeScale) { _voxelSizeScale = sizeScale; }
|
||||
void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; }
|
||||
void setMaxPacketsPerSecond(int maxPacketsPerSecond) { _maxPacketsPerSecond = maxPacketsPerSecond; }
|
||||
void setVoxelSizeScale(float sizeScale) { _octreeQuery.setOctreeSizeScale(sizeScale) ; }
|
||||
void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _octreeQuery.setBoundaryLevelAdjust(boundaryLevelAdjust); }
|
||||
void setMaxPacketsPerSecond(int maxPacketsPerSecond) { _octreeQuery.setMaxQueryPacketsPerSecond(maxPacketsPerSecond); }
|
||||
|
||||
// getters for camera attributes
|
||||
const glm::vec3& getPosition() const { return _viewFrustum.getPosition(); }
|
||||
const glm::quat& getOrientation() const { return _viewFrustum.getOrientation(); }
|
||||
|
||||
// getters for LOD and PPS
|
||||
float getVoxelSizeScale() const { return _voxelSizeScale; }
|
||||
int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; }
|
||||
int getMaxPacketsPerSecond() const { return _maxPacketsPerSecond; }
|
||||
float getVoxelSizeScale() const { return _octreeQuery.getOctreeSizeScale(); }
|
||||
int getBoundaryLevelAdjust() const { return _octreeQuery.getBoundaryLevelAdjust(); }
|
||||
int getMaxPacketsPerSecond() const { return _octreeQuery.getMaxQueryPacketsPerSecond(); }
|
||||
|
||||
unsigned getOctreeElementsCount() const { return _tree->getOctreeElementsCount(); }
|
||||
|
||||
private:
|
||||
OctreeQuery _octreeQuery;
|
||||
|
||||
bool _hasViewFrustum { false };
|
||||
ViewFrustum _viewFrustum;
|
||||
float _voxelSizeScale { DEFAULT_OCTREE_SIZE_SCALE };
|
||||
int _boundaryLevelAdjust { 0 };
|
||||
int _maxPacketsPerSecond { DEFAULT_MAX_OCTREE_PPS };
|
||||
};
|
||||
|
||||
#endif // hifi_OctreeHeadlessViewer_h
|
||||
|
|
|
@ -330,8 +330,9 @@ int OctreeSendThread::packetDistributor(SharedNodePointer node, OctreeQueryNode*
|
|||
} else {
|
||||
// we aren't forcing a full scene, check if something else suggests we should
|
||||
isFullScene = nodeData->haveJSONParametersChanged() ||
|
||||
(nodeData->getUsesFrustum()
|
||||
&& ((!viewFrustumChanged && nodeData->getViewFrustumJustStoppedChanging()) || nodeData->hasLodChanged()));
|
||||
(nodeData->hasMainViewFrustum() &&
|
||||
(nodeData->getViewFrustumJustStoppedChanging() ||
|
||||
nodeData->hasLodChanged()));
|
||||
}
|
||||
|
||||
if (nodeData->isPacketWaiting()) {
|
||||
|
@ -445,7 +446,6 @@ void OctreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, Octre
|
|||
params.trackSend = [this](const QUuid& dataID, quint64 dataEdited) {
|
||||
_myServer->trackSend(dataID, dataEdited, _nodeUuid);
|
||||
};
|
||||
nodeData->copyCurrentViewFrustum(params.viewFrustum);
|
||||
|
||||
bool somethingToSend = true; // assume we have something
|
||||
bool hadSomething = hasSomethingToSend(nodeData);
|
||||
|
|
|
@ -294,7 +294,6 @@ void EntityScriptServer::run() {
|
|||
queryJSONParameters[EntityJSONQueryProperties::FLAGS_PROPERTY] = queryFlags;
|
||||
|
||||
// setup the JSON parameters so that OctreeQuery does not use a frustum and uses our JSON filter
|
||||
_entityViewer.getOctreeQuery().setUsesFrustum(false);
|
||||
_entityViewer.getOctreeQuery().setJSONParameters(queryJSONParameters);
|
||||
|
||||
entityScriptingInterface->setEntityTree(_entityViewer.getTree());
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<span class='step-description'>
|
||||
<a target='_blank' href='https://docs.highfidelity.com/create-and-explore/start-working-in-your-sandbox/place-names'>Place names</a> are similar to web addresses. Users who want to visit your domain can
|
||||
enter its Place Name in High Fidelity's Interface. You can choose a Place Name for your domain.</br>
|
||||
People can also use your <b>domain's IP address (shown below)</b> to visit your High Fidelity domain.
|
||||
Your domain may also be reachable by <b>IP address</b>.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -35,10 +35,10 @@
|
|||
<div class="centered-hack-parent">
|
||||
<div id="place-name-group" class="centered-hack">
|
||||
<p id="place-name-link"></p>
|
||||
<div id="place-name-edit">
|
||||
<span class='glyphicon glyphicon-pencil'></span>
|
||||
<a href="#" id="change-place-name">Choose a custom Place Name instead</a>
|
||||
</div>
|
||||
<div id="place-name-edit">
|
||||
<span class='glyphicon glyphicon-pencil'></span>
|
||||
<a href="#" id="change-place-name">Choose a custom Place Name instead</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -729,7 +729,7 @@ Rectangle {
|
|||
}
|
||||
lightboxPopup.button2text = "CONFIRM";
|
||||
lightboxPopup.button2method = function() {
|
||||
MyAvatar.skeletonModelURL = '';
|
||||
MyAvatar.useFullAvatarURL('');
|
||||
root.activeView = "giftAsset";
|
||||
lightboxPopup.visible = false;
|
||||
};
|
||||
|
|
|
@ -5240,6 +5240,78 @@ void Application::updateDialogs(float deltaTime) const {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::updateSecondaryCameraViewFrustum() {
|
||||
// TODO: Fix this by modeling the way the secondary camera works on how the main camera works
|
||||
// ie. Use a camera object stored in the game logic and informs the Engine on where the secondary
|
||||
// camera should be.
|
||||
|
||||
// Code based on SecondaryCameraJob
|
||||
auto renderConfig = _renderEngine->getConfiguration();
|
||||
assert(renderConfig);
|
||||
auto camera = dynamic_cast<SecondaryCameraJobConfig*>(renderConfig->getConfig("SecondaryCamera"));
|
||||
assert(camera);
|
||||
|
||||
if (!camera->isEnabled()) {
|
||||
_hasSecondaryViewFrustum = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (camera->mirrorProjection && !camera->attachedEntityId.isNull()) {
|
||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||
auto entityProperties = entityScriptingInterface->getEntityProperties(camera->attachedEntityId);
|
||||
glm::vec3 mirrorPropertiesPosition = entityProperties.getPosition();
|
||||
glm::quat mirrorPropertiesRotation = entityProperties.getRotation();
|
||||
glm::vec3 mirrorPropertiesDimensions = entityProperties.getDimensions();
|
||||
glm::vec3 halfMirrorPropertiesDimensions = 0.5f * mirrorPropertiesDimensions;
|
||||
|
||||
// setup mirror from world as inverse of world from mirror transformation using inverted x and z for mirrored image
|
||||
// TODO: we are assuming here that UP is world y-axis
|
||||
glm::mat4 worldFromMirrorRotation = glm::mat4_cast(mirrorPropertiesRotation) * glm::scale(vec3(-1.0f, 1.0f, -1.0f));
|
||||
glm::mat4 worldFromMirrorTranslation = glm::translate(mirrorPropertiesPosition);
|
||||
glm::mat4 worldFromMirror = worldFromMirrorTranslation * worldFromMirrorRotation;
|
||||
glm::mat4 mirrorFromWorld = glm::inverse(worldFromMirror);
|
||||
|
||||
// get mirror camera position by reflecting main camera position's z coordinate in mirror space
|
||||
glm::vec3 mainCameraPositionWorld = getCamera().getPosition();
|
||||
glm::vec3 mainCameraPositionMirror = vec3(mirrorFromWorld * vec4(mainCameraPositionWorld, 1.0f));
|
||||
glm::vec3 mirrorCameraPositionMirror = vec3(mainCameraPositionMirror.x, mainCameraPositionMirror.y,
|
||||
-mainCameraPositionMirror.z);
|
||||
glm::vec3 mirrorCameraPositionWorld = vec3(worldFromMirror * vec4(mirrorCameraPositionMirror, 1.0f));
|
||||
|
||||
// set frustum position to be mirrored camera and set orientation to mirror's adjusted rotation
|
||||
glm::quat mirrorCameraOrientation = glm::quat_cast(worldFromMirrorRotation);
|
||||
_secondaryViewFrustum.setPosition(mirrorCameraPositionWorld);
|
||||
_secondaryViewFrustum.setOrientation(mirrorCameraOrientation);
|
||||
|
||||
// build frustum using mirror space translation of mirrored camera
|
||||
float nearClip = mirrorCameraPositionMirror.z + mirrorPropertiesDimensions.z * 2.0f;
|
||||
glm::vec3 upperRight = halfMirrorPropertiesDimensions - mirrorCameraPositionMirror;
|
||||
glm::vec3 bottomLeft = -halfMirrorPropertiesDimensions - mirrorCameraPositionMirror;
|
||||
glm::mat4 frustum = glm::frustum(bottomLeft.x, upperRight.x, bottomLeft.y, upperRight.y, nearClip, camera->farClipPlaneDistance);
|
||||
_secondaryViewFrustum.setProjection(frustum);
|
||||
} else {
|
||||
if (!camera->attachedEntityId.isNull()) {
|
||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||
auto entityProperties = entityScriptingInterface->getEntityProperties(camera->attachedEntityId);
|
||||
_secondaryViewFrustum.setPosition(entityProperties.getPosition());
|
||||
_secondaryViewFrustum.setOrientation(entityProperties.getRotation());
|
||||
} else {
|
||||
_secondaryViewFrustum.setPosition(camera->position);
|
||||
_secondaryViewFrustum.setOrientation(camera->orientation);
|
||||
}
|
||||
|
||||
float aspectRatio = (float)camera->textureWidth / (float)camera->textureHeight;
|
||||
_secondaryViewFrustum.setProjection(camera->vFoV,
|
||||
aspectRatio,
|
||||
camera->nearClipPlaneDistance,
|
||||
camera->farClipPlaneDistance);
|
||||
}
|
||||
// Without calculating the bound planes, the secondary camera will use the same culling frustum as the main camera,
|
||||
// which is not what we want here.
|
||||
_secondaryViewFrustum.calculate();
|
||||
_hasSecondaryViewFrustum = true;
|
||||
}
|
||||
|
||||
static bool domainLoadingInProgress = false;
|
||||
|
||||
void Application::update(float deltaTime) {
|
||||
|
@ -5593,6 +5665,11 @@ void Application::update(float deltaTime) {
|
|||
{
|
||||
QMutexLocker viewLocker(&_viewMutex);
|
||||
_myCamera.loadViewFrustum(_viewFrustum);
|
||||
|
||||
// TODO: Fix this by modeling the way the secondary camera works on how the main camera works
|
||||
// ie. Use a camera object stored in the game logic and informs the Engine on where the secondary
|
||||
// camera should be.
|
||||
updateSecondaryCameraViewFrustum();
|
||||
}
|
||||
|
||||
quint64 now = usecTimestampNow();
|
||||
|
@ -5606,6 +5683,8 @@ void Application::update(float deltaTime) {
|
|||
const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND;
|
||||
bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY;
|
||||
bool viewIsDifferentEnough = !_lastQueriedViewFrustum.isVerySimilar(_viewFrustum);
|
||||
viewIsDifferentEnough |= _hasSecondaryViewFrustum && !_lastQueriedSecondaryViewFrustum.isVerySimilar(_secondaryViewFrustum);
|
||||
|
||||
// if it's been a while since our last query or the view has significantly changed then send a query, otherwise suppress it
|
||||
if (queryIsDue || viewIsDifferentEnough) {
|
||||
_lastQueriedTime = now;
|
||||
|
@ -5614,6 +5693,7 @@ void Application::update(float deltaTime) {
|
|||
}
|
||||
sendAvatarViewFrustum();
|
||||
_lastQueriedViewFrustum = _viewFrustum;
|
||||
_lastQueriedSecondaryViewFrustum = _secondaryViewFrustum;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5786,8 +5866,16 @@ void Application::update(float deltaTime) {
|
|||
}
|
||||
|
||||
void Application::sendAvatarViewFrustum() {
|
||||
uint8_t numFrustums = 1;
|
||||
QByteArray viewFrustumByteArray = _viewFrustum.toByteArray();
|
||||
auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size());
|
||||
|
||||
if (_hasSecondaryViewFrustum) {
|
||||
++numFrustums;
|
||||
viewFrustumByteArray += _secondaryViewFrustum.toByteArray();
|
||||
}
|
||||
|
||||
auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size() + sizeof(numFrustums));
|
||||
avatarPacket->writePrimitive(numFrustums);
|
||||
avatarPacket->write(viewFrustumByteArray);
|
||||
|
||||
DependencyManager::get<NodeList>()->broadcastToNodes(std::move(avatarPacket), NodeSet() << NodeType::AvatarMixer);
|
||||
|
@ -5852,14 +5940,15 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType) {
|
|||
|
||||
ViewFrustum viewFrustum;
|
||||
copyViewFrustum(viewFrustum);
|
||||
_octreeQuery.setCameraPosition(viewFrustum.getPosition());
|
||||
_octreeQuery.setCameraOrientation(viewFrustum.getOrientation());
|
||||
_octreeQuery.setCameraFov(viewFrustum.getFieldOfView());
|
||||
_octreeQuery.setCameraAspectRatio(viewFrustum.getAspectRatio());
|
||||
_octreeQuery.setCameraNearClip(viewFrustum.getNearClip());
|
||||
_octreeQuery.setCameraFarClip(viewFrustum.getFarClip());
|
||||
_octreeQuery.setCameraEyeOffsetPosition(glm::vec3());
|
||||
_octreeQuery.setCameraCenterRadius(viewFrustum.getCenterRadius());
|
||||
_octreeQuery.setMainViewFrustum(viewFrustum);
|
||||
|
||||
if (hasSecondaryViewFrustum()) {
|
||||
copySecondaryViewFrustum(viewFrustum);
|
||||
_octreeQuery.setSecondaryViewFrustum(viewFrustum);
|
||||
} else {
|
||||
_octreeQuery.clearSecondaryViewFrustum();
|
||||
}
|
||||
|
||||
auto lodManager = DependencyManager::get<LODManager>();
|
||||
_octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale());
|
||||
_octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust());
|
||||
|
@ -5943,6 +6032,11 @@ void Application::copyDisplayViewFrustum(ViewFrustum& viewOut) const {
|
|||
viewOut = _displayViewFrustum;
|
||||
}
|
||||
|
||||
void Application::copySecondaryViewFrustum(ViewFrustum& viewOut) const {
|
||||
QMutexLocker viewLocker(&_viewMutex);
|
||||
viewOut = _secondaryViewFrustum;
|
||||
}
|
||||
|
||||
void Application::resetSensors(bool andReload) {
|
||||
DependencyManager::get<DdeFaceTracker>()->reset();
|
||||
DependencyManager::get<EyeTracker>()->reset();
|
||||
|
|
|
@ -149,6 +149,8 @@ public:
|
|||
void initializeRenderEngine();
|
||||
void initializeUi();
|
||||
|
||||
void updateSecondaryCameraViewFrustum();
|
||||
|
||||
void updateCamera(RenderArgs& renderArgs, float deltaTime);
|
||||
void paintGL();
|
||||
void resizeGL();
|
||||
|
@ -173,11 +175,14 @@ public:
|
|||
Camera& getCamera() { return _myCamera; }
|
||||
const Camera& getCamera() const { return _myCamera; }
|
||||
// Represents the current view frustum of the avatar.
|
||||
void copyViewFrustum(ViewFrustum& viewOut) const;
|
||||
void copyViewFrustum(ViewFrustum& viewOut) const override;
|
||||
void copySecondaryViewFrustum(ViewFrustum& viewOut) const override;
|
||||
bool hasSecondaryViewFrustum() const override { return _hasSecondaryViewFrustum; }
|
||||
// Represents the view frustum of the current rendering pass,
|
||||
// which might be different from the viewFrustum, i.e. shadowmap
|
||||
// passes, mirror window passes, etc
|
||||
void copyDisplayViewFrustum(ViewFrustum& viewOut) const;
|
||||
|
||||
const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; }
|
||||
QSharedPointer<EntityTreeRenderer> getEntities() const { return DependencyManager::get<EntityTreeRenderer>(); }
|
||||
QUndoStack* getUndoStack() { return &_undoStack; }
|
||||
|
@ -565,8 +570,11 @@ private:
|
|||
|
||||
mutable QMutex _viewMutex { QMutex::Recursive };
|
||||
ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc.
|
||||
ViewFrustum _lastQueriedViewFrustum; /// last view frustum used to query octree servers (voxels)
|
||||
ViewFrustum _lastQueriedViewFrustum; // last view frustum used to query octree servers
|
||||
ViewFrustum _displayViewFrustum;
|
||||
ViewFrustum _secondaryViewFrustum;
|
||||
ViewFrustum _lastQueriedSecondaryViewFrustum; // last secondary view frustum used to query octree servers
|
||||
bool _hasSecondaryViewFrustum;
|
||||
quint64 _lastQueriedTime;
|
||||
|
||||
OctreeQuery _octreeQuery { true }; // NodeData derived class for querying octee cells from octree servers
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
/**jsdoc
|
||||
* This API helps manage adding and deleting avatar bookmarks.
|
||||
* @namespace AvatarBookmarks
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
*/
|
||||
|
||||
class AvatarBookmarks: public Bookmarks, public Dependency {
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include "Crashpad.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#if HAS_CRASHPAD
|
||||
|
@ -20,7 +22,7 @@
|
|||
#include <QStandardPaths>
|
||||
#include <QDir>
|
||||
|
||||
#include <BuildInfo.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include <client/crashpad_client.h>
|
||||
#include <client/crash_report_database.h>
|
||||
|
@ -28,28 +30,27 @@
|
|||
#include <client/annotation_list.h>
|
||||
#include <client/crashpad_info.h>
|
||||
|
||||
#include <BuildInfo.h>
|
||||
|
||||
using namespace crashpad;
|
||||
|
||||
static const std::string BACKTRACE_URL { CMAKE_BACKTRACE_URL };
|
||||
static const std::string BACKTRACE_TOKEN { CMAKE_BACKTRACE_TOKEN };
|
||||
|
||||
static std::wstring gIPCPipe;
|
||||
|
||||
extern QString qAppFileName();
|
||||
|
||||
CrashpadClient* client { nullptr };
|
||||
std::mutex annotationMutex;
|
||||
crashpad::SimpleStringDictionary* crashpadAnnotations { nullptr };
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
LONG WINAPI vectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) {
|
||||
if (!client) {
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
if (pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_HEAP_CORRUPTION ||
|
||||
pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_STACK_BUFFER_OVERRUN) {
|
||||
CrashpadClient client;
|
||||
if (gIPCPipe.length()) {
|
||||
client.SetHandlerIPCPipe(gIPCPipe);
|
||||
}
|
||||
client.DumpAndCrash(pExceptionInfo);
|
||||
client->DumpAndCrash(pExceptionInfo);
|
||||
}
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
@ -60,7 +61,8 @@ bool startCrashHandler() {
|
|||
return false;
|
||||
}
|
||||
|
||||
CrashpadClient client;
|
||||
assert(!client);
|
||||
client = new CrashpadClient();
|
||||
std::vector<std::string> arguments;
|
||||
|
||||
std::map<std::string, std::string> annotations;
|
||||
|
@ -96,12 +98,9 @@ bool startCrashHandler() {
|
|||
// Enable automated uploads.
|
||||
database->GetSettings()->SetUploadsEnabled(true);
|
||||
|
||||
bool result = client.StartHandler(handler, db, db, BACKTRACE_URL, annotations, arguments, true, true);
|
||||
gIPCPipe = client.GetHandlerIPCPipe();
|
||||
|
||||
AddVectoredExceptionHandler(0, vectoredExceptionHandler);
|
||||
|
||||
return result;
|
||||
return client->StartHandler(handler, db, db, BACKTRACE_URL, annotations, arguments, true, true);
|
||||
}
|
||||
|
||||
void setCrashAnnotation(std::string name, std::string value) {
|
||||
|
|
|
@ -37,6 +37,10 @@ class AABox;
|
|||
/**jsdoc
|
||||
* The LOD class manages your Level of Detail functions within Interface.
|
||||
* @namespace LODManager
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {number} presentTime <em>Read-only.</em>
|
||||
* @property {number} engineRunTime <em>Read-only.</em>
|
||||
* @property {number} gpuTime <em>Read-only.</em>
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
/**jsdoc
|
||||
* @namespace SpeechRecognizer
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
class SpeechRecognizer : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -28,6 +28,10 @@ class AudioScope : public QObject, public Dependency {
|
|||
/**jsdoc
|
||||
* The AudioScope API helps control the Audio Scope features in Interface
|
||||
* @namespace AudioScope
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {number} scopeInput <em>Read-only.</em>
|
||||
* @property {number} scopeOutputLeft <em>Read-only.</em>
|
||||
* @property {number} scopeOutputRight <em>Read-only.</em>
|
||||
|
|
|
@ -155,9 +155,19 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
|||
AvatarSharedPointer _avatar;
|
||||
};
|
||||
|
||||
ViewFrustum cameraView;
|
||||
qApp->copyDisplayViewFrustum(cameraView);
|
||||
PrioritySortUtil::PriorityQueue<SortableAvatar> sortedAvatars(cameraView,
|
||||
|
||||
ViewFrustums views;
|
||||
|
||||
ViewFrustum view;
|
||||
qApp->copyCurrentViewFrustum(view);
|
||||
views.push_back(view);
|
||||
|
||||
if (qApp->hasSecondaryViewFrustum()) {
|
||||
qApp->copySecondaryViewFrustum(view);
|
||||
views.push_back(view);
|
||||
}
|
||||
|
||||
PrioritySortUtil::PriorityQueue<SortableAvatar> sortedAvatars(views,
|
||||
AvatarData::_avatarSortCoefficientSize,
|
||||
AvatarData::_avatarSortCoefficientCenter,
|
||||
AvatarData::_avatarSortCoefficientAge);
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
/**jsdoc
|
||||
* The AvatarManager API has properties and methods which manage Avatars within the same domain.
|
||||
* @namespace AvatarManager
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
|
||||
class AvatarManager : public AvatarHashMap {
|
||||
|
|
|
@ -1486,6 +1486,15 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
|
|||
std::shared_ptr<QMetaObject::Connection> skeletonConnection = std::make_shared<QMetaObject::Connection>();
|
||||
*skeletonConnection = QObject::connect(_skeletonModel.get(), &SkeletonModel::skeletonLoaded, [this, skeletonModelChangeCount, skeletonConnection]() {
|
||||
if (skeletonModelChangeCount == _skeletonModelChangeCount) {
|
||||
|
||||
if (_fullAvatarModelName.isEmpty()) {
|
||||
// Store the FST file name into preferences
|
||||
const auto& mapping = _skeletonModel->getGeometry()->getMapping();
|
||||
if (mapping.value("name").isValid()) {
|
||||
_fullAvatarModelName = mapping.value("name").toString();
|
||||
}
|
||||
}
|
||||
|
||||
initHeadBones();
|
||||
_skeletonModel->setCauterizeBoneSet(_headBoneSet);
|
||||
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
||||
|
@ -1548,12 +1557,7 @@ void MyAvatar::useFullAvatarURL(const QUrl& fullAvatarURL, const QString& modelN
|
|||
|
||||
if (_fullAvatarURLFromPreferences != fullAvatarURL) {
|
||||
_fullAvatarURLFromPreferences = fullAvatarURL;
|
||||
if (modelName.isEmpty()) {
|
||||
QVariantHash fullAvatarFST = FSTReader::downloadMapping(_fullAvatarURLFromPreferences.toString());
|
||||
_fullAvatarModelName = fullAvatarFST["name"].toString();
|
||||
} else {
|
||||
_fullAvatarModelName = modelName;
|
||||
}
|
||||
_fullAvatarModelName = modelName;
|
||||
}
|
||||
|
||||
const QString& urlString = fullAvatarURL.toString();
|
||||
|
@ -1561,8 +1565,8 @@ void MyAvatar::useFullAvatarURL(const QUrl& fullAvatarURL, const QString& modelN
|
|||
setSkeletonModelURL(fullAvatarURL);
|
||||
UserActivityLogger::getInstance().changedModel("skeleton", urlString);
|
||||
}
|
||||
|
||||
markIdentityDataChanged();
|
||||
|
||||
}
|
||||
|
||||
void MyAvatar::setAttachmentData(const QVector<AttachmentData>& attachmentData) {
|
||||
|
@ -2050,12 +2054,14 @@ void MyAvatar::preDisplaySide(RenderArgs* renderArgs) {
|
|||
_attachmentData[i].jointName.compare("RightEye", Qt::CaseInsensitive) == 0 ||
|
||||
_attachmentData[i].jointName.compare("HeadTop_End", Qt::CaseInsensitive) == 0 ||
|
||||
_attachmentData[i].jointName.compare("Face", Qt::CaseInsensitive) == 0) {
|
||||
uint8_t modelRenderTagBits = shouldDrawHead ? render::ItemKey::TAG_BITS_0 : render::ItemKey::TAG_BITS_NONE;
|
||||
modelRenderTagBits |= render::ItemKey::TAG_BITS_1;
|
||||
_attachmentModels[i]->setVisibleInScene(true, qApp->getMain3DScene(),
|
||||
modelRenderTagBits, false);
|
||||
|
||||
_attachmentModels[i]->setVisibleInScene(shouldDrawHead, qApp->getMain3DScene(),
|
||||
render::ItemKey::TAG_BITS_NONE, true);
|
||||
|
||||
_attachmentModels[i]->setCanCastShadow(shouldDrawHead, qApp->getMain3DScene(),
|
||||
render::ItemKey::TAG_BITS_NONE, true);
|
||||
uint8_t castShadowRenderTagBits = render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1;
|
||||
_attachmentModels[i]->setCanCastShadow(true, qApp->getMain3DScene(),
|
||||
castShadowRenderTagBits, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ bool QmlCommerce::uninstallApp(const QString& itemHref) {
|
|||
// Read from the file to know what .js script to stop
|
||||
QFile appFile(_appsPath + "/" + appHref.fileName());
|
||||
if (!appFile.open(QIODevice::ReadOnly)) {
|
||||
qCDebug(commerce) << "Couldn't open local .app.json file for deletion.";
|
||||
qCDebug(commerce) << "Couldn't open local .app.json file for deletion. Cannot continue with app uninstallation. App filename is:" << appHref.fileName();
|
||||
return false;
|
||||
}
|
||||
QJsonDocument appFileJsonDocument = QJsonDocument::fromJson(appFile.readAll());
|
||||
|
@ -309,15 +309,13 @@ bool QmlCommerce::uninstallApp(const QString& itemHref) {
|
|||
QString scriptUrl = appFileJsonObject["scriptURL"].toString();
|
||||
|
||||
if (!DependencyManager::get<ScriptEngines>()->stopScript(scriptUrl.trimmed(), false)) {
|
||||
qCDebug(commerce) << "Couldn't stop script.";
|
||||
return false;
|
||||
qCWarning(commerce) << "Couldn't stop script during app uninstall. Continuing anyway. ScriptURL is:" << scriptUrl.trimmed();
|
||||
}
|
||||
|
||||
// Delete the .app.json from the filesystem
|
||||
// remove() closes the file first.
|
||||
if (!appFile.remove()) {
|
||||
qCDebug(commerce) << "Couldn't delete local .app.json file.";
|
||||
return false;
|
||||
qCWarning(commerce) << "Couldn't delete local .app.json file during app uninstall. Continuing anyway. App filename is:" << appHref.fileName();
|
||||
}
|
||||
|
||||
emit appUninstalled(itemHref);
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
/**jsdoc
|
||||
* The FaceTracker API helps manage facial tracking hardware.
|
||||
* @namespace FaceTracker
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
|
||||
class DdeFaceTracker : public FaceTracker, public Dependency {
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
* The Picks API lets you create and manage objects for repeatedly calculating intersections in different ways.
|
||||
*
|
||||
* @namespace Picks
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property PICK_NOTHING {number} A filter flag. Don't intersect with anything.
|
||||
* @property PICK_ENTITIES {number} A filter flag. Include entities when intersecting.
|
||||
* @property PICK_OVERLAYS {number} A filter flag. Include overlays when intersecting.
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
* Pointers can also be configured to automatically generate PointerEvents.
|
||||
*
|
||||
* @namespace Pointers
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
|
||||
class PointerScriptingInterface : public QObject, public Dependency {
|
||||
|
|
|
@ -38,6 +38,9 @@ class AccountServicesScriptingInterface : public QObject {
|
|||
/**jsdoc
|
||||
* The AccountServices API contains helper functions related to user connectivity
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @namespace AccountServices
|
||||
* @property {string} username <em>Read-only.</em>
|
||||
* @property {boolean} loggedIn <em>Read-only.</em>
|
||||
|
|
|
@ -27,8 +27,14 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable {
|
|||
|
||||
/**jsdoc
|
||||
* The Audio API features tools to help control audio contexts and settings.
|
||||
*
|
||||
*
|
||||
* @namespace Audio
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property {boolean} muted
|
||||
* @property {boolean} noiseReduction
|
||||
* @property {number} inputVolume
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
* The Clipboard API enables you to export and import entities to and from JSON files.
|
||||
*
|
||||
* @namespace Clipboard
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
class ClipboardScriptingInterface : public QObject {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -200,7 +200,10 @@ class ScriptEngine;
|
|||
*
|
||||
* @namespace Controller
|
||||
*
|
||||
* @property {Controller.Actions} Actions - Predefined actions on Interface and the user's avatar. These can be used as end
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {Controller.Actions} Actions - Predefined actions on Interface and the user's avatar. These can be used as end
|
||||
* points in a {@link RouteObject} mapping. A synonym for <code>Controller.Hardware.Actions</code>.
|
||||
* <em>Read-only.</em><br />
|
||||
* Default mappings are provided from the <code>Controller.Hardware.Keyboard</code> and <code>Controller.Standard</code> to
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
/**jsdoc
|
||||
* The GooglePoly API allows you to interact with Google Poly models direct from inside High Fidelity.
|
||||
* @namespace GooglePoly
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
|
||||
class GooglePolyScriptingInterface : public QObject, public Dependency {
|
||||
|
|
|
@ -28,7 +28,11 @@ class QScriptEngine;
|
|||
* The HMD API provides access to the HMD used in VR display mode.
|
||||
*
|
||||
* @namespace HMD
|
||||
* @property {Vec3} position - The position of the HMD if currently in VR display mode, otherwise
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {Vec3} position - The position of the HMD if currently in VR display mode, otherwise
|
||||
* {@link Vec3(0)|Vec3.ZERO}. <em>Read-only.</em>
|
||||
* @property {Quat} orientation - The orientation of the HMD if currently in VR display mode, otherwise
|
||||
* {@link Quat(0)|Quat.IDENTITY}. <em>Read-only.</em>
|
||||
|
|
|
@ -32,6 +32,9 @@ class MenuItemProperties;
|
|||
* If a menu item doesn't belong to a group it is always displayed.
|
||||
*
|
||||
* @namespace Menu
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -86,6 +86,9 @@ protected:
|
|||
* The <code>Selection</code> API provides a means of grouping together avatars, entities, and overlays in named lists.
|
||||
* @namespace Selection
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @example <caption>Outline an entity when it is grabbed by a controller.</caption>
|
||||
* // Create a box and copy the following text into the entity's "Script URL" field.
|
||||
* (function () {
|
||||
|
@ -131,7 +134,7 @@ public:
|
|||
/**jsdoc
|
||||
* Get the names of all the selection lists.
|
||||
* @function Selection.getListNames
|
||||
* @return {list[]} An array of names of all the selection lists.
|
||||
* @returns {list[]} An array of names of all the selection lists.
|
||||
*/
|
||||
Q_INVOKABLE QStringList getListNames() const;
|
||||
|
||||
|
@ -181,7 +184,7 @@ public:
|
|||
* Get the list of avatars, entities, and overlays stored in a selection list.
|
||||
* @function Selection.getList
|
||||
* @param {string} listName - The name of the selection list.
|
||||
* @return {Selection.SelectedItemsList} The content of a selection list. If the list name doesn't exist, the function
|
||||
* @returns {Selection.SelectedItemsList} The content of a selection list. If the list name doesn't exist, the function
|
||||
* returns an empty object with no properties.
|
||||
*/
|
||||
Q_INVOKABLE QVariantMap getSelectedItemsList(const QString& listName) const;
|
||||
|
@ -189,7 +192,7 @@ public:
|
|||
/**jsdoc
|
||||
* Get the names of the highlighted selection lists.
|
||||
* @function Selection.getHighlightedListNames
|
||||
* @return {string[]} An array of names of the selection list currently highlight enabled.
|
||||
* @returns {string[]} An array of names of the selection list currently highlight enabled.
|
||||
*/
|
||||
Q_INVOKABLE QStringList getHighlightedListNames() const;
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
/**jsdoc
|
||||
* The Settings API provides a facility to store and retrieve values that persist between Interface runs.
|
||||
* @namespace Settings
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
|
||||
class SettingsScriptingInterface : public QObject {
|
||||
|
|
|
@ -28,7 +28,11 @@
|
|||
* physics.
|
||||
*
|
||||
* @namespace Window
|
||||
* @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other
|
||||
* chrome), in pixels. <em>Read-only.</em>
|
||||
* @property {number} innerHeight - The height of the drawable area of the Interface window (i.e., without borders or other
|
||||
* chrome), in pixels. <em>Read-only.</em>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
static AvatarInputs* INSTANCE{ nullptr };
|
||||
|
||||
Setting::Handle<bool> showAudioToolsSetting { QStringList { "AvatarInputs", "showAudioTools" }, false };
|
||||
Setting::Handle<bool> showAudioToolsSetting { QStringList { "AvatarInputs", "showAudioTools" }, true };
|
||||
|
||||
AvatarInputs* AvatarInputs::getInstance() {
|
||||
if (!INSTANCE) {
|
||||
|
|
|
@ -26,6 +26,10 @@ class AvatarInputs : public QObject {
|
|||
/**jsdoc
|
||||
* API to help manage your Avatar's input
|
||||
* @namespace AvatarInputs
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {boolean} cameraEnabled <em>Read-only.</em>
|
||||
* @property {boolean} cameraMuted <em>Read-only.</em>
|
||||
* @property {boolean} isHMD <em>Read-only.</em>
|
||||
|
|
|
@ -31,9 +31,6 @@
|
|||
#include "EntityTree.h"
|
||||
#include "ContextOverlayLogging.h"
|
||||
|
||||
/**jsdoc
|
||||
* @namespace ContextOverlay
|
||||
*/
|
||||
class ContextOverlayInterface : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -76,6 +76,10 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R
|
|||
* The Overlays API provides facilities to create and interact with overlays. Overlays are 2D and 3D objects visible only to
|
||||
* yourself and that aren't persisted to the domain. They are used for UI.
|
||||
* @namespace Overlays
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {Uuid} keyboardFocusOverlay - Get or set the {@link Overlays.OverlayType|web3d} overlay that has keyboard focus.
|
||||
* If no overlay has keyboard focus, get returns <code>null</code>; set to <code>null</code> or {@link Uuid|Uuid.NULL} to
|
||||
* clear keyboard focus.
|
||||
|
|
|
@ -37,51 +37,49 @@ public:
|
|||
* API to manage animation cache resources.
|
||||
* @namespace AnimationCache
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property {number} numTotal - Total number of total resources. <em>Read-only.</em>
|
||||
* @property {number} numCached - Total number of cached resource. <em>Read-only.</em>
|
||||
* @property {number} sizeTotal - Size in bytes of all resources. <em>Read-only.</em>
|
||||
* @property {number} sizeCached - Size in bytes of all cached resources. <em>Read-only.</em>
|
||||
*/
|
||||
|
||||
// Functions are copied over from ResourceCache (see ResourceCache.h for reason).
|
||||
// Functions are copied over from ResourceCache (see ResourceCache.h for reason).
|
||||
|
||||
/**jsdoc
|
||||
/**jsdoc
|
||||
* Get the list of all resource URLs.
|
||||
* @function AnimationCache.getResourceList
|
||||
* @return {string[]}
|
||||
* @returns {string[]}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
/**jsdoc
|
||||
* @function AnimationCache.dirty
|
||||
* @returns {Signal}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
/**jsdoc
|
||||
* @function AnimationCache.updateTotalSize
|
||||
* @param {number} deltaSize
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
/**jsdoc
|
||||
* Prefetches a resource.
|
||||
* @function AnimationCache.prefetch
|
||||
* @param {string} url
|
||||
* @param {object} extra
|
||||
* @returns {object}
|
||||
* @param {string} url - URL of the resource to prefetch.
|
||||
* @param {object} [extra=null]
|
||||
* @returns {Resource}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
/**jsdoc
|
||||
* Asynchronously loads a resource from the specified URL and returns it.
|
||||
* @function AnimationCache.getResource
|
||||
* @param {string} url - URL of the resource to load.
|
||||
* @param {string} [fallback=""] - Fallback URL if load of the desired URL fails.
|
||||
* @param {} [extra=null]
|
||||
* @return {Resource}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
* Prefetches a resource.
|
||||
* @function AnimationCache.prefetch
|
||||
* @param {string} url - URL of the resource to prefetch.
|
||||
* @return {Resource}
|
||||
* @returns {Resource}
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -41,6 +41,10 @@ class AudioStreamStatsInterface : public QObject {
|
|||
|
||||
/**jsdoc
|
||||
* @class AudioStats.AudioStreamStats
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {number} lossRate <em>Read-only.</em>
|
||||
* @property {number} lossCount <em>Read-only.</em>
|
||||
* @property {number} lossRateWindow <em>Read-only.</em>
|
||||
|
@ -185,6 +189,10 @@ class AudioStatsInterface : public QObject {
|
|||
/**jsdoc
|
||||
* Audio stats from the client.
|
||||
* @namespace AudioStats
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {number} pingMs <em>Read-only.</em>
|
||||
* @property {number} inputReadMsMax <em>Read-only.</em>
|
||||
* @property {number} inputUnplayedMsMax <em>Read-only.</em>
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
// Inline functions to implement audio dynamics processing
|
||||
//
|
||||
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
@ -21,7 +21,15 @@
|
|||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER)
|
||||
#define FORCEINLINE __forceinline
|
||||
#elif defined(__GNUC__)
|
||||
#define FORCEINLINE inline __attribute__((always_inline))
|
||||
#else
|
||||
#define FORCEINLINE inline
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <intrin.h>
|
||||
#define MUL64(a,b) __emul((a), (b))
|
||||
#else
|
||||
|
@ -42,14 +50,14 @@
|
|||
|
||||
#include <xmmintrin.h>
|
||||
// convert float to int using round-to-nearest
|
||||
static inline int32_t floatToInt(float x) {
|
||||
FORCEINLINE static int32_t floatToInt(float x) {
|
||||
return _mm_cvt_ss2si(_mm_load_ss(&x));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// convert float to int using round-to-nearest
|
||||
static inline int32_t floatToInt(float x) {
|
||||
FORCEINLINE static int32_t floatToInt(float x) {
|
||||
x += (x < 0.0f ? -0.5f : 0.5f); // round
|
||||
return (int32_t)x;
|
||||
}
|
||||
|
@ -60,12 +68,12 @@ static const double FIXQ31 = 2147483648.0; // convert float to Q31
|
|||
static const double DB_TO_LOG2 = 0.16609640474436813; // convert dB to log2
|
||||
|
||||
// convert dB to amplitude
|
||||
static inline double dBToGain(double dB) {
|
||||
FORCEINLINE static double dBToGain(double dB) {
|
||||
return pow(10.0, dB / 20.0);
|
||||
}
|
||||
|
||||
// convert milliseconds to first-order time constant
|
||||
static inline int32_t msToTc(double ms, double sampleRate) {
|
||||
FORCEINLINE static int32_t msToTc(double ms, double sampleRate) {
|
||||
double tc = exp(-1000.0 / (ms * sampleRate));
|
||||
return (int32_t)(FIXQ31 * tc); // Q31
|
||||
}
|
||||
|
@ -144,16 +152,16 @@ static const int IEEE754_EXPN_BIAS = 127;
|
|||
// x < 2^(31-LOG2_HEADROOM) returns 0x7fffffff
|
||||
// x > 2^LOG2_HEADROOM undefined
|
||||
//
|
||||
static inline int32_t peaklog2(float* input) {
|
||||
FORCEINLINE static int32_t peaklog2(float* input) {
|
||||
|
||||
// float as integer bits
|
||||
int32_t u = *(int32_t*)input;
|
||||
uint32_t u = *(uint32_t*)input;
|
||||
|
||||
// absolute value
|
||||
int32_t peak = u & IEEE754_FABS_MASK;
|
||||
uint32_t peak = u & IEEE754_FABS_MASK;
|
||||
|
||||
// split into e and x - 1.0
|
||||
int32_t e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM;
|
||||
int e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM;
|
||||
int32_t x = (peak << IEEE754_EXPN_BITS) & 0x7fffffff;
|
||||
|
||||
// saturate
|
||||
|
@ -180,19 +188,19 @@ static inline int32_t peaklog2(float* input) {
|
|||
// x < 2^(31-LOG2_HEADROOM) returns 0x7fffffff
|
||||
// x > 2^LOG2_HEADROOM undefined
|
||||
//
|
||||
static inline int32_t peaklog2(float* input0, float* input1) {
|
||||
FORCEINLINE static int32_t peaklog2(float* input0, float* input1) {
|
||||
|
||||
// float as integer bits
|
||||
int32_t u0 = *(int32_t*)input0;
|
||||
int32_t u1 = *(int32_t*)input1;
|
||||
uint32_t u0 = *(uint32_t*)input0;
|
||||
uint32_t u1 = *(uint32_t*)input1;
|
||||
|
||||
// max absolute value
|
||||
u0 &= IEEE754_FABS_MASK;
|
||||
u1 &= IEEE754_FABS_MASK;
|
||||
int32_t peak = MAX(u0, u1);
|
||||
uint32_t peak = MAX(u0, u1);
|
||||
|
||||
// split into e and x - 1.0
|
||||
int32_t e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM;
|
||||
int e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM;
|
||||
int32_t x = (peak << IEEE754_EXPN_BITS) & 0x7fffffff;
|
||||
|
||||
// saturate
|
||||
|
@ -219,23 +227,23 @@ static inline int32_t peaklog2(float* input0, float* input1) {
|
|||
// x < 2^(31-LOG2_HEADROOM) returns 0x7fffffff
|
||||
// x > 2^LOG2_HEADROOM undefined
|
||||
//
|
||||
static inline int32_t peaklog2(float* input0, float* input1, float* input2, float* input3) {
|
||||
FORCEINLINE static int32_t peaklog2(float* input0, float* input1, float* input2, float* input3) {
|
||||
|
||||
// float as integer bits
|
||||
int32_t u0 = *(int32_t*)input0;
|
||||
int32_t u1 = *(int32_t*)input1;
|
||||
int32_t u2 = *(int32_t*)input2;
|
||||
int32_t u3 = *(int32_t*)input3;
|
||||
uint32_t u0 = *(uint32_t*)input0;
|
||||
uint32_t u1 = *(uint32_t*)input1;
|
||||
uint32_t u2 = *(uint32_t*)input2;
|
||||
uint32_t u3 = *(uint32_t*)input3;
|
||||
|
||||
// max absolute value
|
||||
u0 &= IEEE754_FABS_MASK;
|
||||
u1 &= IEEE754_FABS_MASK;
|
||||
u2 &= IEEE754_FABS_MASK;
|
||||
u3 &= IEEE754_FABS_MASK;
|
||||
int32_t peak = MAX(MAX(u0, u1), MAX(u2, u3));
|
||||
uint32_t peak = MAX(MAX(u0, u1), MAX(u2, u3));
|
||||
|
||||
// split into e and x - 1.0
|
||||
int32_t e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM;
|
||||
int e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM;
|
||||
int32_t x = (peak << IEEE754_EXPN_BITS) & 0x7fffffff;
|
||||
|
||||
// saturate
|
||||
|
@ -261,7 +269,7 @@ static inline int32_t peaklog2(float* input0, float* input1, float* input2, floa
|
|||
// Count Leading Zeros
|
||||
// Emulates the CLZ (ARM) and LZCNT (x86) instruction
|
||||
//
|
||||
static inline int CLZ(uint32_t u) {
|
||||
FORCEINLINE static int CLZ(uint32_t u) {
|
||||
|
||||
if (u == 0) {
|
||||
return 32;
|
||||
|
@ -294,7 +302,7 @@ static inline int CLZ(uint32_t u) {
|
|||
// Compute -log2(x) for x=[0,1] in Q31, result in Q26
|
||||
// x <= 0 returns 0x7fffffff
|
||||
//
|
||||
static inline int32_t fixlog2(int32_t x) {
|
||||
FORCEINLINE static int32_t fixlog2(int32_t x) {
|
||||
|
||||
if (x <= 0) {
|
||||
return 0x7fffffff;
|
||||
|
@ -303,8 +311,7 @@ static inline int32_t fixlog2(int32_t x) {
|
|||
// split into e and x - 1.0
|
||||
uint32_t u = (uint32_t)x;
|
||||
int e = CLZ(u);
|
||||
u <<= e; // normalize to [0x80000000, 0xffffffff]
|
||||
x = u & 0x7fffffff; // x - 1.0
|
||||
x = (u << e) & 0x7fffffff;
|
||||
|
||||
int k = x >> (31 - LOG2_TABBITS);
|
||||
|
||||
|
@ -324,7 +331,7 @@ static inline int32_t fixlog2(int32_t x) {
|
|||
// Compute exp2(-x) for x=[0,32] in Q26, result in Q31
|
||||
// x <= 0 returns 0x7fffffff
|
||||
//
|
||||
static inline int32_t fixexp2(int32_t x) {
|
||||
FORCEINLINE static int32_t fixexp2(int32_t x) {
|
||||
|
||||
if (x <= 0) {
|
||||
return 0x7fffffff;
|
||||
|
@ -350,12 +357,12 @@ static inline int32_t fixexp2(int32_t x) {
|
|||
}
|
||||
|
||||
// fast TPDF dither in [-1.0f, 1.0f]
|
||||
static inline float dither() {
|
||||
FORCEINLINE static float dither() {
|
||||
static uint32_t rz = 0;
|
||||
rz = rz * 69069 + 1;
|
||||
int32_t r0 = rz & 0xffff;
|
||||
int32_t r1 = rz >> 16;
|
||||
return (int32_t)(r0 - r1) * (1/65536.0f);
|
||||
return (r0 - r1) * (1/65536.0f);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -13,18 +13,11 @@
|
|||
#include "AudioReverb.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#include <intrin.h>
|
||||
inline static int MULHI(int a, int b) {
|
||||
long long c = __emul(a, b);
|
||||
return ((int*)&c)[1];
|
||||
}
|
||||
|
||||
#define MULHI(a,b) ((int32_t)(__emul(a, b) >> 32))
|
||||
#else
|
||||
|
||||
#define MULHI(a,b) (int)(((long long)(a) * (b)) >> 32)
|
||||
|
||||
#endif // _MSC_VER
|
||||
#define MULHI(a,b) ((int32_t)(((int64_t)(a) * (int64_t)(b)) >> 32))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
|
@ -1954,7 +1947,7 @@ static inline float dither() {
|
|||
rz = rz * 69069 + 1;
|
||||
int32_t r0 = rz & 0xffff;
|
||||
int32_t r1 = rz >> 16;
|
||||
return (int32_t)(r0 - r1) * (1/65536.0f);
|
||||
return (r0 - r1) * (1/65536.0f);
|
||||
}
|
||||
|
||||
// convert float to int16_t with dither, interleave stereo
|
||||
|
|
|
@ -1200,7 +1200,7 @@ static inline float dither() {
|
|||
rz = rz * 69069 + 1;
|
||||
int32_t r0 = rz & 0xffff;
|
||||
int32_t r1 = rz >> 16;
|
||||
return (int32_t)(r0 - r1) * (1/65536.0f);
|
||||
return (r0 - r1) * (1/65536.0f);
|
||||
}
|
||||
|
||||
// convert float to int16_t with dither, interleave stereo
|
||||
|
|
|
@ -29,6 +29,11 @@ public:
|
|||
* API to manage sound cache resources.
|
||||
* @namespace SoundCache
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property {number} numTotal - Total number of total resources. <em>Read-only.</em>
|
||||
* @property {number} numCached - Total number of cached resource. <em>Read-only.</em>
|
||||
* @property {number} sizeTotal - Size in bytes of all resources. <em>Read-only.</em>
|
||||
|
@ -36,12 +41,12 @@ public:
|
|||
*/
|
||||
|
||||
|
||||
// Functions are copied over from ResourceCache (see ResourceCache.h for reason).
|
||||
// Functions are copied over from ResourceCache (see ResourceCache.h for reason).
|
||||
|
||||
/**jsdoc
|
||||
* Get the list of all resource URLs.
|
||||
* @function SoundCache.getResourceList
|
||||
* @return {string[]}
|
||||
* @returns {string[]}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
|
@ -55,10 +60,11 @@ public:
|
|||
*/
|
||||
|
||||
/**jsdoc
|
||||
* Prefetches a resource.
|
||||
* @function SoundCache.prefetch
|
||||
* @param {string} url
|
||||
* @param {object} extra
|
||||
* @returns {object}
|
||||
* @param {string} url - URL of the resource to prefetch.
|
||||
* @param {object} [extra=null]
|
||||
* @returns {Resource}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
|
@ -67,14 +73,7 @@ public:
|
|||
* @param {string} url - URL of the resource to load.
|
||||
* @param {string} [fallback=""] - Fallback URL if load of the desired URL fails.
|
||||
* @param {} [extra=null]
|
||||
* @return {Resource}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
* Prefetches a resource.
|
||||
* @function SoundCache.prefetch
|
||||
* @param {string} url - URL of the resource to prefetch.
|
||||
* @return {Resource}
|
||||
* @returns {Resource}
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -277,8 +277,6 @@ namespace AvatarDataPacket {
|
|||
|
||||
const float MAX_AUDIO_LOUDNESS = 1000.0f; // close enough for mouth animation
|
||||
|
||||
const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS = 1000;
|
||||
|
||||
// See also static AvatarData::defaultFullAvatarModelUrl().
|
||||
const QString DEFAULT_FULL_AVATAR_MODEL_NAME = QString("Default");
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ class UserInputMapper;
|
|||
* </ul>
|
||||
*
|
||||
* @class MappingObject
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
|
|
|
@ -36,6 +36,9 @@ class ScriptingInterface;
|
|||
* types.<p>
|
||||
*
|
||||
* @class RouteObject
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
|
||||
// TODO migrate functionality to a RouteBuilder class and make the proxy defer to that
|
||||
|
|
|
@ -174,6 +174,10 @@ private:
|
|||
|
||||
/**jsdoc
|
||||
* @namespace Reticle
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {boolean} allowMouseCapture
|
||||
* @property {number} depth
|
||||
* @property {Vec2} maximumPosition
|
||||
|
|
|
@ -296,7 +296,8 @@ void EntityTreeRenderer::addPendingEntities(const render::ScenePointer& scene, r
|
|||
}
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene, const ViewFrustum& view, render::Transaction& transaction) {
|
||||
void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene, const ViewFrustums& views,
|
||||
render::Transaction& transaction) {
|
||||
PROFILE_RANGE_EX(simulation_physics, "ChangeInScene", 0xffff00ff, (uint64_t)_changedEntities.size());
|
||||
PerformanceTimer pt("change");
|
||||
std::unordered_set<EntityItemID> changedEntities;
|
||||
|
@ -357,7 +358,7 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene
|
|||
|
||||
// prioritize and sort the renderables
|
||||
uint64_t sortStart = usecTimestampNow();
|
||||
PrioritySortUtil::PriorityQueue<SortableRenderer> sortedRenderables(view);
|
||||
PrioritySortUtil::PriorityQueue<SortableRenderer> sortedRenderables(views);
|
||||
{
|
||||
PROFILE_RANGE_EX(simulation_physics, "SortRenderables", 0xffff00ff, (uint64_t)_renderablesToUpdate.size());
|
||||
std::unordered_map<EntityItemID, EntityRendererPointer>::iterator itr = _renderablesToUpdate.begin();
|
||||
|
@ -415,9 +416,20 @@ void EntityTreeRenderer::update(bool simulate) {
|
|||
if (scene) {
|
||||
render::Transaction transaction;
|
||||
addPendingEntities(scene, transaction);
|
||||
|
||||
ViewFrustums views;
|
||||
|
||||
ViewFrustum view;
|
||||
_viewState->copyCurrentViewFrustum(view);
|
||||
updateChangedEntities(scene, view, transaction);
|
||||
_viewState->copyViewFrustum(view);
|
||||
views.push_back(view);
|
||||
|
||||
if (_viewState->hasSecondaryViewFrustum()) {
|
||||
_viewState->copySecondaryViewFrustum(view);
|
||||
views.push_back(view);
|
||||
}
|
||||
|
||||
|
||||
updateChangedEntities(scene, views, transaction);
|
||||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,8 @@ protected:
|
|||
|
||||
private:
|
||||
void addPendingEntities(const render::ScenePointer& scene, render::Transaction& transaction);
|
||||
void updateChangedEntities(const render::ScenePointer& scene, const ViewFrustum& view, render::Transaction& transaction);
|
||||
void updateChangedEntities(const render::ScenePointer& scene, const ViewFrustums& views,
|
||||
render::Transaction& transaction);
|
||||
EntityRendererPointer renderableForEntity(const EntityItemPointer& entity) const { return renderableForEntityId(entity->getID()); }
|
||||
render::ItemID renderableIdForEntity(const EntityItemPointer& entity) const { return renderableIdForEntityId(entity->getID()); }
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ using namespace render::entities;
|
|||
static uint8_t CUSTOM_PIPELINE_NUMBER = 0;
|
||||
static gpu::Stream::FormatPointer _vertexFormat;
|
||||
static std::weak_ptr<gpu::Pipeline> _texturedPipeline;
|
||||
// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 11 to avoid collisions
|
||||
static int32_t PARTICLE_UNIFORM_SLOT { 11 };
|
||||
// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 12 to avoid collisions
|
||||
static int32_t PARTICLE_UNIFORM_SLOT { 12 };
|
||||
|
||||
static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) {
|
||||
auto texturedPipeline = _texturedPipeline.lock();
|
||||
|
|
|
@ -34,8 +34,8 @@ using namespace render::entities;
|
|||
|
||||
static uint8_t CUSTOM_PIPELINE_NUMBER { 0 };
|
||||
static const int32_t PAINTSTROKE_TEXTURE_SLOT { 0 };
|
||||
// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 11 to avoid collisions
|
||||
static const int32_t PAINTSTROKE_UNIFORM_SLOT { 11 };
|
||||
// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 12 to avoid collisions
|
||||
static const int32_t PAINTSTROKE_UNIFORM_SLOT { 12 };
|
||||
static gpu::Stream::FormatPointer polylineFormat;
|
||||
static gpu::PipelinePointer polylinePipeline;
|
||||
#ifdef POLYLINE_ENTITY_USE_FADE_EFFECT
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include <OctreeUtils.h>
|
||||
|
||||
|
||||
DiffTraversal::Waypoint::Waypoint(EntityTreeElementPointer& element) : _nextIndex(0) {
|
||||
assert(element);
|
||||
_weakElement = element;
|
||||
|
@ -37,15 +36,14 @@ void DiffTraversal::Waypoint::getNextVisibleElementFirstTime(DiffTraversal::Visi
|
|||
EntityTreeElementPointer nextElement = element->getChildAtIndex(_nextIndex);
|
||||
++_nextIndex;
|
||||
if (nextElement) {
|
||||
if (!view.usesViewFrustum) {
|
||||
const auto& cube = nextElement->getAACube();
|
||||
if (!view.usesViewFrustums()) {
|
||||
// No LOD truncation if we aren't using the view frustum
|
||||
next.element = nextElement;
|
||||
return;
|
||||
} else if (view.viewFrustum.cubeIntersectsKeyhole(nextElement->getAACube())) {
|
||||
} else if (view.intersects(cube)) {
|
||||
// check for LOD truncation
|
||||
float distance = glm::distance(view.viewFrustum.getPosition(), nextElement->getAACube().calcCenter()) + MIN_VISIBLE_DISTANCE;
|
||||
float angularDiameter = nextElement->getAACube().getScale() / distance;
|
||||
if (angularDiameter > MIN_ELEMENT_ANGULAR_DIAMETER * view.lodScaleFactor) {
|
||||
if (view.isBigEnough(cube, MIN_ELEMENT_ANGULAR_DIAMETER)) {
|
||||
next.element = nextElement;
|
||||
return;
|
||||
}
|
||||
|
@ -76,17 +74,16 @@ void DiffTraversal::Waypoint::getNextVisibleElementRepeat(
|
|||
EntityTreeElementPointer nextElement = element->getChildAtIndex(_nextIndex);
|
||||
++_nextIndex;
|
||||
if (nextElement && nextElement->getLastChanged() > lastTime) {
|
||||
if (!view.usesViewFrustum) {
|
||||
if (!view.usesViewFrustums()) {
|
||||
// No LOD truncation if we aren't using the view frustum
|
||||
next.element = nextElement;
|
||||
next.intersection = ViewFrustum::INSIDE;
|
||||
return;
|
||||
} else {
|
||||
// check for LOD truncation
|
||||
float distance = glm::distance(view.viewFrustum.getPosition(), nextElement->getAACube().calcCenter()) + MIN_VISIBLE_DISTANCE;
|
||||
float angularDiameter = nextElement->getAACube().getScale() / distance;
|
||||
if (angularDiameter > MIN_ELEMENT_ANGULAR_DIAMETER * view.lodScaleFactor) {
|
||||
ViewFrustum::intersection intersection = view.viewFrustum.calculateCubeKeyholeIntersection(nextElement->getAACube());
|
||||
const auto& cube = nextElement->getAACube();
|
||||
if (view.isBigEnough(cube, MIN_ELEMENT_ANGULAR_DIAMETER)) {
|
||||
ViewFrustum::intersection intersection = view.calculateIntersection(cube);
|
||||
if (intersection != ViewFrustum::OUTSIDE) {
|
||||
next.element = nextElement;
|
||||
next.intersection = intersection;
|
||||
|
@ -118,14 +115,13 @@ void DiffTraversal::Waypoint::getNextVisibleElementDifferential(DiffTraversal::V
|
|||
EntityTreeElementPointer nextElement = element->getChildAtIndex(_nextIndex);
|
||||
++_nextIndex;
|
||||
if (nextElement) {
|
||||
AACube cube = nextElement->getAACube();
|
||||
// check for LOD truncation
|
||||
float distance = glm::distance(view.viewFrustum.getPosition(), cube.calcCenter()) + MIN_VISIBLE_DISTANCE;
|
||||
float angularDiameter = cube.getScale() / distance;
|
||||
if (angularDiameter > MIN_ELEMENT_ANGULAR_DIAMETER * view.lodScaleFactor) {
|
||||
if (view.viewFrustum.calculateCubeKeyholeIntersection(cube) != ViewFrustum::OUTSIDE) {
|
||||
const auto& cube = nextElement->getAACube();
|
||||
if (view.isBigEnough(cube, MIN_ELEMENT_ANGULAR_DIAMETER)) {
|
||||
ViewFrustum::intersection intersection = view.calculateIntersection(cube);
|
||||
if (intersection != ViewFrustum::OUTSIDE) {
|
||||
next.element = nextElement;
|
||||
next.intersection = ViewFrustum::OUTSIDE;
|
||||
next.intersection = intersection;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -137,13 +133,83 @@ void DiffTraversal::Waypoint::getNextVisibleElementDifferential(DiffTraversal::V
|
|||
next.intersection = ViewFrustum::OUTSIDE;
|
||||
}
|
||||
|
||||
bool DiffTraversal::View::isBigEnough(const AACube& cube, float minDiameter) const {
|
||||
if (viewFrustums.empty()) {
|
||||
// Everything is big enough when not using view frustums
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isBigEnough = std::any_of(std::begin(viewFrustums), std::end(viewFrustums),
|
||||
[&](const ViewFrustum& viewFrustum) {
|
||||
return isAngularSizeBigEnough(viewFrustum.getPosition(), cube, lodScaleFactor, minDiameter);
|
||||
});
|
||||
|
||||
return isBigEnough;
|
||||
}
|
||||
|
||||
bool DiffTraversal::View::intersects(const AACube& cube) const {
|
||||
if (viewFrustums.empty()) {
|
||||
// Everything intersects when not using view frustums
|
||||
return true;
|
||||
}
|
||||
|
||||
bool intersects = std::any_of(std::begin(viewFrustums), std::end(viewFrustums),
|
||||
[&](const ViewFrustum& viewFrustum) {
|
||||
return viewFrustum.cubeIntersectsKeyhole(cube);
|
||||
});
|
||||
|
||||
return intersects;
|
||||
}
|
||||
|
||||
ViewFrustum::intersection DiffTraversal::View::calculateIntersection(const AACube& cube) const {
|
||||
if (viewFrustums.empty()) {
|
||||
// Everything is inside when not using view frustums
|
||||
return ViewFrustum::INSIDE;
|
||||
}
|
||||
|
||||
ViewFrustum::intersection intersection = ViewFrustum::OUTSIDE;
|
||||
|
||||
for (const auto& viewFrustum : viewFrustums) {
|
||||
switch (viewFrustum.calculateCubeKeyholeIntersection(cube)) {
|
||||
case ViewFrustum::INSIDE:
|
||||
return ViewFrustum::INSIDE;
|
||||
case ViewFrustum::INTERSECT:
|
||||
intersection = ViewFrustum::INTERSECT;
|
||||
break;
|
||||
default:
|
||||
// DO NOTHING
|
||||
break;
|
||||
}
|
||||
}
|
||||
return intersection;
|
||||
}
|
||||
|
||||
bool DiffTraversal::View::usesViewFrustums() const {
|
||||
return !viewFrustums.empty();
|
||||
}
|
||||
|
||||
bool DiffTraversal::View::isVerySimilar(const View& view) const {
|
||||
auto size = view.viewFrustums.size();
|
||||
|
||||
if (view.lodScaleFactor != lodScaleFactor ||
|
||||
viewFrustums.size() != size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (!viewFrustums[i].isVerySimilar(view.viewFrustums[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DiffTraversal::DiffTraversal() {
|
||||
const int32_t MIN_PATH_DEPTH = 16;
|
||||
_path.reserve(MIN_PATH_DEPTH);
|
||||
}
|
||||
|
||||
DiffTraversal::Type DiffTraversal::prepareNewTraversal(const ViewFrustum& viewFrustum, EntityTreeElementPointer root,
|
||||
int32_t lodLevelOffset, bool usesViewFrustum) {
|
||||
DiffTraversal::Type DiffTraversal::prepareNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root) {
|
||||
assert(root);
|
||||
// there are three types of traversal:
|
||||
//
|
||||
|
@ -159,29 +225,25 @@ DiffTraversal::Type DiffTraversal::prepareNewTraversal(const ViewFrustum& viewFr
|
|||
//
|
||||
// external code should update the _scanElementCallback after calling prepareNewTraversal
|
||||
//
|
||||
_currentView.usesViewFrustum = usesViewFrustum;
|
||||
float lodScaleFactor = powf(2.0f, lodLevelOffset);
|
||||
|
||||
Type type;
|
||||
// If usesViewFrustum changes, treat it as a First traversal
|
||||
if (_completedView.startTime == 0 || _currentView.usesViewFrustum != _completedView.usesViewFrustum) {
|
||||
if (_completedView.startTime == 0 || _currentView.usesViewFrustums() != _completedView.usesViewFrustums()) {
|
||||
type = Type::First;
|
||||
_currentView.viewFrustum = viewFrustum;
|
||||
_currentView.lodScaleFactor = lodScaleFactor;
|
||||
_currentView.viewFrustums = view.viewFrustums;
|
||||
_currentView.lodScaleFactor = view.lodScaleFactor;
|
||||
_getNextVisibleElementCallback = [this](DiffTraversal::VisibleElement& next) {
|
||||
_path.back().getNextVisibleElementFirstTime(next, _currentView);
|
||||
};
|
||||
} else if (!_currentView.usesViewFrustum ||
|
||||
(_completedView.viewFrustum.isVerySimilar(viewFrustum) &&
|
||||
lodScaleFactor == _completedView.lodScaleFactor)) {
|
||||
} else if (!_currentView.usesViewFrustums() || _completedView.isVerySimilar(view)) {
|
||||
type = Type::Repeat;
|
||||
_getNextVisibleElementCallback = [this](DiffTraversal::VisibleElement& next) {
|
||||
_path.back().getNextVisibleElementRepeat(next, _completedView, _completedView.startTime);
|
||||
};
|
||||
} else {
|
||||
type = Type::Differential;
|
||||
_currentView.viewFrustum = viewFrustum;
|
||||
_currentView.lodScaleFactor = lodScaleFactor;
|
||||
_currentView.viewFrustums = view.viewFrustums;
|
||||
_currentView.lodScaleFactor = view.lodScaleFactor;
|
||||
_getNextVisibleElementCallback = [this](DiffTraversal::VisibleElement& next) {
|
||||
_path.back().getNextVisibleElementDifferential(next, _currentView, _completedView);
|
||||
};
|
||||
|
|
|
@ -30,10 +30,15 @@ public:
|
|||
// View is a struct with a ViewFrustum and LOD parameters
|
||||
class View {
|
||||
public:
|
||||
ViewFrustum viewFrustum;
|
||||
bool isBigEnough(const AACube& cube, float minDiameter = MIN_ENTITY_ANGULAR_DIAMETER) const;
|
||||
bool intersects(const AACube& cube) const;
|
||||
bool usesViewFrustums() const;
|
||||
bool isVerySimilar(const View& view) const;
|
||||
ViewFrustum::intersection calculateIntersection(const AACube& cube) const;
|
||||
|
||||
ViewFrustums viewFrustums;
|
||||
uint64_t startTime { 0 };
|
||||
float lodScaleFactor { 1.0f };
|
||||
bool usesViewFrustum { true };
|
||||
};
|
||||
|
||||
// Waypoint is an bookmark in a "path" of waypoints during a traversal.
|
||||
|
@ -57,15 +62,12 @@ public:
|
|||
|
||||
DiffTraversal();
|
||||
|
||||
Type prepareNewTraversal(const ViewFrustum& viewFrustum, EntityTreeElementPointer root, int32_t lodLevelOffset,
|
||||
bool usesViewFrustum);
|
||||
Type prepareNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root);
|
||||
|
||||
const ViewFrustum& getCurrentView() const { return _currentView.viewFrustum; }
|
||||
const ViewFrustum& getCompletedView() const { return _completedView.viewFrustum; }
|
||||
const View& getCurrentView() const { return _currentView; }
|
||||
const View& getCompletedView() const { return _completedView; }
|
||||
|
||||
bool doesCurrentUseViewFrustum() const { return _currentView.usesViewFrustum; }
|
||||
float getCurrentLODScaleFactor() const { return _currentView.lodScaleFactor; }
|
||||
float getCompletedLODScaleFactor() const { return _completedView.lodScaleFactor; }
|
||||
bool doesCurrentUseViewFrustum() const { return _currentView.usesViewFrustums(); }
|
||||
|
||||
uint64_t getStartOfCompletedTraversal() const { return _completedView.startTime; }
|
||||
bool finished() const { return _path.empty(); }
|
||||
|
|
|
@ -94,6 +94,12 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra
|
|||
* Interface has displayed and so knows about.
|
||||
*
|
||||
* @namespace Entities
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property {Uuid} keyboardFocusEntity - Get or set the {@link Entities.EntityType|Web} entity that has keyboard focus.
|
||||
* If no entity has keyboard focus, get returns <code>null</code>; set to <code>null</code> or {@link Uuid|Uuid.NULL} to
|
||||
* clear keyboard focus.
|
||||
|
|
|
@ -27,9 +27,6 @@ using EntityTreePointer = std::shared_ptr<EntityTree>;
|
|||
#include "MovingEntitiesOperator.h"
|
||||
|
||||
class EntityEditFilters;
|
||||
class Model;
|
||||
using ModelPointer = std::shared_ptr<Model>;
|
||||
using ModelWeakPointer = std::weak_ptr<Model>;
|
||||
|
||||
class EntitySimulation;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
// this is the maximum per shader stage on the low end apple
|
||||
// TODO make it platform dependant at init time
|
||||
static const int MAX_NUM_UNIFORM_BUFFERS = 12;
|
||||
static const int MAX_NUM_UNIFORM_BUFFERS = 14;
|
||||
size_t getMaxNumUniformBuffers() const { return MAX_NUM_UNIFORM_BUFFERS; }
|
||||
|
||||
// this is the maximum per shader stage on the low end apple
|
||||
|
|
|
@ -46,10 +46,10 @@ void GLBackend::do_setFramebuffer(const Batch& batch, size_t paramOffset) {
|
|||
}
|
||||
|
||||
void GLBackend::do_setFramebufferSwapChain(const Batch& batch, size_t paramOffset) {
|
||||
auto swapChain = batch._swapChains.get(batch._params[paramOffset]._uint);
|
||||
auto swapChain = std::static_pointer_cast<FramebufferSwapChain>(batch._swapChains.get(batch._params[paramOffset]._uint));
|
||||
if (swapChain) {
|
||||
auto index = batch._params[paramOffset + 1]._uint;
|
||||
FramebufferPointer framebuffer = static_cast<const FramebufferSwapChain*>(swapChain.get())->get(index);
|
||||
const auto& framebuffer = swapChain->get(index);
|
||||
setFramebuffer(framebuffer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ void GLBackend::do_setResourceFramebufferSwapChainTexture(const Batch& batch, si
|
|||
return;
|
||||
}
|
||||
|
||||
SwapChainPointer swapChain = batch._swapChains.get(batch._params[paramOffset + 0]._uint);
|
||||
auto swapChain = std::static_pointer_cast<FramebufferSwapChain>(batch._swapChains.get(batch._params[paramOffset + 0]._uint));
|
||||
|
||||
if (!swapChain) {
|
||||
releaseResourceTexture(slot);
|
||||
|
@ -276,9 +276,8 @@ void GLBackend::do_setResourceFramebufferSwapChainTexture(const Batch& batch, si
|
|||
}
|
||||
auto index = batch._params[paramOffset + 2]._uint;
|
||||
auto renderBufferSlot = batch._params[paramOffset + 3]._uint;
|
||||
FramebufferPointer resourceFramebuffer = static_cast<const FramebufferSwapChain*>(swapChain.get())->get(index);
|
||||
TexturePointer resourceTexture = resourceFramebuffer->getRenderBuffer(renderBufferSlot);
|
||||
|
||||
auto resourceFramebuffer = swapChain->get(index);
|
||||
auto resourceTexture = resourceFramebuffer->getRenderBuffer(renderBufferSlot);
|
||||
setResourceTexture(slot, resourceTexture);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ ProfileRangeBatch::~ProfileRangeBatch() {
|
|||
using namespace gpu;
|
||||
|
||||
// FIXME make these backend / pipeline dependent.
|
||||
static const int MAX_NUM_UNIFORM_BUFFERS = 12;
|
||||
static const int MAX_NUM_UNIFORM_BUFFERS = 14;
|
||||
static const int MAX_NUM_RESOURCE_BUFFERS = 16;
|
||||
static const int MAX_NUM_RESOURCE_TEXTURES = 16;
|
||||
|
||||
|
|
|
@ -15,18 +15,18 @@ namespace gpu {
|
|||
class SwapChain {
|
||||
public:
|
||||
|
||||
SwapChain(unsigned int size = 2U) : _size{ size } {}
|
||||
SwapChain(uint8_t size = 2U) : _size{ size } {}
|
||||
virtual ~SwapChain() {}
|
||||
|
||||
void advance() {
|
||||
_frontIndex = (_frontIndex + 1) % _size;
|
||||
}
|
||||
|
||||
unsigned int getSize() const { return _size; }
|
||||
uint8_t getSize() const { return _size; }
|
||||
|
||||
protected:
|
||||
unsigned int _size;
|
||||
unsigned int _frontIndex{ 0U };
|
||||
const uint8_t _size;
|
||||
uint8_t _frontIndex{ 0U };
|
||||
|
||||
};
|
||||
typedef std::shared_ptr<SwapChain> SwapChainPointer;
|
||||
|
@ -41,16 +41,13 @@ namespace gpu {
|
|||
|
||||
using Type = R;
|
||||
using TypePointer = std::shared_ptr<R>;
|
||||
using TypeConstPointer = std::shared_ptr<const R>;
|
||||
|
||||
ResourceSwapChain(unsigned int size = 2U) : SwapChain{ size } {}
|
||||
|
||||
void reset() {
|
||||
for (auto& ptr : _resources) {
|
||||
ptr.reset();
|
||||
ResourceSwapChain(const std::vector<TypePointer>& v) : SwapChain{ std::min<uint8_t>((uint8_t)v.size(), MAX_SIZE) } {
|
||||
for (size_t i = 0; i < _size; ++i) {
|
||||
_resources[i] = v[i];
|
||||
}
|
||||
}
|
||||
|
||||
TypePointer& edit(unsigned int index) { return _resources[(index + _frontIndex) % _size]; }
|
||||
const TypePointer& get(unsigned int index) const { return _resources[(index + _frontIndex) % _size]; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
/**jsdoc
|
||||
* The experimental Graphics API <em>(experimental)</em> lets you query and manage certain graphics-related structures (like underlying meshes and textures) from scripting.
|
||||
* @namespace Graphics
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
|
||||
class GraphicsScriptingInterface : public QObject, public QScriptable, public Dependency {
|
||||
|
@ -39,7 +42,7 @@ public slots:
|
|||
*
|
||||
* @function Graphics.getModel
|
||||
* @param {UUID} entityID - The objectID of the model whose meshes are to be retrieved.
|
||||
* @return {Graphics.Model} the resulting Model object
|
||||
* @returns {Graphics.Model} the resulting Model object
|
||||
*/
|
||||
scriptable::ScriptableModelPointer getModel(QUuid uuid);
|
||||
|
||||
|
@ -54,7 +57,7 @@ public slots:
|
|||
*
|
||||
* @function Graphics.newMesh
|
||||
* @param {Graphics.IFSData} ifsMeshData Index-Faced Set (IFS) arrays used to create the new mesh.
|
||||
* @return {Graphics.Mesh} the resulting Mesh / Mesh Part object
|
||||
* @returns {Graphics.Mesh} the resulting Mesh / Mesh Part object
|
||||
*/
|
||||
/**jsdoc
|
||||
* @typedef {object} Graphics.IFSData
|
||||
|
|
|
@ -63,9 +63,10 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) {
|
|||
PROFILE_ASYNC_BEGIN(resource_parse_geometry, "GeometryMappingResource::downloadFinished", _url.toString(),
|
||||
{ { "url", _url.toString() } });
|
||||
|
||||
auto mapping = FSTReader::readMapping(data);
|
||||
// store parsed contents of FST file
|
||||
_mapping = FSTReader::readMapping(data);
|
||||
|
||||
QString filename = mapping.value("filename").toString();
|
||||
QString filename = _mapping.value("filename").toString();
|
||||
|
||||
if (filename.isNull()) {
|
||||
qCDebug(modelnetworking) << "Mapping file" << _url << "has no \"filename\" field";
|
||||
|
@ -73,7 +74,7 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) {
|
|||
} else {
|
||||
QUrl url = _url.resolved(filename);
|
||||
|
||||
QString texdir = mapping.value(TEXDIR_FIELD).toString();
|
||||
QString texdir = _mapping.value(TEXDIR_FIELD).toString();
|
||||
if (!texdir.isNull()) {
|
||||
if (!texdir.endsWith('/')) {
|
||||
texdir += '/';
|
||||
|
@ -83,15 +84,16 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) {
|
|||
_textureBaseUrl = url.resolved(QUrl("."));
|
||||
}
|
||||
|
||||
auto scripts = FSTReader::getScripts(_url, mapping);
|
||||
auto scripts = FSTReader::getScripts(_url, _mapping);
|
||||
if (scripts.size() > 0) {
|
||||
mapping.remove(SCRIPT_FIELD);
|
||||
_mapping.remove(SCRIPT_FIELD);
|
||||
for (auto &scriptPath : scripts) {
|
||||
mapping.insertMulti(SCRIPT_FIELD, scriptPath);
|
||||
_mapping.insertMulti(SCRIPT_FIELD, scriptPath);
|
||||
}
|
||||
}
|
||||
|
||||
auto animGraphVariant = mapping.value("animGraphUrl");
|
||||
auto animGraphVariant = _mapping.value("animGraphUrl");
|
||||
|
||||
if (animGraphVariant.isValid()) {
|
||||
QUrl fstUrl(animGraphVariant.toString());
|
||||
if (fstUrl.isValid()) {
|
||||
|
@ -104,7 +106,7 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) {
|
|||
}
|
||||
|
||||
auto modelCache = DependencyManager::get<ModelCache>();
|
||||
GeometryExtra extra{ mapping, _textureBaseUrl, false };
|
||||
GeometryExtra extra{ _mapping, _textureBaseUrl, false };
|
||||
|
||||
// Get the raw GeometryResource
|
||||
_geometryResource = modelCache->getResource(url, QUrl(), &extra).staticCast<GeometryResource>();
|
||||
|
@ -379,6 +381,7 @@ Geometry::Geometry(const Geometry& geometry) {
|
|||
}
|
||||
|
||||
_animGraphOverrideUrl = geometry._animGraphOverrideUrl;
|
||||
_mapping = geometry._mapping;
|
||||
}
|
||||
|
||||
void Geometry::setTextures(const QVariantMap& textureMap) {
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
|
||||
virtual bool areTexturesLoaded() const;
|
||||
const QUrl& getAnimGraphOverrideUrl() const { return _animGraphOverrideUrl; }
|
||||
const QVariantHash& getMapping() const { return _mapping; }
|
||||
|
||||
protected:
|
||||
friend class GeometryMappingResource;
|
||||
|
@ -68,6 +69,7 @@ protected:
|
|||
NetworkMaterials _materials;
|
||||
|
||||
QUrl _animGraphOverrideUrl;
|
||||
QVariantHash _mapping; // parsed contents of FST file.
|
||||
|
||||
private:
|
||||
mutable bool _areTexturesLoaded { false };
|
||||
|
@ -144,6 +146,9 @@ public:
|
|||
* API to manage model cache resources.
|
||||
* @namespace ModelCache
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {number} numTotal - Total number of total resources. <em>Read-only.</em>
|
||||
* @property {number} numCached - Total number of cached resource. <em>Read-only.</em>
|
||||
* @property {number} sizeTotal - Size in bytes of all resources. <em>Read-only.</em>
|
||||
|
@ -156,7 +161,7 @@ public:
|
|||
/**jsdoc
|
||||
* Get the list of all resource URLs.
|
||||
* @function ModelCache.getResourceList
|
||||
* @return {string[]}
|
||||
* @returns {string[]}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
|
@ -170,10 +175,11 @@ public:
|
|||
*/
|
||||
|
||||
/**jsdoc
|
||||
* Prefetches a resource.
|
||||
* @function ModelCache.prefetch
|
||||
* @param {string} url
|
||||
* @param {object} extra
|
||||
* @returns {object}
|
||||
* @param {string} url - URL of the resource to prefetch.
|
||||
* @param {object} [extra=null]
|
||||
* @returns {Resource}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
|
@ -182,14 +188,7 @@ public:
|
|||
* @param {string} url - URL of the resource to load.
|
||||
* @param {string} [fallback=""] - Fallback URL if load of the desired URL fails.
|
||||
* @param {} [extra=null]
|
||||
* @return {Resource}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
* Prefetches a resource.
|
||||
* @function ModelCache.prefetch
|
||||
* @param {string} url - URL of the resource to prefetch.
|
||||
* @return {Resource}
|
||||
* @returns {Resource}
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -151,6 +151,9 @@ public:
|
|||
* API to manage texture cache resources.
|
||||
* @namespace TextureCache
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {number} numTotal - Total number of total resources. <em>Read-only.</em>
|
||||
* @property {number} numCached - Total number of cached resource. <em>Read-only.</em>
|
||||
* @property {number} sizeTotal - Size in bytes of all resources. <em>Read-only.</em>
|
||||
|
@ -160,44 +163,38 @@ public:
|
|||
|
||||
// Functions are copied over from ResourceCache (see ResourceCache.h for reason).
|
||||
|
||||
/**jsdoc
|
||||
* Get the list of all resource URLs.
|
||||
* @function TextureCache.getResourceList
|
||||
* @return {string[]}
|
||||
*/
|
||||
/**jsdoc
|
||||
* Get the list of all resource URLs.
|
||||
* @function TextureCache.getResourceList
|
||||
* @returns {string[]}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
* @function TextureCache.dirty
|
||||
* @returns {Signal}
|
||||
*/
|
||||
/**jsdoc
|
||||
* @function TextureCache.dirty
|
||||
* @returns {Signal}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
* @function TextureCache.updateTotalSize
|
||||
* @param {number} deltaSize
|
||||
*/
|
||||
/**jsdoc
|
||||
* @function TextureCache.updateTotalSize
|
||||
* @param {number} deltaSize
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
* @function TextureCache.prefetch
|
||||
* @param {string} url
|
||||
* @param {object} extra
|
||||
* @returns {object}
|
||||
*/
|
||||
/**jsdoc
|
||||
* Prefetches a resource.
|
||||
* @function TextureCache.prefetch
|
||||
* @param {string} url - URL of the resource to prefetch.
|
||||
* @param {object} [extra=null]
|
||||
* @returns {Resource}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
* Asynchronously loads a resource from the specified URL and returns it.
|
||||
* @function TextureCache.getResource
|
||||
* @param {string} url - URL of the resource to load.
|
||||
* @param {string} [fallback=""] - Fallback URL if load of the desired URL fails.
|
||||
* @param {} [extra=null]
|
||||
* @return {Resource}
|
||||
*/
|
||||
|
||||
/**jsdoc
|
||||
* Prefetches a resource.
|
||||
* @function TextureCache.prefetch
|
||||
* @param {string} url - URL of the resource to prefetch.
|
||||
* @return {Resource}
|
||||
*/
|
||||
/**jsdoc
|
||||
* Asynchronously loads a resource from the specified URL and returns it.
|
||||
* @function TextureCache.getResource
|
||||
* @param {string} url - URL of the resource to load.
|
||||
* @param {string} [fallback=""] - Fallback URL if load of the desired URL fails.
|
||||
* @param {} [extra=null]
|
||||
* @returns {Resource}
|
||||
*/
|
||||
|
||||
|
||||
/// Returns the ID of the permutation/normal texture used for Perlin noise shader programs. This texture
|
||||
|
@ -246,10 +243,11 @@ signals:
|
|||
protected:
|
||||
|
||||
/**jsdoc
|
||||
* @function TextureCache.prefect
|
||||
* @function TextureCache.prefetch
|
||||
* @param {string} url
|
||||
* @param {number} type
|
||||
* @param {number} [maxNumPixels=67108864]
|
||||
* @returns {Resource}
|
||||
*/
|
||||
// Overload ResourceCache::prefetch to allow specifying texture type for loads
|
||||
Q_INVOKABLE ScriptableResource* prefetch(const QUrl& url, int type, int maxNumPixels = ABSOLUTE_MAX_TEXTURE_NUM_PIXELS);
|
||||
|
|
|
@ -33,11 +33,14 @@ const QString GET_PLACE = "/api/v1/places/%1";
|
|||
* The location API provides facilities related to your current location in the metaverse.
|
||||
*
|
||||
* @namespace location
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property {Uuid} domainID - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid|Uuid.NULL} if you're not
|
||||
* connected to the domain or are in a serverless domain.
|
||||
* <em>Read-only.</em>
|
||||
* @property {Uuid} domainId - Synonym for <code>domainId</code>. <em>Read-only.</em> <strong>Deprecated:</strong> This property
|
||||
* is deprecated and will soon be removed.
|
||||
* @property {string} hostname - The name of the domain for your current metaverse address (e.g., <code>"AvatarIsland"</code>,
|
||||
* <code>localhost</code>, or an IP address). Is blank if you're in a serverless domain.
|
||||
* <em>Read-only.</em>
|
||||
|
@ -68,7 +71,6 @@ class AddressManager : public QObject, public Dependency {
|
|||
Q_PROPERTY(QString pathname READ currentPath)
|
||||
Q_PROPERTY(QString placename READ getPlaceName)
|
||||
Q_PROPERTY(QString domainID READ getDomainID)
|
||||
Q_PROPERTY(QString domainId READ getDomainID)
|
||||
public:
|
||||
using PositionGetter = std::function<glm::vec3()>;
|
||||
using OrientationGetter = std::function<glm::quat()>;
|
||||
|
|
|
@ -37,6 +37,11 @@
|
|||
* </ul>
|
||||
*
|
||||
* @namespace Messages
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*/
|
||||
class MessagesClient : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -167,7 +167,7 @@ private:
|
|||
HifiSockAddr _assignmentServerSocket;
|
||||
bool _isShuttingDown { false };
|
||||
QTimer _keepAlivePingTimer;
|
||||
bool _requestsDomainListData;
|
||||
bool _requestsDomainListData { false };
|
||||
|
||||
mutable QReadWriteLock _ignoredSetLock;
|
||||
tbb::concurrent_unordered_set<QUuid, UUIDHasher> _ignoredNodeIDs;
|
||||
|
|
|
@ -89,6 +89,12 @@ class ScriptableResource : public QObject {
|
|||
|
||||
/**jsdoc
|
||||
* @constructor Resource
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property {string} url - URL of this resource.
|
||||
* @property {Resource.State} state - Current loading state.
|
||||
*/
|
||||
|
@ -209,7 +215,7 @@ public:
|
|||
/**jsdoc
|
||||
* Get the list of all resource URLs.
|
||||
* @function ResourceCache.getResourceList
|
||||
* @return {string[]}
|
||||
* @returns {string[]}
|
||||
*/
|
||||
Q_INVOKABLE QVariantList getResourceList();
|
||||
|
||||
|
@ -251,10 +257,11 @@ protected slots:
|
|||
void updateTotalSize(const qint64& deltaSize);
|
||||
|
||||
/**jsdoc
|
||||
* Prefetches a resource.
|
||||
* @function ResourceCache.prefetch
|
||||
* @param {string} url
|
||||
* @param {object} extra
|
||||
* @returns {object}
|
||||
* @param {string} url - URL of the resource to prefetch.
|
||||
* @param {object} [extra=null]
|
||||
* @returns {Resource}
|
||||
*/
|
||||
// Prefetches a resource to be held by the QScriptEngine.
|
||||
// Left as a protected member so subclasses can overload prefetch
|
||||
|
@ -267,7 +274,7 @@ protected slots:
|
|||
* @param {string} url - URL of the resource to load.
|
||||
* @param {string} [fallback=""] - Fallback URL if load of the desired URL fails.
|
||||
* @param {} [extra=null]
|
||||
* @return {Resource}
|
||||
* @returns {Resource}
|
||||
*/
|
||||
/// Loads a resource from the specified URL and returns it.
|
||||
/// If the caller is on a different thread than the ResourceCache,
|
||||
|
@ -285,12 +292,7 @@ protected:
|
|||
// Pointers created through this method should be owned by the caller,
|
||||
// which should be a QScriptEngine with ScriptableResource registered, so that
|
||||
// the QScriptEngine will delete the pointer when it is garbage collected.
|
||||
/**jsdoc
|
||||
* Prefetches a resource.
|
||||
* @function ResourceCache.prefetch
|
||||
* @param {string} url - URL of the resource to prefetch.
|
||||
* @return {Resource}
|
||||
*/
|
||||
// JSDoc is provided on more general function signature.
|
||||
Q_INVOKABLE ScriptableResource* prefetch(const QUrl& url) { return prefetch(url, nullptr); }
|
||||
|
||||
/// Creates a new resource.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include "ConnectionStats.h"
|
||||
|
||||
using namespace udt;
|
||||
|
@ -112,3 +113,31 @@ void ConnectionStats::recordPacketSendPeriod(int sample) {
|
|||
_currentSample.packetSendPeriod = sample;
|
||||
_total.packetSendPeriod = (int)((_total.packetSendPeriod * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT));
|
||||
}
|
||||
|
||||
QDebug& operator<<(QDebug&& debug, const udt::ConnectionStats::Stats& stats) {
|
||||
debug << "Connection stats:\n";
|
||||
#define HIFI_LOG_EVENT(x) << " " #x " events: " << stats.events[ConnectionStats::Stats::Event::x] << "\n"
|
||||
debug
|
||||
HIFI_LOG_EVENT(SentACK)
|
||||
HIFI_LOG_EVENT(ReceivedACK)
|
||||
HIFI_LOG_EVENT(ProcessedACK)
|
||||
HIFI_LOG_EVENT(SentLightACK)
|
||||
HIFI_LOG_EVENT(ReceivedLightACK)
|
||||
HIFI_LOG_EVENT(SentACK2)
|
||||
HIFI_LOG_EVENT(ReceivedACK2)
|
||||
HIFI_LOG_EVENT(SentNAK)
|
||||
HIFI_LOG_EVENT(ReceivedNAK)
|
||||
HIFI_LOG_EVENT(SentTimeoutNAK)
|
||||
HIFI_LOG_EVENT(ReceivedTimeoutNAK)
|
||||
HIFI_LOG_EVENT(Retransmission)
|
||||
HIFI_LOG_EVENT(Duplicate)
|
||||
;
|
||||
#undef HIFI_LOG_EVENT
|
||||
|
||||
debug << " Sent packets: " << stats.sentPackets;
|
||||
debug << "\n Received packets: " << stats.receivedPackets;
|
||||
debug << "\n Sent util bytes: " << stats.sentUtilBytes;
|
||||
debug << "\n Sent bytes: " << stats.sentBytes;
|
||||
debug << "\n Received bytes: " << stats.receivedBytes << "\n";
|
||||
return debug;
|
||||
}
|
||||
|
|
|
@ -101,4 +101,7 @@ private:
|
|||
|
||||
}
|
||||
|
||||
class QDebug;
|
||||
QDebug& operator<<(QDebug&& debug, const udt::ConnectionStats::Stats& stats);
|
||||
|
||||
#endif // hifi_ConnectionStats_h
|
||||
|
|
|
@ -34,7 +34,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
|||
case PacketType::EntityPhysics:
|
||||
return static_cast<PacketVersion>(EntityVersion::MaterialData);
|
||||
case PacketType::EntityQuery:
|
||||
return static_cast<PacketVersion>(EntityQueryPacketVersion::RemovedJurisdictions);
|
||||
return static_cast<PacketVersion>(EntityQueryPacketVersion::MultiFrustumQuery);
|
||||
case PacketType::AvatarIdentity:
|
||||
case PacketType::AvatarData:
|
||||
case PacketType::BulkAvatarData:
|
||||
|
@ -90,6 +90,8 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
|||
return 18; // replace min_avatar_scale and max_avatar_scale with min_avatar_height and max_avatar_height
|
||||
case PacketType::Ping:
|
||||
return static_cast<PacketVersion>(PingVersion::IncludeConnectionID);
|
||||
case PacketType::ViewFrustum:
|
||||
return static_cast<PacketVersion>(ViewFrustumVersion::SendMultipleFrustums);
|
||||
default:
|
||||
return 20;
|
||||
}
|
||||
|
|
|
@ -244,7 +244,8 @@ enum class EntityQueryPacketVersion: PacketVersion {
|
|||
JSONFilter = 18,
|
||||
JSONFilterWithFamilyTree = 19,
|
||||
ConnectionIdentifier = 20,
|
||||
RemovedJurisdictions = 21
|
||||
RemovedJurisdictions = 21,
|
||||
MultiFrustumQuery = 22
|
||||
};
|
||||
|
||||
enum class AssetServerPacketVersion: PacketVersion {
|
||||
|
@ -327,4 +328,8 @@ enum class PingVersion : PacketVersion {
|
|||
IncludeConnectionID = 18
|
||||
};
|
||||
|
||||
enum class ViewFrustumVersion : PacketVersion {
|
||||
SendMultipleFrustums = 21
|
||||
};
|
||||
|
||||
#endif // hifi_PacketHeaders_h
|
||||
|
|
|
@ -59,7 +59,6 @@ const int LOW_RES_MOVING_ADJUST = 1;
|
|||
|
||||
class EncodeBitstreamParams {
|
||||
public:
|
||||
ViewFrustum viewFrustum;
|
||||
bool includeExistsBits;
|
||||
NodeData* nodeData;
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "OctreeQuery.h"
|
||||
|
||||
#include <random>
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
|
@ -16,23 +18,11 @@
|
|||
#include <GLMHelpers.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "OctreeConstants.h"
|
||||
#include "OctreeQuery.h"
|
||||
|
||||
const float DEFAULT_FOV = 45.0f; // degrees
|
||||
const float DEFAULT_ASPECT_RATIO = 1.0f;
|
||||
const float DEFAULT_NEAR_CLIP = 0.1f;
|
||||
const float DEFAULT_FAR_CLIP = 3.0f;
|
||||
|
||||
OctreeQuery::OctreeQuery(bool randomizeConnectionID) :
|
||||
_cameraFov(DEFAULT_FOV),
|
||||
_cameraAspectRatio(DEFAULT_ASPECT_RATIO),
|
||||
_cameraNearClip(DEFAULT_NEAR_CLIP),
|
||||
_cameraFarClip(DEFAULT_FAR_CLIP),
|
||||
_cameraCenterRadius(DEFAULT_FAR_CLIP)
|
||||
{
|
||||
_maxQueryPPS = DEFAULT_MAX_OCTREE_PPS;
|
||||
using QueryFlags = uint8_t;
|
||||
const QueryFlags QUERY_HAS_MAIN_FRUSTUM = 1U << 0;
|
||||
const QueryFlags QUERY_HAS_SECONDARY_FRUSTUM = 1U << 1;
|
||||
|
||||
OctreeQuery::OctreeQuery(bool randomizeConnectionID) {
|
||||
if (randomizeConnectionID) {
|
||||
// randomize our initial octree query connection ID using random_device
|
||||
// the connection ID is 16 bits so we take a generated 32 bit value from random device and chop off the top
|
||||
|
@ -47,26 +37,28 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
// pack the connection ID so the server can detect when we start a new connection
|
||||
memcpy(destinationBuffer, &_connectionID, sizeof(_connectionID));
|
||||
destinationBuffer += sizeof(_connectionID);
|
||||
|
||||
// back a boolean (cut to 1 byte) to designate if this query uses the sent view frustum
|
||||
memcpy(destinationBuffer, &_usesFrustum, sizeof(_usesFrustum));
|
||||
destinationBuffer += sizeof(_usesFrustum);
|
||||
|
||||
if (_usesFrustum) {
|
||||
// TODO: DRY this up to a shared method
|
||||
// that can pack any type given the number of bytes
|
||||
// and return the number of bytes to push the pointer
|
||||
|
||||
// camera details
|
||||
memcpy(destinationBuffer, &_cameraPosition, sizeof(_cameraPosition));
|
||||
destinationBuffer += sizeof(_cameraPosition);
|
||||
destinationBuffer += packOrientationQuatToBytes(destinationBuffer, _cameraOrientation);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _cameraFov);
|
||||
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _cameraAspectRatio);
|
||||
destinationBuffer += packClipValueToTwoByte(destinationBuffer, _cameraNearClip);
|
||||
destinationBuffer += packClipValueToTwoByte(destinationBuffer, _cameraFarClip);
|
||||
memcpy(destinationBuffer, &_cameraEyeOffsetPosition, sizeof(_cameraEyeOffsetPosition));
|
||||
destinationBuffer += sizeof(_cameraEyeOffsetPosition);
|
||||
|
||||
// flags for wether the frustums are present
|
||||
QueryFlags frustumFlags = 0;
|
||||
if (_hasMainFrustum) {
|
||||
frustumFlags |= QUERY_HAS_MAIN_FRUSTUM;
|
||||
}
|
||||
if (_hasSecondaryFrustum) {
|
||||
frustumFlags |= QUERY_HAS_SECONDARY_FRUSTUM;
|
||||
}
|
||||
memcpy(destinationBuffer, &frustumFlags, sizeof(frustumFlags));
|
||||
destinationBuffer += sizeof(frustumFlags);
|
||||
|
||||
if (_hasMainFrustum) {
|
||||
auto byteArray = _mainViewFrustum.toByteArray();
|
||||
memcpy(destinationBuffer, byteArray.constData(), byteArray.size());
|
||||
destinationBuffer += byteArray.size();
|
||||
}
|
||||
|
||||
if (_hasSecondaryFrustum) {
|
||||
auto byteArray = _secondaryViewFrustum.toByteArray();
|
||||
memcpy(destinationBuffer, byteArray.constData(), byteArray.size());
|
||||
destinationBuffer += byteArray.size();
|
||||
}
|
||||
|
||||
// desired Max Octree PPS
|
||||
|
@ -80,9 +72,6 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
// desired boundaryLevelAdjust
|
||||
memcpy(destinationBuffer, &_boundaryLevelAdjust, sizeof(_boundaryLevelAdjust));
|
||||
destinationBuffer += sizeof(_boundaryLevelAdjust);
|
||||
|
||||
memcpy(destinationBuffer, &_cameraCenterRadius, sizeof(_cameraCenterRadius));
|
||||
destinationBuffer += sizeof(_cameraCenterRadius);
|
||||
|
||||
// create a QByteArray that holds the binary representation of the JSON parameters
|
||||
QByteArray binaryParametersDocument;
|
||||
|
@ -110,6 +99,7 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
int OctreeQuery::parseData(ReceivedMessage& message) {
|
||||
|
||||
const unsigned char* startPosition = reinterpret_cast<const unsigned char*>(message.getRawMessage());
|
||||
const unsigned char* endPosition = startPosition + message.getSize();
|
||||
const unsigned char* sourceBuffer = startPosition;
|
||||
|
||||
// unpack the connection ID
|
||||
|
@ -133,20 +123,23 @@ int OctreeQuery::parseData(ReceivedMessage& message) {
|
|||
}
|
||||
|
||||
// check if this query uses a view frustum
|
||||
memcpy(&_usesFrustum, sourceBuffer, sizeof(_usesFrustum));
|
||||
sourceBuffer += sizeof(_usesFrustum);
|
||||
|
||||
if (_usesFrustum) {
|
||||
// unpack camera details
|
||||
memcpy(&_cameraPosition, sourceBuffer, sizeof(_cameraPosition));
|
||||
sourceBuffer += sizeof(_cameraPosition);
|
||||
sourceBuffer += unpackOrientationQuatFromBytes(sourceBuffer, _cameraOrientation);
|
||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_cameraFov);
|
||||
sourceBuffer += unpackFloatRatioFromTwoByte(sourceBuffer,_cameraAspectRatio);
|
||||
sourceBuffer += unpackClipValueFromTwoByte(sourceBuffer,_cameraNearClip);
|
||||
sourceBuffer += unpackClipValueFromTwoByte(sourceBuffer,_cameraFarClip);
|
||||
memcpy(&_cameraEyeOffsetPosition, sourceBuffer, sizeof(_cameraEyeOffsetPosition));
|
||||
sourceBuffer += sizeof(_cameraEyeOffsetPosition);
|
||||
QueryFlags frustumFlags { 0 };
|
||||
memcpy(&frustumFlags, sourceBuffer, sizeof(frustumFlags));
|
||||
sourceBuffer += sizeof(frustumFlags);
|
||||
|
||||
_hasMainFrustum = frustumFlags & QUERY_HAS_MAIN_FRUSTUM;
|
||||
_hasSecondaryFrustum = frustumFlags & QUERY_HAS_SECONDARY_FRUSTUM;
|
||||
|
||||
if (_hasMainFrustum) {
|
||||
auto bytesLeft = endPosition - sourceBuffer;
|
||||
auto byteArray = QByteArray::fromRawData(reinterpret_cast<const char*>(sourceBuffer), bytesLeft);
|
||||
sourceBuffer += _mainViewFrustum.fromByteArray(byteArray);
|
||||
}
|
||||
|
||||
if (_hasSecondaryFrustum) {
|
||||
auto bytesLeft = endPosition - sourceBuffer;
|
||||
auto byteArray = QByteArray::fromRawData(reinterpret_cast<const char*>(sourceBuffer), bytesLeft);
|
||||
sourceBuffer += _secondaryViewFrustum.fromByteArray(byteArray);
|
||||
}
|
||||
|
||||
// desired Max Octree PPS
|
||||
|
@ -161,9 +154,6 @@ int OctreeQuery::parseData(ReceivedMessage& message) {
|
|||
memcpy(&_boundaryLevelAdjust, sourceBuffer, sizeof(_boundaryLevelAdjust));
|
||||
sourceBuffer += sizeof(_boundaryLevelAdjust);
|
||||
|
||||
memcpy(&_cameraCenterRadius, sourceBuffer, sizeof(_cameraCenterRadius));
|
||||
sourceBuffer += sizeof(_cameraCenterRadius);
|
||||
|
||||
// check if we have a packed JSON filter
|
||||
uint16_t binaryParametersBytes;
|
||||
memcpy(&binaryParametersBytes, sourceBuffer, sizeof(binaryParametersBytes));
|
||||
|
@ -184,8 +174,3 @@ int OctreeQuery::parseData(ReceivedMessage& message) {
|
|||
|
||||
return sourceBuffer - startPosition;
|
||||
}
|
||||
|
||||
glm::vec3 OctreeQuery::calculateCameraDirection() const {
|
||||
glm::vec3 direction = glm::vec3(_cameraOrientation * glm::vec4(IDENTITY_FORWARD, 0.0f));
|
||||
return direction;
|
||||
}
|
||||
|
|
|
@ -12,16 +12,14 @@
|
|||
#ifndef hifi_OctreeQuery_h
|
||||
#define hifi_OctreeQuery_h
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QReadWriteLock>
|
||||
|
||||
#include <NodeData.h>
|
||||
|
||||
#include <ViewFrustum.h>
|
||||
|
||||
#include "OctreeConstants.h"
|
||||
|
||||
class OctreeQuery : public NodeData {
|
||||
Q_OBJECT
|
||||
|
@ -30,31 +28,22 @@ public:
|
|||
OctreeQuery(bool randomizeConnectionID = false);
|
||||
virtual ~OctreeQuery() {}
|
||||
|
||||
OctreeQuery(const OctreeQuery&) = delete;
|
||||
OctreeQuery& operator=(const OctreeQuery&) = delete;
|
||||
|
||||
int getBroadcastData(unsigned char* destinationBuffer);
|
||||
int parseData(ReceivedMessage& message) override;
|
||||
|
||||
// getters for camera details
|
||||
const glm::vec3& getCameraPosition() const { return _cameraPosition; }
|
||||
const glm::quat& getCameraOrientation() const { return _cameraOrientation; }
|
||||
float getCameraFov() const { return _cameraFov; }
|
||||
float getCameraAspectRatio() const { return _cameraAspectRatio; }
|
||||
float getCameraNearClip() const { return _cameraNearClip; }
|
||||
float getCameraFarClip() const { return _cameraFarClip; }
|
||||
const glm::vec3& getCameraEyeOffsetPosition() const { return _cameraEyeOffsetPosition; }
|
||||
float getCameraCenterRadius() const { return _cameraCenterRadius; }
|
||||
bool hasMainViewFrustum() const { return _hasMainFrustum; }
|
||||
void setMainViewFrustum(const ViewFrustum& viewFrustum) { _hasMainFrustum = true; _mainViewFrustum = viewFrustum; }
|
||||
void clearMainViewFrustum() { _hasMainFrustum = false; }
|
||||
const ViewFrustum& getMainViewFrustum() const { return _mainViewFrustum; }
|
||||
|
||||
glm::vec3 calculateCameraDirection() const;
|
||||
bool hasSecondaryViewFrustum() const { return _hasSecondaryFrustum; }
|
||||
void setSecondaryViewFrustum(const ViewFrustum& viewFrustum) { _hasSecondaryFrustum = true; _secondaryViewFrustum = viewFrustum; }
|
||||
void clearSecondaryViewFrustum() { _hasSecondaryFrustum = false; }
|
||||
const ViewFrustum& getSecondaryViewFrustum() const { return _secondaryViewFrustum; }
|
||||
|
||||
// setters for camera details
|
||||
void setCameraPosition(const glm::vec3& position) { _cameraPosition = position; }
|
||||
void setCameraOrientation(const glm::quat& orientation) { _cameraOrientation = orientation; }
|
||||
void setCameraFov(float fov) { _cameraFov = fov; }
|
||||
void setCameraAspectRatio(float aspectRatio) { _cameraAspectRatio = aspectRatio; }
|
||||
void setCameraNearClip(float nearClip) { _cameraNearClip = nearClip; }
|
||||
void setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
|
||||
void setCameraEyeOffsetPosition(const glm::vec3& eyeOffsetPosition) { _cameraEyeOffsetPosition = eyeOffsetPosition; }
|
||||
void setCameraCenterRadius(float radius) { _cameraCenterRadius = radius; }
|
||||
|
||||
// getters/setters for JSON filter
|
||||
QJsonObject getJSONParameters() { QReadLocker locker { &_jsonParametersLock }; return _jsonParameters; }
|
||||
void setJSONParameters(const QJsonObject& jsonParameters)
|
||||
|
@ -64,9 +53,6 @@ public:
|
|||
int getMaxQueryPacketsPerSecond() const { return _maxQueryPPS; }
|
||||
float getOctreeSizeScale() const { return _octreeElementSizeScale; }
|
||||
int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; }
|
||||
|
||||
bool getUsesFrustum() { return _usesFrustum; }
|
||||
void setUsesFrustum(bool usesFrustum) { _usesFrustum = usesFrustum; }
|
||||
|
||||
void incrementConnectionID() { ++_connectionID; }
|
||||
|
||||
|
@ -81,33 +67,22 @@ public slots:
|
|||
void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; }
|
||||
|
||||
protected:
|
||||
// camera details for the avatar
|
||||
glm::vec3 _cameraPosition { glm::vec3(0.0f) };
|
||||
glm::quat _cameraOrientation { glm::quat() };
|
||||
float _cameraFov;
|
||||
float _cameraAspectRatio;
|
||||
float _cameraNearClip;
|
||||
float _cameraFarClip;
|
||||
float _cameraCenterRadius;
|
||||
glm::vec3 _cameraEyeOffsetPosition { glm::vec3(0.0f) };
|
||||
bool _hasMainFrustum { false };
|
||||
ViewFrustum _mainViewFrustum;
|
||||
bool _hasSecondaryFrustum { false };
|
||||
ViewFrustum _secondaryViewFrustum;
|
||||
|
||||
// octree server sending items
|
||||
int _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS;
|
||||
float _octreeElementSizeScale = DEFAULT_OCTREE_SIZE_SCALE; /// used for LOD calculations
|
||||
int _boundaryLevelAdjust = 0; /// used for LOD calculations
|
||||
|
||||
uint8_t _usesFrustum = true;
|
||||
|
||||
uint16_t _connectionID; // query connection ID, randomized to start, increments with each new connection to server
|
||||
|
||||
QJsonObject _jsonParameters;
|
||||
QReadWriteLock _jsonParametersLock;
|
||||
|
||||
bool _hasReceivedFirstQuery { false };
|
||||
|
||||
private:
|
||||
// privatize the copy constructor and assignment operator so they cannot be called
|
||||
OctreeQuery(const OctreeQuery&);
|
||||
OctreeQuery& operator= (const OctreeQuery&);
|
||||
};
|
||||
|
||||
#endif // hifi_OctreeQuery_h
|
||||
|
|
|
@ -139,9 +139,14 @@ void OctreeQueryNode::writeToPacket(const unsigned char* buffer, unsigned int by
|
|||
}
|
||||
}
|
||||
|
||||
void OctreeQueryNode::copyCurrentViewFrustum(ViewFrustum& viewOut) const {
|
||||
void OctreeQueryNode::copyCurrentMainViewFrustum(ViewFrustum& viewOut) const {
|
||||
QMutexLocker viewLocker(&_viewMutex);
|
||||
viewOut = _currentViewFrustum;
|
||||
viewOut = _currentMainViewFrustum;
|
||||
}
|
||||
|
||||
void OctreeQueryNode::copyCurrentSecondaryViewFrustum(ViewFrustum& viewOut) const {
|
||||
QMutexLocker viewLocker(&_viewMutex);
|
||||
viewOut = _currentSecondaryViewFrustum;
|
||||
}
|
||||
|
||||
bool OctreeQueryNode::updateCurrentViewFrustum() {
|
||||
|
@ -150,70 +155,50 @@ bool OctreeQueryNode::updateCurrentViewFrustum() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!_usesFrustum) {
|
||||
if (!_hasMainFrustum && !_hasSecondaryFrustum) {
|
||||
// this client does not use a view frustum so the view frustum for this query has not changed
|
||||
return false;
|
||||
} else {
|
||||
bool currentViewFrustumChanged = false;
|
||||
|
||||
ViewFrustum newestViewFrustum;
|
||||
// get position and orientation details from the camera
|
||||
newestViewFrustum.setPosition(getCameraPosition());
|
||||
newestViewFrustum.setOrientation(getCameraOrientation());
|
||||
|
||||
newestViewFrustum.setCenterRadius(getCameraCenterRadius());
|
||||
|
||||
// Also make sure it's got the correct lens details from the camera
|
||||
float originalFOV = getCameraFov();
|
||||
float wideFOV = originalFOV + VIEW_FRUSTUM_FOV_OVERSEND;
|
||||
|
||||
if (0.0f != getCameraAspectRatio() &&
|
||||
0.0f != getCameraNearClip() &&
|
||||
0.0f != getCameraFarClip() &&
|
||||
getCameraNearClip() != getCameraFarClip()) {
|
||||
newestViewFrustum.setProjection(glm::perspective(
|
||||
glm::radians(wideFOV), // hack
|
||||
getCameraAspectRatio(),
|
||||
getCameraNearClip(),
|
||||
getCameraFarClip()));
|
||||
newestViewFrustum.calculate();
|
||||
}
|
||||
|
||||
|
||||
{ // if there has been a change, then recalculate
|
||||
QMutexLocker viewLocker(&_viewMutex);
|
||||
if (!newestViewFrustum.isVerySimilar(_currentViewFrustum)) {
|
||||
_currentViewFrustum = newestViewFrustum;
|
||||
currentViewFrustumChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Also check for LOD changes from the client
|
||||
if (_lodInitialized) {
|
||||
if (_lastClientBoundaryLevelAdjust != getBoundaryLevelAdjust()) {
|
||||
_lastClientBoundaryLevelAdjust = getBoundaryLevelAdjust();
|
||||
_lodChanged = true;
|
||||
}
|
||||
if (_lastClientOctreeSizeScale != getOctreeSizeScale()) {
|
||||
_lastClientOctreeSizeScale = getOctreeSizeScale();
|
||||
_lodChanged = true;
|
||||
}
|
||||
} else {
|
||||
_lodInitialized = true;
|
||||
_lastClientOctreeSizeScale = getOctreeSizeScale();
|
||||
_lastClientBoundaryLevelAdjust = getBoundaryLevelAdjust();
|
||||
_lodChanged = false;
|
||||
}
|
||||
|
||||
// When we first detect that the view stopped changing, we record this.
|
||||
// but we don't change it back to false until we've completely sent this
|
||||
// scene.
|
||||
if (_viewFrustumChanging && !currentViewFrustumChanged) {
|
||||
_viewFrustumJustStoppedChanging = true;
|
||||
}
|
||||
_viewFrustumChanging = currentViewFrustumChanged;
|
||||
return currentViewFrustumChanged;
|
||||
}
|
||||
|
||||
bool currentViewFrustumChanged = false;
|
||||
|
||||
{ // if there has been a change, then recalculate
|
||||
QMutexLocker viewLocker(&_viewMutex);
|
||||
if (_hasMainFrustum && !_mainViewFrustum.isVerySimilar(_currentMainViewFrustum)) {
|
||||
_currentMainViewFrustum = _mainViewFrustum;
|
||||
currentViewFrustumChanged = true;
|
||||
}
|
||||
if (_hasSecondaryFrustum && !_secondaryViewFrustum.isVerySimilar(_currentSecondaryViewFrustum)) {
|
||||
_currentSecondaryViewFrustum = _secondaryViewFrustum;
|
||||
currentViewFrustumChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Also check for LOD changes from the client
|
||||
if (_lodInitialized) {
|
||||
if (_lastClientBoundaryLevelAdjust != getBoundaryLevelAdjust()) {
|
||||
_lastClientBoundaryLevelAdjust = getBoundaryLevelAdjust();
|
||||
_lodChanged = true;
|
||||
}
|
||||
if (_lastClientOctreeSizeScale != getOctreeSizeScale()) {
|
||||
_lastClientOctreeSizeScale = getOctreeSizeScale();
|
||||
_lodChanged = true;
|
||||
}
|
||||
} else {
|
||||
_lodInitialized = true;
|
||||
_lastClientOctreeSizeScale = getOctreeSizeScale();
|
||||
_lastClientBoundaryLevelAdjust = getBoundaryLevelAdjust();
|
||||
_lodChanged = false;
|
||||
}
|
||||
|
||||
// When we first detect that the view stopped changing, we record this.
|
||||
// but we don't change it back to false until we've completely sent this
|
||||
// scene.
|
||||
if (_viewFrustumChanging && !currentViewFrustumChanged) {
|
||||
_viewFrustumJustStoppedChanging = true;
|
||||
}
|
||||
_viewFrustumChanging = currentViewFrustumChanged;
|
||||
return currentViewFrustumChanged;
|
||||
}
|
||||
|
||||
void OctreeQueryNode::setViewSent(bool viewSent) {
|
||||
|
|
|
@ -49,7 +49,8 @@ public:
|
|||
|
||||
OctreeElementExtraEncodeData extraEncodeData;
|
||||
|
||||
void copyCurrentViewFrustum(ViewFrustum& viewOut) const;
|
||||
void copyCurrentMainViewFrustum(ViewFrustum& viewOut) const;
|
||||
void copyCurrentSecondaryViewFrustum(ViewFrustum& viewOut) const;
|
||||
|
||||
// These are not classic setters because they are calculating and maintaining state
|
||||
// which is set asynchronously through the network receive
|
||||
|
@ -87,9 +88,6 @@ public:
|
|||
void setShouldForceFullScene(bool shouldForceFullScene) { _shouldForceFullScene = shouldForceFullScene; }
|
||||
|
||||
private:
|
||||
OctreeQueryNode(const OctreeQueryNode &);
|
||||
OctreeQueryNode& operator= (const OctreeQueryNode&);
|
||||
|
||||
bool _viewSent { false };
|
||||
std::unique_ptr<NLPacket> _octreePacket;
|
||||
bool _octreePacketWaiting;
|
||||
|
@ -99,7 +97,8 @@ private:
|
|||
quint64 _firstSuppressedPacket { usecTimestampNow() };
|
||||
|
||||
mutable QMutex _viewMutex { QMutex::Recursive };
|
||||
ViewFrustum _currentViewFrustum;
|
||||
ViewFrustum _currentMainViewFrustum;
|
||||
ViewFrustum _currentSecondaryViewFrustum;
|
||||
bool _viewFrustumChanging { false };
|
||||
bool _viewFrustumJustStoppedChanging { true };
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <glm/glm.hpp>
|
||||
|
||||
#include <AABox.h>
|
||||
#include <AACube.h>
|
||||
|
||||
float calculateRenderAccuracy(const glm::vec3& position,
|
||||
const AABox& bounds,
|
||||
|
@ -73,4 +74,10 @@ float getOrthographicAccuracySize(float octreeSizeScale, int boundaryLevelAdjust
|
|||
// Smallest visible element is 1cm
|
||||
const float smallestSize = 0.01f;
|
||||
return (smallestSize * MAX_VISIBILITY_DISTANCE_FOR_UNIT_ELEMENT) / boundaryDistanceForRenderLevel(boundaryLevelAdjust, octreeSizeScale);
|
||||
}
|
||||
}
|
||||
|
||||
bool isAngularSizeBigEnough(glm::vec3 position, const AACube& cube, float lodScaleFactor, float minDiameter) {
|
||||
float distance = glm::distance(cube.calcCenter(), position) + MIN_VISIBLE_DISTANCE;
|
||||
float angularDiameter = cube.getScale() / distance;
|
||||
return angularDiameter > minDiameter * lodScaleFactor;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "OctreeConstants.h"
|
||||
|
||||
class AABox;
|
||||
class AACube;
|
||||
class QJsonDocument;
|
||||
|
||||
/// renderAccuracy represents a floating point "visibility" of an object based on it's view from the camera. At a simple
|
||||
|
@ -36,4 +37,6 @@ const float SQRT_THREE = 1.73205080f;
|
|||
const float MIN_ENTITY_ANGULAR_DIAMETER = MIN_ELEMENT_ANGULAR_DIAMETER * SQRT_THREE;
|
||||
const float MIN_VISIBLE_DISTANCE = 0.0001f; // helps avoid divide-by-zero check
|
||||
|
||||
bool isAngularSizeBigEnough(glm::vec3 position, const AACube& cube, float lodScaleFactor, float minDiameter);
|
||||
|
||||
#endif // hifi_OctreeUtils_h
|
||||
|
|
|
@ -31,6 +31,10 @@ public:
|
|||
/// copies the current view frustum for rendering the view state
|
||||
virtual void copyCurrentViewFrustum(ViewFrustum& viewOut) const = 0;
|
||||
|
||||
virtual void copyViewFrustum(ViewFrustum& viewOut) const = 0;
|
||||
virtual void copySecondaryViewFrustum(ViewFrustum& viewOut) const = 0;
|
||||
virtual bool hasSecondaryViewFrustum() const = 0;
|
||||
|
||||
virtual QThread* getMainThread() = 0;
|
||||
|
||||
virtual PickRay computePickRay(float x, float y) const = 0;
|
||||
|
|
|
@ -189,7 +189,6 @@ const int AntialiasingPass_NextMapSlot = 4;
|
|||
|
||||
Antialiasing::Antialiasing(bool isSharpenEnabled) :
|
||||
_isSharpenEnabled{ isSharpenEnabled } {
|
||||
_antialiasingBuffers = std::make_shared<gpu::FramebufferSwapChain>(2U);
|
||||
}
|
||||
|
||||
Antialiasing::~Antialiasing() {
|
||||
|
@ -325,25 +324,25 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
|||
int width = sourceBuffer->getWidth();
|
||||
int height = sourceBuffer->getHeight();
|
||||
|
||||
if (_antialiasingBuffers->get(0)) {
|
||||
if (_antialiasingBuffers->get(0)->getSize() != uvec2(width, height)) {// || (sourceBuffer && (_antialiasingBuffer->getRenderBuffer(1) != sourceBuffer->getRenderBuffer(0)))) {
|
||||
_antialiasingBuffers->edit(0).reset();
|
||||
_antialiasingBuffers->edit(1).reset();
|
||||
_antialiasingTextures[0].reset();
|
||||
_antialiasingTextures[1].reset();
|
||||
}
|
||||
if (_antialiasingBuffers && _antialiasingBuffers->get(0) && _antialiasingBuffers->get(0)->getSize() != uvec2(width, height)) {
|
||||
_antialiasingBuffers.reset();
|
||||
_antialiasingTextures[0].reset();
|
||||
_antialiasingTextures[1].reset();
|
||||
}
|
||||
|
||||
if (!_antialiasingBuffers->get(0)) {
|
||||
|
||||
if (!_antialiasingBuffers) {
|
||||
std::vector<gpu::FramebufferPointer> antiAliasingBuffers;
|
||||
// Link the antialiasing FBO to texture
|
||||
auto format = sourceBuffer->getRenderBuffer(0)->getTexelFormat();
|
||||
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR, gpu::Sampler::WRAP_CLAMP);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
auto& antiAliasingBuffer = _antialiasingBuffers->edit(i);
|
||||
antiAliasingBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("antialiasing"));
|
||||
antiAliasingBuffers.emplace_back(gpu::Framebuffer::create("antialiasing"));
|
||||
const auto& antiAliasingBuffer = antiAliasingBuffers.back();
|
||||
_antialiasingTextures[i] = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, defaultSampler);
|
||||
antiAliasingBuffer->setRenderBuffer(0, _antialiasingTextures[i]);
|
||||
}
|
||||
_antialiasingBuffers = std::make_shared<gpu::FramebufferSwapChain>(antiAliasingBuffers);
|
||||
}
|
||||
|
||||
gpu::doInBatch("Antialiasing::run", args->_context, [&](gpu::Batch& batch) {
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
/**jsdoc
|
||||
* The Assets API allows you to communicate with the Asset Browser.
|
||||
* @namespace Assets
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*/
|
||||
class AssetScriptingInterface : public BaseAssetScriptingInterface, QScriptable {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -35,6 +35,12 @@
|
|||
* of gimbal lock.
|
||||
* @namespace Quat
|
||||
* @variation 0
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property IDENTITY {Quat} <code>{ x: 0, y: 0, z: 0, w: 1 }</code> : The identity rotation, i.e., no rotation.
|
||||
* <em>Read-only.</em>
|
||||
* @example <caption>Print the <code>IDENTITY</code> value.</caption>
|
||||
|
|
|
@ -25,6 +25,10 @@ class QScriptValue;
|
|||
|
||||
/**jsdoc
|
||||
* @namespace Recording
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-assignment-client
|
||||
*/
|
||||
class RecordingScriptingInterface : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -112,6 +112,10 @@ namespace SceneScripting {
|
|||
|
||||
/**jsdoc
|
||||
* @class Scene.Stage
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {string} backgroundMode
|
||||
* @property {Scene.Stage.KeyLight} keyLight
|
||||
* @property {Scene.Stage.Location} location
|
||||
|
@ -171,6 +175,10 @@ namespace SceneScripting {
|
|||
|
||||
/**jsdoc
|
||||
* @namespace Scene
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {boolean} shouldRenderAvatars
|
||||
* @property {boolean} shouldRenderEntities
|
||||
* @property {Scene.Stage} stage
|
||||
|
|
|
@ -89,6 +89,12 @@ public:
|
|||
|
||||
/**jsdoc
|
||||
* @namespace Script
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property {string} context
|
||||
*/
|
||||
class ScriptEngine : public BaseScriptEngine, public EntitiesScriptEngineProvider {
|
||||
|
|
|
@ -29,6 +29,10 @@ class ScriptEngine;
|
|||
|
||||
/**jsdoc
|
||||
* @namespace ScriptDiscoveryService
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*
|
||||
* @property {string} debugScriptUrl
|
||||
* @property {string} defaultScriptsPath
|
||||
* @property {ScriptsModel} scriptsModel
|
||||
|
|
|
@ -23,6 +23,12 @@
|
|||
* hexadecimal digits.
|
||||
*
|
||||
* @namespace Uuid
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property NULL {Uuid} The null UUID, <code>{00000000-0000-0000-0000-000000000000}</code>.
|
||||
*/
|
||||
|
||||
|
|
|
@ -68,6 +68,9 @@ public:
|
|||
* <p>Has properties and functions below in addition to those of <a href="http://doc.qt.io/qt-5/qabstractitemmodel.html">
|
||||
* http://doc.qt.io/qt-5/qabstractitemmodel.html</a>.</p>
|
||||
* @class ScriptsModel
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
class ScriptsModel : public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
* <p>Has properties and functions per <a href="http://doc.qt.io/qt-5/qsortfilterproxymodel.html">
|
||||
* http://doc.qt.io/qt-5/qsortfilterproxymodel.html</a>.</p>
|
||||
* @class ScriptsModelFilter
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
*/
|
||||
class ScriptsModelFilter : public QSortFilterProxyModel {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -18,7 +18,12 @@
|
|||
|
||||
/**jsdoc
|
||||
* @namespace Users
|
||||
* @property {boolean} canKick - <code>true</code> if the domain server allows the node or avatar to kick (ban) avatars,
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property {boolean} canKick - <code>true</code> if the domain server allows the node or avatar to kick (ban) avatars,
|
||||
* otherwise <code>false</code>. <em>Read-only.</em>
|
||||
* @property {boolean} requestsDomainListData - <code>true</code> if the avatar requests extra data from the mixers (such as
|
||||
* positional data of an avatar you've ignored). <em>Read-only.</em>
|
||||
|
|
|
@ -47,6 +47,12 @@
|
|||
*
|
||||
* @namespace Vec3
|
||||
* @variation 0
|
||||
*
|
||||
* @hifi-interface
|
||||
* @hifi-client-entity
|
||||
* @hifi-server-entity
|
||||
* @hifi-assignment-client
|
||||
*
|
||||
* @property {Vec3} UNIT_X - <code>{ x: 1, y: 0, z: 0 }</code> : Unit vector in the x-axis direction. <em>Read-only.</em>
|
||||
* @property {Vec3} UNIT_Y - <code>{ x: 0, y: 1, z: 0 }</code> : Unit vector in the y-axis direction. <em>Read-only.</em>
|
||||
* @property {Vec3} UNIT_Z - <code>{ x: 0, y: 0, z: 1 }</code> : Unit vector in the z-axis direction. <em>Read-only.</em>
|
||||
|
|
77
libraries/shared/src/CrashHelpers.cpp
Normal file
77
libraries/shared/src/CrashHelpers.cpp
Normal file
|
@ -0,0 +1,77 @@
|
|||
//
|
||||
// CrashHelpers.cpp
|
||||
// libraries/shared/src
|
||||
//
|
||||
// Created by Clement Brisset on 4/30/18.
|
||||
// Copyright 2018 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 "CrashHelpers.h"
|
||||
|
||||
namespace crash {
|
||||
|
||||
class B;
|
||||
class A {
|
||||
public:
|
||||
A(B* b) : _b(b) { }
|
||||
~A();
|
||||
virtual void virtualFunction() = 0;
|
||||
|
||||
private:
|
||||
B* _b;
|
||||
};
|
||||
|
||||
class B : public A {
|
||||
public:
|
||||
B() : A(this) { }
|
||||
virtual void virtualFunction() override { }
|
||||
};
|
||||
|
||||
A::~A() {
|
||||
_b->virtualFunction();
|
||||
}
|
||||
|
||||
void pureVirtualCall() {
|
||||
qCDebug(shared) << "About to make a pure virtual call";
|
||||
B b;
|
||||
}
|
||||
|
||||
void doubleFree() {
|
||||
qCDebug(shared) << "About to double delete memory";
|
||||
int* blah = new int(200);
|
||||
delete blah;
|
||||
delete blah;
|
||||
}
|
||||
|
||||
void nullDeref() {
|
||||
qCDebug(shared) << "About to dereference a null pointer";
|
||||
int* p = nullptr;
|
||||
*p = 1;
|
||||
}
|
||||
|
||||
void doAbort() {
|
||||
qCDebug(shared) << "About to abort";
|
||||
abort();
|
||||
}
|
||||
|
||||
void outOfBoundsVectorCrash() {
|
||||
qCDebug(shared) << "std::vector out of bounds crash!";
|
||||
std::vector<int> v;
|
||||
v[0] = 42;
|
||||
}
|
||||
|
||||
void newFault() {
|
||||
qCDebug(shared) << "About to crash inside new fault";
|
||||
|
||||
// Force crash with multiple large allocations
|
||||
while (true) {
|
||||
const size_t GIGABYTE = 1024 * 1024 * 1024;
|
||||
new char[GIGABYTE];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue