mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 13:33:38 +02:00
First alpha version of bubble collision fade events. Missing a lot of information.
This commit is contained in:
parent
381e0c64a8
commit
7552cca316
8 changed files with 48 additions and 20 deletions
|
@ -330,7 +330,7 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar
|
|||
DependencyManager::get<UsersScriptingInterface>()->avatarDisconnected(avatar->getSessionUUID());
|
||||
}
|
||||
_avatarsToFade.push_back(removedAvatar);
|
||||
avatar->fadeOut(qApp->getMain3DScene());
|
||||
avatar->fadeOut(qApp->getMain3DScene(), removalReason);
|
||||
}
|
||||
|
||||
void AvatarManager::clearOtherAvatars() {
|
||||
|
|
|
@ -513,17 +513,25 @@ void Avatar::fadeIn(render::ScenePointer scene) {
|
|||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
|
||||
void Avatar::fadeOut(render::ScenePointer scene) {
|
||||
void Avatar::fadeOut(render::ScenePointer scene, KillAvatarReason reason) {
|
||||
render::Transition::Type transitionType = render::Transition::USER_LEAVE_DOMAIN;
|
||||
render::Transaction transaction;
|
||||
fade(transaction, render::Transition::USER_LEAVE_DOMAIN);
|
||||
|
||||
if (reason == KillAvatarReason::YourAvatarEnteredTheirBubble) {
|
||||
transitionType = render::Transition::BUBBLE_ISECT_TRESPASSER;
|
||||
}
|
||||
else if (reason == KillAvatarReason::TheirAvatarEnteredYourBubble) {
|
||||
transitionType = render::Transition::BUBBLE_ISECT_OWNER;
|
||||
}
|
||||
fade(transaction, transitionType);
|
||||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
|
||||
void Avatar::fade(render::Transaction& transaction, render::Transition::Type type) {
|
||||
transaction.transitionItem(_renderItemID, type);
|
||||
transaction.addTransitionToItem(_renderItemID, type);
|
||||
for (auto& attachmentModel : _attachmentModels) {
|
||||
for (auto itemId : attachmentModel->fetchRenderItemIDs()) {
|
||||
transaction.transitionItem(itemId, type, _renderItemID);
|
||||
transaction.addTransitionToItem(itemId, type, _renderItemID);
|
||||
}
|
||||
}
|
||||
_isWaitingForFade = true;
|
||||
|
|
|
@ -251,7 +251,7 @@ public:
|
|||
bool isInPhysicsSimulation() const { return _physicsCallback != nullptr; }
|
||||
|
||||
void fadeIn(render::ScenePointer scene);
|
||||
void fadeOut(render::ScenePointer scene);
|
||||
void fadeOut(render::ScenePointer scene, KillAvatarReason reason);
|
||||
bool isFading(render::ScenePointer scene) const;
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -180,7 +180,14 @@ void AvatarHashMap::processExitingSpaceBubble(QSharedPointer<ReceivedMessage> me
|
|||
void AvatarHashMap::removeAvatar(const QUuid& sessionUUID, KillAvatarReason removalReason) {
|
||||
QWriteLocker locker(&_hashLock);
|
||||
|
||||
auto removedAvatar = _avatarHash.take(sessionUUID);
|
||||
AvatarSharedPointer removedAvatar;
|
||||
|
||||
if (removalReason != KillAvatarReason::TheirAvatarEnteredYourBubble && removalReason != KillAvatarReason::YourAvatarEnteredTheirBubble) {
|
||||
removedAvatar = _avatarHash.take(sessionUUID);
|
||||
}
|
||||
else {
|
||||
removedAvatar = _avatarHash[sessionUUID];
|
||||
}
|
||||
|
||||
if (removedAvatar) {
|
||||
handleRemovedAvatar(removedAvatar, removalReason);
|
||||
|
|
|
@ -244,7 +244,7 @@ bool RenderableModelEntityItem::addToScene(const EntityItemPointer& self, const
|
|||
_model->addToScene(scene, transaction, statusGetters);
|
||||
|
||||
if (!_hasTransitioned) {
|
||||
transaction.transitionItem(_myMetaItem, render::Transition::ELEMENT_ENTER_DOMAIN);
|
||||
transaction.addTransitionToItem(_myMetaItem, render::Transition::ELEMENT_ENTER_DOMAIN);
|
||||
_hasTransitioned = true;
|
||||
}
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
_model->addToScene(scene, transaction, statusGetters);
|
||||
|
||||
if (!_hasTransitioned) {
|
||||
transaction.transitionItem(_myMetaItem, render::Transition::ELEMENT_ENTER_DOMAIN);
|
||||
transaction.addTransitionToItem(_myMetaItem, render::Transition::ELEMENT_ENTER_DOMAIN);
|
||||
_hasTransitioned = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ void FadeEditJob::run(const render::RenderContextPointer& renderContext, const F
|
|||
|
||||
// Relaunch transition
|
||||
render::Transaction transaction;
|
||||
transaction.transitionItem(itemId, categoryToTransition[inputs.get1()]);
|
||||
transaction.addTransitionToItem(itemId, categoryToTransition[inputs.get1()]);
|
||||
renderContext->_scene->enqueueTransaction(transaction);
|
||||
}
|
||||
}
|
||||
|
@ -115,13 +115,13 @@ FadeConfig::FadeConfig()
|
|||
events[BUBBLE_ISECT_TRESPASSER].edgeOuterColor = glm::vec4{ 31.f / 255.f, 198.f / 255.f, 166.f / 255.f, 2.0f };
|
||||
|
||||
events[USER_ENTER_LEAVE_DOMAIN].noiseSize = glm::vec3{ 10.f, 0.01f, 10.0f };
|
||||
events[USER_ENTER_LEAVE_DOMAIN].noiseLevel = 0.7f;
|
||||
events[USER_ENTER_LEAVE_DOMAIN].noiseLevel = 0.3f;
|
||||
events[USER_ENTER_LEAVE_DOMAIN].noiseSpeed = glm::vec3{ 0.0f, -0.5f, 0.0f };
|
||||
events[USER_ENTER_LEAVE_DOMAIN].timing = FadeConfig::LINEAR;
|
||||
events[USER_ENTER_LEAVE_DOMAIN].baseSize = glm::vec3{ 10000.f, 1.0f, 10000.0f };
|
||||
events[USER_ENTER_LEAVE_DOMAIN].baseLevel = 1.f;
|
||||
events[USER_ENTER_LEAVE_DOMAIN].isInverted = true;
|
||||
events[USER_ENTER_LEAVE_DOMAIN].duration = 5.f;
|
||||
events[USER_ENTER_LEAVE_DOMAIN].duration = 2.f;
|
||||
events[USER_ENTER_LEAVE_DOMAIN].edgeWidth = 0.229f;
|
||||
events[USER_ENTER_LEAVE_DOMAIN].edgeInnerColor = glm::vec4{ 78.f / 255.f, 215.f / 255.f, 255.f / 255.f, 0.25f };
|
||||
events[USER_ENTER_LEAVE_DOMAIN].edgeOuterColor = glm::vec4{ 1.f, 1.f, 1.f, 1.0f };
|
||||
|
@ -559,7 +559,7 @@ void FadeJob::run(const render::RenderContextPointer& renderContext, FadeJob::Ou
|
|||
auto& state = transitionStage->editTransition(transitionId);
|
||||
if (!update(*jobConfig, scene, state, deltaTime)) {
|
||||
// Remove transition for this item
|
||||
transaction.transitionItem(state.itemId, render::Transition::NONE);
|
||||
transaction.addTransitionToItem(state.itemId, render::Transition::NONE);
|
||||
hasTransactions = true;
|
||||
}
|
||||
|
||||
|
@ -605,12 +605,16 @@ bool FadeJob::update(const Config& config, const render::ScenePointer& scene, re
|
|||
|
||||
assert(timing < FadeConfig::TIMING_COUNT);
|
||||
|
||||
transition.noiseOffset = aabb.calcCenter();
|
||||
transition.baseInvSize.x = 1.f / eventConfig.baseSize.x;
|
||||
transition.baseInvSize.y = 1.f / eventConfig.baseSize.y;
|
||||
transition.baseInvSize.z = 1.f / eventConfig.baseSize.z;
|
||||
|
||||
switch (transition.eventType) {
|
||||
case render::Transition::ELEMENT_ENTER_DOMAIN:
|
||||
case render::Transition::ELEMENT_LEAVE_DOMAIN:
|
||||
{
|
||||
transition.threshold = computeElementEnterRatio(transition.time, eventConfig.duration, timing);
|
||||
transition.noiseOffset = aabb.calcCenter();
|
||||
transition.baseOffset = transition.noiseOffset;
|
||||
transition.baseInvSize.x = 1.f / dimensions.x;
|
||||
transition.baseInvSize.y = 1.f / dimensions.y;
|
||||
|
@ -624,6 +628,9 @@ bool FadeJob::update(const Config& config, const render::ScenePointer& scene, re
|
|||
|
||||
case render::Transition::BUBBLE_ISECT_OWNER:
|
||||
{
|
||||
transition.threshold = 0.5f;
|
||||
transition.baseOffset = transition.noiseOffset;
|
||||
|
||||
/* const glm::vec3 cameraPos = renderContext->args->getViewFrustum().getPosition();
|
||||
glm::vec3 delta = itemBounds.bound.calcCenter() - cameraPos;
|
||||
float distance = glm::length(delta);
|
||||
|
@ -637,7 +644,8 @@ bool FadeJob::update(const Config& config, const render::ScenePointer& scene, re
|
|||
|
||||
case render::Transition::BUBBLE_ISECT_TRESPASSER:
|
||||
{
|
||||
// _editBaseOffset = glm::vec3{ 0.f, 0.f, 0.f };
|
||||
transition.threshold = 0.5f;
|
||||
transition.baseOffset = transition.noiseOffset;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -645,11 +653,8 @@ bool FadeJob::update(const Config& config, const render::ScenePointer& scene, re
|
|||
case render::Transition::USER_LEAVE_DOMAIN:
|
||||
{
|
||||
transition.threshold = computeElementEnterRatio(transition.time, eventConfig.duration, timing);
|
||||
transition.noiseOffset = aabb.calcCenter();
|
||||
transition.baseOffset = transition.noiseOffset - dimensions.y / 2.f;
|
||||
transition.baseInvSize.x = 1.f / eventConfig.baseSize.x;
|
||||
transition.baseInvSize.y = 1.f / dimensions.y;
|
||||
transition.baseInvSize.z = 1.f / eventConfig.baseSize.z;
|
||||
continueTransition = transition.threshold < 1.f;
|
||||
if (transition.eventType == render::Transition::USER_LEAVE_DOMAIN) {
|
||||
transition.threshold = 1.f - transition.threshold;
|
||||
|
@ -665,6 +670,7 @@ bool FadeJob::update(const Config& config, const render::ScenePointer& scene, re
|
|||
}
|
||||
}
|
||||
|
||||
transition.noiseOffset += eventConfig.noiseSpeed * (float)transition.time;
|
||||
transition.threshold = (transition.threshold - 0.5f)*_thresholdScale[fadeCategory] + 0.5f;
|
||||
transition.time += deltaTime;
|
||||
|
||||
|
|
|
@ -31,12 +31,18 @@ void Transaction::removeItem(ItemID id) {
|
|||
_removedItems.emplace_back(id);
|
||||
}
|
||||
|
||||
void Transaction::transitionItem(ItemID id, Transition::Type transition, ItemID boundId) {
|
||||
void Transaction::addTransitionToItem(ItemID id, Transition::Type transition, ItemID boundId) {
|
||||
_transitioningItems.emplace_back(id);
|
||||
_transitioningItemBounds.emplace_back(boundId);
|
||||
_transitionTypes.emplace_back(transition);
|
||||
}
|
||||
|
||||
void Transaction::removeTransitionFromItem(ItemID id) {
|
||||
_transitioningItems.emplace_back(id);
|
||||
_transitioningItemBounds.emplace_back(render::Item::INVALID_ITEM_ID);
|
||||
_transitionTypes.emplace_back(render::Transition::NONE);
|
||||
}
|
||||
|
||||
void Transaction::updateItem(ItemID id, const UpdateFunctorPointer& functor) {
|
||||
_updatedItems.emplace_back(id);
|
||||
_updateFunctors.emplace_back(functor);
|
||||
|
|
|
@ -40,7 +40,8 @@ public:
|
|||
void resetItem(ItemID id, const PayloadPointer& payload);
|
||||
void removeItem(ItemID id);
|
||||
|
||||
void transitionItem(ItemID id, Transition::Type transition, ItemID boundId = render::Item::INVALID_ITEM_ID);
|
||||
void addTransitionToItem(ItemID id, Transition::Type transition, ItemID boundId = render::Item::INVALID_ITEM_ID);
|
||||
void removeTransitionFromItem(ItemID id);
|
||||
|
||||
template <class T> void updateItem(ItemID id, std::function<void(T&)> func) {
|
||||
updateItem(id, std::make_shared<UpdateFunctor<T>>(func));
|
||||
|
|
Loading…
Reference in a new issue