bool ParticlesEditorSceneModelHelper::GetCheckableStateForGraphItem(GraphItem* graphItem) const { LayerParticleEditorNode* layerEditorNode = GetLayerEditorNodeByGraphItem(graphItem); if (!layerEditorNode || !layerEditorNode->GetLayer()) { return false; } return !layerEditorNode->GetLayer()->GetDisabled(); }
SceneGraphItem* ParticlesEditorSceneModelHelper::GetGraphItemForParticlesLayer(GraphItem* rootItem, DAVA::ParticleLayer* layer) { // Check fot the current root SceneGraphItem* curItem = dynamic_cast<SceneGraphItem*>(rootItem); if (curItem && curItem->GetExtraUserData()) { LayerParticleEditorNode* editorNode = dynamic_cast<LayerParticleEditorNode*>(curItem->GetExtraUserData()); if (editorNode && editorNode->GetLayer() == layer) { return curItem; } } // Verify for all children. int32 childrenCount = rootItem->ChildrenCount(); for (int32 i = 0; i < childrenCount; i ++) { SceneGraphItem* curItem = dynamic_cast<SceneGraphItem*>(rootItem->Child(i)); SceneGraphItem* resultItem = GetGraphItemForParticlesLayer(curItem, layer); if (resultItem) { return resultItem; } } // Nothing is found... return NULL; }
void ParticlesEditorController::RemoveParticleForceNode(ForceParticleEditorNode* forceNode) { if (!forceNode || !forceNode->GetLayerEditorNode()) { return; } LayerParticleEditorNode* layerNode = forceNode->GetLayerEditorNode(); ParticleLayer* layer = layerNode->GetLayer(); if (!layer) { return; } // If the selected node is one to be removed - clean it up. CleanupSelectedNodeIfDeleting(forceNode); // Remove the force from the emitter... int forceIndex = forceNode->GetForceIndex(); layer->RemoveForce(forceIndex); // ...and from the tree. layerNode->RemoveChildNode(forceNode); // Done removing, recalculate the indices and names. layerNode->UpdateForcesIndices(); }
void ParticlesEditorSceneModelHelper::SetCheckableStateForGraphItem(GraphItem* graphItem, bool value) { LayerParticleEditorNode* layerEditorNode = GetLayerEditorNodeByGraphItem(graphItem); if (!layerEditorNode || !layerEditorNode->GetLayer()) { return; } // Execute the appropriate command. CommandsManager::Instance()->ExecuteAndRelease(new CommandUpdateParticleLayerEnabled(layerEditorNode->GetLayer(), value)); }
void ParticlesEditorController::EmitSelectedNodeChanged(bool forceRefresh) { if (this->selectedNode == NULL) { emit EmitterSelected(NULL, this->selectedNode); return; } // Determine the exact node type and emit the event needed. EffectParticleEditorNode* effectEditorNode = dynamic_cast<EffectParticleEditorNode*>(this->selectedNode); if (effectEditorNode) { emit EmitterSelected(NULL, this->selectedNode); emit EffectSelected(effectEditorNode->GetRootNode()); return; } EmitterParticleEditorNode* emitterEditorNode = dynamic_cast<EmitterParticleEditorNode*>(this->selectedNode); if (emitterEditorNode) { emit EmitterSelected(emitterEditorNode->GetEmitterNode(), this->selectedNode); return; } LayerParticleEditorNode* layerEditorNode = dynamic_cast<LayerParticleEditorNode*>(this->selectedNode); if (layerEditorNode) { emit LayerSelected(layerEditorNode->GetEmitterNode(), layerEditorNode->GetLayer(), this->selectedNode, forceRefresh); return; } ForceParticleEditorNode* forceEditorNode = dynamic_cast<ForceParticleEditorNode*>(this->selectedNode); if (forceEditorNode) { emit ForceSelected(forceEditorNode->GetEmitterNode(), forceEditorNode->GetLayer(), forceEditorNode->GetForceIndex(), this->selectedNode); return; } // Cleanip the selection in case we don't know what to do. Logger::Warning("ParticlesEditorController::EmitSelectedNodeChanged() - unknown selected node type!"); EmitterSelected(NULL, this->selectedNode); }