mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
Merge remote-tracking branch 'upstream/master' into feature/quest
This commit is contained in:
commit
79369a0c83
14 changed files with 149 additions and 51 deletions
|
@ -627,8 +627,6 @@ public:
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NestableType::Entity:
|
case NestableType::Entity:
|
||||||
return getEntityModelProvider(static_cast<EntityItemID>(uuid));
|
return getEntityModelProvider(static_cast<EntityItemID>(uuid));
|
||||||
case NestableType::Overlay:
|
|
||||||
return nullptr;
|
|
||||||
case NestableType::Avatar:
|
case NestableType::Avatar:
|
||||||
return getAvatarModelProvider(uuid);
|
return getAvatarModelProvider(uuid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,10 @@ public:
|
||||||
static glm::vec3 intersectRayWithEntityXYPlane(const QUuid& entityID, const glm::vec3& origin, const glm::vec3& direction);
|
static glm::vec3 intersectRayWithEntityXYPlane(const QUuid& entityID, const glm::vec3& origin, const glm::vec3& direction);
|
||||||
static glm::vec2 projectOntoEntityXYPlane(const QUuid& entityID, const glm::vec3& worldPos, bool unNormalized = true);
|
static glm::vec2 projectOntoEntityXYPlane(const QUuid& entityID, const glm::vec3& worldPos, bool unNormalized = true);
|
||||||
|
|
||||||
|
static glm::vec2 projectOntoXYPlane(const glm::vec3& worldPos, const glm::vec3& position, const glm::quat& rotation, const glm::vec3& dimensions, const glm::vec3& registrationPoint, bool unNormalized);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static glm::vec3 intersectRayWithXYPlane(const glm::vec3& origin, const glm::vec3& direction, const glm::vec3& point, const glm::quat& rotation, const glm::vec3& registration);
|
static glm::vec3 intersectRayWithXYPlane(const glm::vec3& origin, const glm::vec3& direction, const glm::vec3& point, const glm::quat& rotation, const glm::vec3& registration);
|
||||||
static glm::vec2 projectOntoXYPlane(const glm::vec3& worldPos, const glm::vec3& position, const glm::quat& rotation, const glm::vec3& dimensions, const glm::vec3& registrationPoint, bool unNormalized);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_RayPick_h
|
#endif // hifi_RayPick_h
|
||||||
|
|
|
@ -137,13 +137,14 @@ PickResultPointer StylusPick::getDefaultResult(const QVariantMap& pickVariant) c
|
||||||
}
|
}
|
||||||
|
|
||||||
PickResultPointer StylusPick::getEntityIntersection(const StylusTip& pick) {
|
PickResultPointer StylusPick::getEntityIntersection(const StylusTip& pick) {
|
||||||
|
auto entityTree = qApp->getEntities()->getTree();
|
||||||
StylusPickResult nearestTarget(pick.toVariantMap());
|
StylusPickResult nearestTarget(pick.toVariantMap());
|
||||||
for (const auto& target : getIncludeItems()) {
|
for (const auto& target : getIncludeItems()) {
|
||||||
if (target.isNull()) {
|
if (target.isNull()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto entity = qApp->getEntities()->getTree()->findEntityByEntityItemID(target);
|
auto entity = entityTree->findEntityByEntityItemID(target);
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -158,8 +159,11 @@ PickResultPointer StylusPick::getEntityIntersection(const StylusTip& pick) {
|
||||||
glm::vec3 normal = entityRotation * Vectors::UNIT_Z;
|
glm::vec3 normal = entityRotation * Vectors::UNIT_Z;
|
||||||
float distance = glm::dot(pick.position - entityPosition, normal);
|
float distance = glm::dot(pick.position - entityPosition, normal);
|
||||||
if (distance < nearestTarget.distance) {
|
if (distance < nearestTarget.distance) {
|
||||||
|
const auto entityDimensions = entity->getScaledDimensions();
|
||||||
|
const auto entityRegistrationPoint = entity->getRegistrationPoint();
|
||||||
glm::vec3 intersection = pick.position - (normal * distance);
|
glm::vec3 intersection = pick.position - (normal * distance);
|
||||||
glm::vec2 pos2D = RayPick::projectOntoEntityXYPlane(target, intersection, false);
|
glm::vec2 pos2D = RayPick::projectOntoXYPlane(intersection, entityPosition, entityRotation,
|
||||||
|
entityDimensions, entityRegistrationPoint, false);
|
||||||
if (pos2D == glm::clamp(pos2D, glm::vec2(0), glm::vec2(1))) {
|
if (pos2D == glm::clamp(pos2D, glm::vec2(0), glm::vec2(1))) {
|
||||||
IntersectionType type = IntersectionType::ENTITY;
|
IntersectionType type = IntersectionType::ENTITY;
|
||||||
if (getFilter().doesPickLocalEntities()) {
|
if (getFilter().doesPickLocalEntities()) {
|
||||||
|
|
|
@ -309,12 +309,22 @@ void Keyboard::setRaised(bool raised) {
|
||||||
_layerIndex = 0;
|
_layerIndex = 0;
|
||||||
_capsEnabled = false;
|
_capsEnabled = false;
|
||||||
_typedCharacters.clear();
|
_typedCharacters.clear();
|
||||||
|
addIncludeItemsToMallets();
|
||||||
});
|
});
|
||||||
|
|
||||||
updateTextDisplay();
|
updateTextDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Keyboard::addIncludeItemsToMallets() {
|
||||||
|
if (_layerIndex >= 0 && _layerIndex < (int)_keyboardLayers.size()) {
|
||||||
|
QVector<QUuid> includeItems = _keyboardLayers[_layerIndex].keys().toVector();
|
||||||
|
auto pointerManager = DependencyManager::get<PointerManager>();
|
||||||
|
pointerManager->setIncludeItems(_leftHandStylus, includeItems);
|
||||||
|
pointerManager->setIncludeItems(_rightHandStylus, includeItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Keyboard::updateTextDisplay() {
|
void Keyboard::updateTextDisplay() {
|
||||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||||
|
@ -463,6 +473,8 @@ void Keyboard::switchToLayer(int layerIndex) {
|
||||||
properties.setRotation(currentOrientation);
|
properties.setRotation(currentOrientation);
|
||||||
entityScriptingInterface->editEntity(_anchor.entityID, properties);
|
entityScriptingInterface->editEntity(_anchor.entityID, properties);
|
||||||
|
|
||||||
|
addIncludeItemsToMallets();
|
||||||
|
|
||||||
startLayerSwitchTimer();
|
startLayerSwitchTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -718,8 +730,6 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) {
|
||||||
clearKeyboardKeys();
|
clearKeyboardKeys();
|
||||||
auto requestData = request->getData();
|
auto requestData = request->getData();
|
||||||
|
|
||||||
QVector<QUuid> includeItems;
|
|
||||||
|
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(requestData, &parseError);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(requestData, &parseError);
|
||||||
|
|
||||||
|
@ -840,7 +850,6 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) {
|
||||||
key.setKeyString(keyString);
|
key.setKeyString(keyString);
|
||||||
key.saveDimensionsAndLocalPosition();
|
key.saveDimensionsAndLocalPosition();
|
||||||
|
|
||||||
includeItems.append(key.getID());
|
|
||||||
_itemsToIgnore.insert(key.getID());
|
_itemsToIgnore.insert(key.getID());
|
||||||
keyboardLayerKeys.insert(id, key);
|
keyboardLayerKeys.insert(id, key);
|
||||||
}
|
}
|
||||||
|
@ -886,9 +895,7 @@ void Keyboard::loadKeyboardFile(const QString& keyboardFile) {
|
||||||
_itemsToIgnore.insert(_anchor.entityID);
|
_itemsToIgnore.insert(_anchor.entityID);
|
||||||
});
|
});
|
||||||
_layerIndex = 0;
|
_layerIndex = 0;
|
||||||
auto pointerManager = DependencyManager::get<PointerManager>();
|
addIncludeItemsToMallets();
|
||||||
pointerManager->setIncludeItems(_leftHandStylus, includeItems);
|
|
||||||
pointerManager->setIncludeItems(_rightHandStylus, includeItems);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
request->send();
|
request->send();
|
||||||
|
|
|
@ -157,6 +157,7 @@ private:
|
||||||
bool shouldProcessEntityAndPointerEvent(const PointerEvent& event) const;
|
bool shouldProcessEntityAndPointerEvent(const PointerEvent& event) const;
|
||||||
bool shouldProcessPointerEvent(const PointerEvent& event) const;
|
bool shouldProcessPointerEvent(const PointerEvent& event) const;
|
||||||
bool shouldProcessEntity() const;
|
bool shouldProcessEntity() const;
|
||||||
|
void addIncludeItemsToMallets();
|
||||||
|
|
||||||
void startLayerSwitchTimer();
|
void startLayerSwitchTimer();
|
||||||
bool isLayerSwitchTimerFinished() const;
|
bool isLayerSwitchTimerFinished() const;
|
||||||
|
|
|
@ -64,7 +64,11 @@ namespace render {
|
||||||
return keyBuilder.build();
|
return keyBuilder.build();
|
||||||
}
|
}
|
||||||
template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar) {
|
template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar) {
|
||||||
return static_pointer_cast<Avatar>(avatar)->getRenderBounds();
|
auto avatarPtr = static_pointer_cast<Avatar>(avatar);
|
||||||
|
if (avatarPtr) {
|
||||||
|
return avatarPtr->getRenderBounds();
|
||||||
|
}
|
||||||
|
return Item::Bound();
|
||||||
}
|
}
|
||||||
template <> void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args) {
|
template <> void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args) {
|
||||||
auto avatarPtr = static_pointer_cast<Avatar>(avatar);
|
auto avatarPtr = static_pointer_cast<Avatar>(avatar);
|
||||||
|
@ -75,10 +79,15 @@ namespace render {
|
||||||
}
|
}
|
||||||
template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems) {
|
template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems) {
|
||||||
auto avatarPtr = static_pointer_cast<Avatar>(avatar);
|
auto avatarPtr = static_pointer_cast<Avatar>(avatar);
|
||||||
if (avatarPtr->getSkeletonModel()) {
|
if (avatarPtr) {
|
||||||
auto& metaSubItems = avatarPtr->getSkeletonModel()->fetchRenderItemIDs();
|
uint32_t total = 0;
|
||||||
subItems.insert(subItems.end(), metaSubItems.begin(), metaSubItems.end());
|
if (avatarPtr->getSkeletonModel()) {
|
||||||
return (uint32_t) metaSubItems.size();
|
auto& metaSubItems = avatarPtr->getSkeletonModel()->fetchRenderItemIDs();
|
||||||
|
subItems.insert(subItems.end(), metaSubItems.begin(), metaSubItems.end());
|
||||||
|
total += (uint32_t)metaSubItems.size();
|
||||||
|
}
|
||||||
|
total += avatarPtr->appendSubMetaItems(subItems);
|
||||||
|
return total;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -626,12 +635,18 @@ void Avatar::addToScene(AvatarSharedPointer self, const render::ScenePointer& sc
|
||||||
_skeletonModel->setVisibleInScene(_isMeshVisible, scene);
|
_skeletonModel->setVisibleInScene(_isMeshVisible, scene);
|
||||||
|
|
||||||
processMaterials();
|
processMaterials();
|
||||||
|
bool attachmentRenderingNeedsUpdate = false;
|
||||||
for (auto& attachmentModel : _attachmentModels) {
|
for (auto& attachmentModel : _attachmentModels) {
|
||||||
attachmentModel->addToScene(scene, transaction);
|
attachmentModel->addToScene(scene, transaction);
|
||||||
attachmentModel->setTagMask(render::hifi::TAG_ALL_VIEWS);
|
attachmentModel->setTagMask(render::hifi::TAG_ALL_VIEWS);
|
||||||
attachmentModel->setGroupCulled(false);
|
attachmentModel->setGroupCulled(true);
|
||||||
attachmentModel->setCanCastShadow(true);
|
attachmentModel->setCanCastShadow(true);
|
||||||
attachmentModel->setVisibleInScene(_isMeshVisible, scene);
|
attachmentModel->setVisibleInScene(_isMeshVisible, scene);
|
||||||
|
attachmentRenderingNeedsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attachmentRenderingNeedsUpdate) {
|
||||||
|
updateAttachmentRenderIDs();
|
||||||
}
|
}
|
||||||
|
|
||||||
_mustFadeIn = true;
|
_mustFadeIn = true;
|
||||||
|
@ -855,15 +870,17 @@ void Avatar::fixupModelsInScene(const render::ScenePointer& scene) {
|
||||||
canTryFade = true;
|
canTryFade = true;
|
||||||
_isAnimatingScale = true;
|
_isAnimatingScale = true;
|
||||||
}
|
}
|
||||||
|
bool attachmentRenderingNeedsUpdate = false;
|
||||||
for (auto attachmentModel : _attachmentModels) {
|
for (auto attachmentModel : _attachmentModels) {
|
||||||
if (attachmentModel->isRenderable() && attachmentModel->needsFixupInScene()) {
|
if (attachmentModel->isRenderable() && attachmentModel->needsFixupInScene()) {
|
||||||
attachmentModel->removeFromScene(scene, transaction);
|
attachmentModel->removeFromScene(scene, transaction);
|
||||||
attachmentModel->addToScene(scene, transaction);
|
attachmentModel->addToScene(scene, transaction);
|
||||||
|
|
||||||
attachmentModel->setTagMask(render::hifi::TAG_ALL_VIEWS);
|
attachmentModel->setTagMask(render::hifi::TAG_ALL_VIEWS);
|
||||||
attachmentModel->setGroupCulled(false);
|
attachmentModel->setGroupCulled(true);
|
||||||
attachmentModel->setCanCastShadow(true);
|
attachmentModel->setCanCastShadow(true);
|
||||||
attachmentModel->setVisibleInScene(_isMeshVisible, scene);
|
attachmentModel->setVisibleInScene(_isMeshVisible, scene);
|
||||||
|
attachmentRenderingNeedsUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,9 +903,15 @@ void Avatar::fixupModelsInScene(const render::ScenePointer& scene) {
|
||||||
|
|
||||||
for (auto attachmentModelToRemove : _attachmentsToRemove) {
|
for (auto attachmentModelToRemove : _attachmentsToRemove) {
|
||||||
attachmentModelToRemove->removeFromScene(scene, transaction);
|
attachmentModelToRemove->removeFromScene(scene, transaction);
|
||||||
|
attachmentRenderingNeedsUpdate = true;
|
||||||
}
|
}
|
||||||
_attachmentsToDelete.insert(_attachmentsToDelete.end(), _attachmentsToRemove.begin(), _attachmentsToRemove.end());
|
_attachmentsToDelete.insert(_attachmentsToDelete.end(), _attachmentsToRemove.begin(), _attachmentsToRemove.end());
|
||||||
_attachmentsToRemove.clear();
|
_attachmentsToRemove.clear();
|
||||||
|
|
||||||
|
if (attachmentRenderingNeedsUpdate) {
|
||||||
|
updateAttachmentRenderIDs();
|
||||||
|
}
|
||||||
|
|
||||||
scene->enqueueTransaction(transaction);
|
scene->enqueueTransaction(transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -931,6 +954,11 @@ void Avatar::simulateAttachments(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_ancestorChainRenderableVersion != _lastAncestorChainRenderableVersion) {
|
||||||
|
_lastAncestorChainRenderableVersion = _ancestorChainRenderableVersion;
|
||||||
|
updateDescendantRenderIDs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float Avatar::getBoundingRadius() const {
|
float Avatar::getBoundingRadius() const {
|
||||||
|
@ -1608,7 +1636,6 @@ void Avatar::setAttachmentData(const QVector<AttachmentData>& attachmentData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Avatar::parseDataFromBuffer(const QByteArray& buffer) {
|
int Avatar::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
PerformanceTimer perfTimer("unpack");
|
PerformanceTimer perfTimer("unpack");
|
||||||
if (!_initialized) {
|
if (!_initialized) {
|
||||||
|
@ -2084,3 +2111,60 @@ void Avatar::clearAvatarGrabData(const QUuid& id) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Avatar::appendSubMetaItems(render::ItemIDs& subItems) {
|
||||||
|
return _subItemLock.resultWithReadLock<uint32_t>([&] {
|
||||||
|
uint32_t total = 0;
|
||||||
|
|
||||||
|
if (_attachmentRenderIDs.size() > 0) {
|
||||||
|
subItems.insert(subItems.end(), _attachmentRenderIDs.begin(), _attachmentRenderIDs.end());
|
||||||
|
total += (uint32_t)_attachmentRenderIDs.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_descendantRenderIDs.size() > 0) {
|
||||||
|
subItems.insert(subItems.end(), _descendantRenderIDs.begin(), _descendantRenderIDs.end());
|
||||||
|
total += (uint32_t)_descendantRenderIDs.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
return total;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Avatar::updateAttachmentRenderIDs() {
|
||||||
|
_subItemLock.withWriteLock([&] {
|
||||||
|
_attachmentRenderIDs.clear();
|
||||||
|
for (auto& attachmentModel : _attachmentModels) {
|
||||||
|
if (attachmentModel && attachmentModel->isRenderable()) {
|
||||||
|
auto& metaSubItems = attachmentModel->fetchRenderItemIDs();
|
||||||
|
_attachmentRenderIDs.insert(_attachmentRenderIDs.end(), metaSubItems.begin(), metaSubItems.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Avatar::updateDescendantRenderIDs() {
|
||||||
|
_subItemLock.withWriteLock([&] {
|
||||||
|
_descendantRenderIDs.clear();
|
||||||
|
auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||||
|
EntityTreePointer entityTree = entityTreeRenderer ? entityTreeRenderer->getTree() : nullptr;
|
||||||
|
if (entityTree) {
|
||||||
|
entityTree->withReadLock([&] {
|
||||||
|
forEachDescendant([&](SpatiallyNestablePointer object) {
|
||||||
|
if (object && object->getNestableType() == NestableType::Entity) {
|
||||||
|
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object);
|
||||||
|
if (entity->isVisible()) {
|
||||||
|
auto renderer = entityTreeRenderer->renderableForEntityId(object->getID());
|
||||||
|
if (renderer) {
|
||||||
|
render::ItemIDs renderableSubItems;
|
||||||
|
uint32_t numRenderableSubItems = renderer->metaFetchMetaSubItems(renderableSubItems);
|
||||||
|
if (numRenderableSubItems > 0) {
|
||||||
|
_descendantRenderIDs.insert(_descendantRenderIDs.end(), renderableSubItems.begin(), renderableSubItems.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -498,6 +498,8 @@ public:
|
||||||
const std::vector<MultiSphereShape>& getMultiSphereShapes() const { return _multiSphereShapes; }
|
const std::vector<MultiSphereShape>& getMultiSphereShapes() const { return _multiSphereShapes; }
|
||||||
void tearDownGrabs();
|
void tearDownGrabs();
|
||||||
|
|
||||||
|
uint32_t appendSubMetaItems(render::ItemIDs& subItems);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void targetScaleChanged(float targetScale);
|
void targetScaleChanged(float targetScale);
|
||||||
|
|
||||||
|
@ -638,8 +640,6 @@ protected:
|
||||||
RateCounter<> _skeletonModelSimulationRate;
|
RateCounter<> _skeletonModelSimulationRate;
|
||||||
RateCounter<> _jointDataSimulationRate;
|
RateCounter<> _jointDataSimulationRate;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
class AvatarEntityDataHash {
|
class AvatarEntityDataHash {
|
||||||
public:
|
public:
|
||||||
AvatarEntityDataHash(uint32_t h) : hash(h) {};
|
AvatarEntityDataHash(uint32_t h) : hash(h) {};
|
||||||
|
@ -699,6 +699,13 @@ protected:
|
||||||
MapOfGrabs _avatarGrabs;
|
MapOfGrabs _avatarGrabs;
|
||||||
SetOfIDs _grabsToChange; // updated grab IDs -- changes needed to entities or physics
|
SetOfIDs _grabsToChange; // updated grab IDs -- changes needed to entities or physics
|
||||||
VectorOfIDs _grabsToDelete; // deleted grab IDs -- changes needed to entities or physics
|
VectorOfIDs _grabsToDelete; // deleted grab IDs -- changes needed to entities or physics
|
||||||
|
|
||||||
|
ReadWriteLockable _subItemLock;
|
||||||
|
void updateAttachmentRenderIDs();
|
||||||
|
render::ItemIDs _attachmentRenderIDs;
|
||||||
|
void updateDescendantRenderIDs();
|
||||||
|
render::ItemIDs _descendantRenderIDs;
|
||||||
|
uint32_t _lastAncestorChainRenderableVersion { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Avatar_h
|
#endif // hifi_Avatar_h
|
||||||
|
|
|
@ -320,6 +320,7 @@ bool EntityRenderer::addToScene(const ScenePointer& scene, Transaction& transact
|
||||||
transaction.resetItem(_renderItemID, renderPayload);
|
transaction.resetItem(_renderItemID, renderPayload);
|
||||||
onAddToScene(_entity);
|
onAddToScene(_entity);
|
||||||
updateInScene(scene, transaction);
|
updateInScene(scene, transaction);
|
||||||
|
_entity->bumpAncestorChainRenderableVersion();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,6 +328,7 @@ void EntityRenderer::removeFromScene(const ScenePointer& scene, Transaction& tra
|
||||||
onRemoveFromScene(_entity);
|
onRemoveFromScene(_entity);
|
||||||
transaction.removeItem(_renderItemID);
|
transaction.removeItem(_renderItemID);
|
||||||
Item::clearID(_renderItemID);
|
Item::clearID(_renderItemID);
|
||||||
|
_entity->bumpAncestorChainRenderableVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& transaction) {
|
void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& transaction) {
|
||||||
|
@ -352,14 +354,6 @@ void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& trans
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityRenderer::clearSubRenderItemIDs() {
|
|
||||||
_subRenderItemIDs.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EntityRenderer::setSubRenderItemIDs(const render::ItemIDs& ids) {
|
|
||||||
_subRenderItemIDs = ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Internal methods
|
// Internal methods
|
||||||
//
|
//
|
||||||
|
|
|
@ -52,9 +52,6 @@ public:
|
||||||
virtual bool addToScene(const ScenePointer& scene, Transaction& transaction) final;
|
virtual bool addToScene(const ScenePointer& scene, Transaction& transaction) final;
|
||||||
virtual void removeFromScene(const ScenePointer& scene, Transaction& transaction);
|
virtual void removeFromScene(const ScenePointer& scene, Transaction& transaction);
|
||||||
|
|
||||||
void clearSubRenderItemIDs();
|
|
||||||
void setSubRenderItemIDs(const render::ItemIDs& ids);
|
|
||||||
|
|
||||||
const uint64_t& getUpdateTime() const { return _updateTime; }
|
const uint64_t& getUpdateTime() const { return _updateTime; }
|
||||||
|
|
||||||
virtual void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName);
|
virtual void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName);
|
||||||
|
@ -64,6 +61,9 @@ public:
|
||||||
|
|
||||||
static glm::vec4 calculatePulseColor(const glm::vec4& color, const PulsePropertyGroup& pulseProperties, quint64 start);
|
static glm::vec4 calculatePulseColor(const glm::vec4& color, const PulsePropertyGroup& pulseProperties, quint64 start);
|
||||||
|
|
||||||
|
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) override;
|
||||||
|
virtual Item::Bound getBound() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool needsRenderUpdateFromEntity() const final { return needsRenderUpdateFromEntity(_entity); }
|
virtual bool needsRenderUpdateFromEntity() const final { return needsRenderUpdateFromEntity(_entity); }
|
||||||
virtual void onAddToScene(const EntityItemPointer& entity);
|
virtual void onAddToScene(const EntityItemPointer& entity);
|
||||||
|
@ -75,9 +75,7 @@ protected:
|
||||||
// Implementing the PayloadProxyInterface methods
|
// Implementing the PayloadProxyInterface methods
|
||||||
virtual ItemKey getKey() override;
|
virtual ItemKey getKey() override;
|
||||||
virtual ShapeKey getShapeKey() override;
|
virtual ShapeKey getShapeKey() override;
|
||||||
virtual Item::Bound getBound() override;
|
|
||||||
virtual void render(RenderArgs* args) override final;
|
virtual void render(RenderArgs* args) override final;
|
||||||
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) override;
|
|
||||||
virtual render::hifi::Tag getTagMask() const;
|
virtual render::hifi::Tag getTagMask() const;
|
||||||
virtual render::hifi::Layer getHifiRenderLayer() const;
|
virtual render::hifi::Layer getHifiRenderLayer() const;
|
||||||
|
|
||||||
|
@ -133,7 +131,6 @@ protected:
|
||||||
SharedSoundPointer _collisionSound;
|
SharedSoundPointer _collisionSound;
|
||||||
QUuid _changeHandlerId;
|
QUuid _changeHandlerId;
|
||||||
ItemID _renderItemID{ Item::INVALID_ITEM_ID };
|
ItemID _renderItemID{ Item::INVALID_ITEM_ID };
|
||||||
ItemIDs _subRenderItemIDs;
|
|
||||||
uint64_t _fadeStartTime{ usecTimestampNow() };
|
uint64_t _fadeStartTime{ usecTimestampNow() };
|
||||||
uint64_t _updateTime{ usecTimestampNow() }; // used when sorting/throttling render updates
|
uint64_t _updateTime{ usecTimestampNow() }; // used when sorting/throttling render updates
|
||||||
bool _isFading { EntityTreeRenderer::getEntitiesShouldFadeFunction()() };
|
bool _isFading { EntityTreeRenderer::getEntitiesShouldFadeFunction()() };
|
||||||
|
|
|
@ -1079,7 +1079,7 @@ render::hifi::Tag ModelEntityRenderer::getTagMask() const {
|
||||||
|
|
||||||
uint32_t ModelEntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) {
|
uint32_t ModelEntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) {
|
||||||
if (_model) {
|
if (_model) {
|
||||||
auto metaSubItems = _subRenderItemIDs;
|
auto metaSubItems = _model->fetchRenderItemIDs();
|
||||||
subItems.insert(subItems.end(), metaSubItems.begin(), metaSubItems.end());
|
subItems.insert(subItems.end(), metaSubItems.begin(), metaSubItems.end());
|
||||||
return (uint32_t)metaSubItems.size();
|
return (uint32_t)metaSubItems.size();
|
||||||
}
|
}
|
||||||
|
@ -1321,11 +1321,8 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
if (!_hasModel) {
|
if (!_hasModel) {
|
||||||
if (model) {
|
if (model) {
|
||||||
model->removeFromScene(scene, transaction);
|
model->removeFromScene(scene, transaction);
|
||||||
|
entity->bumpAncestorChainRenderableVersion();
|
||||||
withWriteLock([&] { _model.reset(); });
|
withWriteLock([&] { _model.reset(); });
|
||||||
transaction.updateItem<PayloadProxyInterface>(getRenderItemID(), [](PayloadProxyInterface& data) {
|
|
||||||
auto entityRenderer = static_cast<EntityRenderer*>(&data);
|
|
||||||
entityRenderer->clearSubRenderItemIDs();
|
|
||||||
});
|
|
||||||
emit DependencyManager::get<scriptable::ModelProviderFactory>()->
|
emit DependencyManager::get<scriptable::ModelProviderFactory>()->
|
||||||
modelRemovedFromScene(entity->getEntityItemID(), NestableType::Entity, _model);
|
modelRemovedFromScene(entity->getEntityItemID(), NestableType::Entity, _model);
|
||||||
}
|
}
|
||||||
|
@ -1442,12 +1439,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
render::Item::Status::Getters statusGetters;
|
render::Item::Status::Getters statusGetters;
|
||||||
makeStatusGetters(entity, statusGetters);
|
makeStatusGetters(entity, statusGetters);
|
||||||
model->addToScene(scene, transaction, statusGetters);
|
model->addToScene(scene, transaction, statusGetters);
|
||||||
|
entity->bumpAncestorChainRenderableVersion();
|
||||||
auto newRenderItemIDs{ model->fetchRenderItemIDs() };
|
|
||||||
transaction.updateItem<PayloadProxyInterface>(getRenderItemID(), [newRenderItemIDs](PayloadProxyInterface& data) {
|
|
||||||
auto entityRenderer = static_cast<EntityRenderer*>(&data);
|
|
||||||
entityRenderer->setSubRenderItemIDs(newRenderItemIDs);
|
|
||||||
});
|
|
||||||
processMaterials();
|
processMaterials();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2935,6 +2935,7 @@ void EntityItem::setVisible(bool value) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
bumpAncestorChainRenderableVersion();
|
||||||
emit requestRenderUpdate();
|
emit requestRenderUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -941,7 +941,7 @@ QUuid EntityScriptingInterface::editEntity(const QUuid& id, const EntityItemProp
|
||||||
auto nestable = nestableWP.lock();
|
auto nestable = nestableWP.lock();
|
||||||
if (nestable) {
|
if (nestable) {
|
||||||
NestableType nestableType = nestable->getNestableType();
|
NestableType nestableType = nestable->getNestableType();
|
||||||
if (nestableType == NestableType::Overlay || nestableType == NestableType::Avatar) {
|
if (nestableType == NestableType::Avatar) {
|
||||||
qCWarning(entities) << "attempted edit on non-entity: " << id << nestable->getName();
|
qCWarning(entities) << "attempted edit on non-entity: " << id << nestable->getName();
|
||||||
return QUuid(); // null script value to indicate failure
|
return QUuid(); // null script value to indicate failure
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ const QUuid SpatiallyNestable::getParentID() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpatiallyNestable::setParentID(const QUuid& parentID) {
|
void SpatiallyNestable::setParentID(const QUuid& parentID) {
|
||||||
|
bumpAncestorChainRenderableVersion();
|
||||||
_idLock.withWriteLock([&] {
|
_idLock.withWriteLock([&] {
|
||||||
if (_parentID != parentID) {
|
if (_parentID != parentID) {
|
||||||
_parentID = parentID;
|
_parentID = parentID;
|
||||||
|
@ -78,6 +79,7 @@ void SpatiallyNestable::setParentID(const QUuid& parentID) {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
auto parent = getParentPointer(success);
|
auto parent = getParentPointer(success);
|
||||||
if (success && parent) {
|
if (success && parent) {
|
||||||
|
bumpAncestorChainRenderableVersion();
|
||||||
parent->updateQueryAACube();
|
parent->updateQueryAACube();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1337,8 +1339,6 @@ QString SpatiallyNestable::nestableTypeToString(NestableType nestableType) {
|
||||||
return "entity";
|
return "entity";
|
||||||
case NestableType::Avatar:
|
case NestableType::Avatar:
|
||||||
return "avatar";
|
return "avatar";
|
||||||
case NestableType::Overlay:
|
|
||||||
return "overlay";
|
|
||||||
default:
|
default:
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
@ -1419,3 +1419,12 @@ QUuid SpatiallyNestable::getEditSenderID() {
|
||||||
});
|
});
|
||||||
return editSenderID;
|
return editSenderID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpatiallyNestable::bumpAncestorChainRenderableVersion() const {
|
||||||
|
_ancestorChainRenderableVersion++;
|
||||||
|
bool success = false;
|
||||||
|
auto parent = getParentPointer(success);
|
||||||
|
if (success && parent) {
|
||||||
|
parent->bumpAncestorChainRenderableVersion();
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,8 +30,7 @@ static const uint16_t INVALID_JOINT_INDEX = -1;
|
||||||
|
|
||||||
enum class NestableType {
|
enum class NestableType {
|
||||||
Entity,
|
Entity,
|
||||||
Avatar,
|
Avatar
|
||||||
Overlay
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpatiallyNestable : public std::enable_shared_from_this<SpatiallyNestable> {
|
class SpatiallyNestable : public std::enable_shared_from_this<SpatiallyNestable> {
|
||||||
|
@ -222,6 +221,8 @@ public:
|
||||||
bool hasGrabs();
|
bool hasGrabs();
|
||||||
virtual QUuid getEditSenderID();
|
virtual QUuid getEditSenderID();
|
||||||
|
|
||||||
|
void bumpAncestorChainRenderableVersion() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QUuid _id;
|
QUuid _id;
|
||||||
mutable SpatiallyNestableWeakPointer _parent;
|
mutable SpatiallyNestableWeakPointer _parent;
|
||||||
|
@ -244,6 +245,8 @@ protected:
|
||||||
mutable ReadWriteLockable _grabsLock;
|
mutable ReadWriteLockable _grabsLock;
|
||||||
QSet<GrabPointer> _grabs; // upon this thing
|
QSet<GrabPointer> _grabs; // upon this thing
|
||||||
|
|
||||||
|
mutable std::atomic<uint32_t> _ancestorChainRenderableVersion { 0 };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SpatiallyNestable() = delete;
|
SpatiallyNestable() = delete;
|
||||||
const NestableType _nestableType; // EntityItem or an AvatarData
|
const NestableType _nestableType; // EntityItem or an AvatarData
|
||||||
|
|
Loading…
Reference in a new issue