mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 20:44:14 +02:00
Some objects fade and fixed crash due to invalid meta item id
This commit is contained in:
parent
267531cc1a
commit
66d09a4c3c
5 changed files with 28 additions and 6 deletions
|
@ -493,11 +493,17 @@ ModelPointer RenderableModelEntityItem::getModelNotSafe() {
|
|||
void RenderableModelEntityItem::setModelURLFinished(bool success) {
|
||||
if (success) {
|
||||
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
render::Transaction transaction;
|
||||
|
||||
const auto& item = scene->getItem(_myMetaItem);
|
||||
transaction.transitionItem(_myMetaItem, render::Transition::ELEMENT_ENTER_LEAVE_DOMAIN);
|
||||
scene->enqueueTransaction(transaction);
|
||||
if (scene->isAllocatedID(_myMetaItem)) {
|
||||
render::Transaction transaction;
|
||||
|
||||
const auto& item = scene->getItem(_myMetaItem);
|
||||
if (!item.exist()) {
|
||||
qWarning() << "Starting transition on item without payload";
|
||||
}
|
||||
transaction.transitionItem(_myMetaItem, render::Transition::ELEMENT_ENTER_LEAVE_DOMAIN);
|
||||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -620,7 +620,7 @@ render::ShapePipeline::ItemSetter FadeJob::getItemSetter() const {
|
|||
auto scene = args->_scene;
|
||||
auto batch = args->_batch;
|
||||
auto transitionStage = scene->getStage<render::TransitionStage>(render::TransitionStage::getName());
|
||||
render::Transition transitionState = transitionStage->getTransition(item.getTransitionId());
|
||||
auto& transitionState = transitionStage->getTransition(item.getTransitionId());
|
||||
render::ShapeKey shapeKey(args->_globalShapeKey);
|
||||
|
||||
// TODO test various cases: polyvox... etc
|
||||
|
|
|
@ -98,6 +98,10 @@ namespace indexed_container {
|
|||
return _elements[index];
|
||||
}
|
||||
|
||||
bool isElementFreed(Index index) const {
|
||||
return std::find(_allocator._freeIndices.begin(), _allocator._freeIndices.end(), index) != _allocator._freeIndices.end();
|
||||
}
|
||||
|
||||
const Element& get(Index index) const {
|
||||
return _elements[index];
|
||||
}
|
||||
|
|
|
@ -178,6 +178,12 @@ void Scene::removeItems(const ItemIDs& ids) {
|
|||
_masterNonspatialSet.erase(removedID);
|
||||
}
|
||||
|
||||
// If there is a transition on this item, remove it
|
||||
if (item.getTransitionId() != render::TransitionStage::INVALID_INDEX) {
|
||||
auto transitionStage = getStage<TransitionStage>(TransitionStage::getName());
|
||||
transitionStage->removeTransition(item.getTransitionId());
|
||||
}
|
||||
|
||||
// Kill it
|
||||
item.kill();
|
||||
}
|
||||
|
@ -237,6 +243,10 @@ void Scene::transitionItems(const ItemIDs& ids, const TransitionTypes& types) {
|
|||
if (*transitionType != Transition::NONE) {
|
||||
transitionId = transitionStage->addTransition(itemId, *transitionType);
|
||||
}
|
||||
else {
|
||||
const auto& item = _items[itemId];
|
||||
transitionStage->removeTransition(item.getTransitionId());
|
||||
}
|
||||
|
||||
setItemTransition(itemId, transitionId);
|
||||
// next loop
|
||||
|
|
|
@ -23,7 +23,9 @@ void TransitionStage::removeTransition(Index index) {
|
|||
if (idIterator != _activeTransitionIds.end()) {
|
||||
_activeTransitionIds.erase(idIterator);
|
||||
}
|
||||
_transitions.freeElement(index);
|
||||
if (!_transitions.isElementFreed(index)) {
|
||||
_transitions.freeElement(index);
|
||||
}
|
||||
}
|
||||
|
||||
TransitionStageSetup::TransitionStageSetup() {
|
||||
|
|
Loading…
Reference in a new issue