void post( const scene::Path& path, scene::Instance& instance ) const { Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 && ( instance.childSelected() || Instance_getSelectable( instance )->isSelected() ) ) { entity->setKeyValue( m_key, m_value ); } }
static gboolean entitylist_tree_select(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer data) { GtkTreeIter iter; gtk_tree_model_get_iter(model, &iter, path); scene::Node* node; gtk_tree_model_get_pointer(model, &iter, 0, &node); scene::Instance* instance; gtk_tree_model_get_pointer(model, &iter, 1, &instance); Selectable* selectable = Instance_getSelectable(*instance); if(node == 0) { if(path_currently_selected != FALSE) { getEntityList().m_selection_disabled = true; GlobalSelectionSystem().setSelectedAll(false); getEntityList().m_selection_disabled = false; } } else if(selectable != 0) { getEntityList().m_selection_disabled = true; selectable->setSelected(path_currently_selected == FALSE); getEntityList().m_selection_disabled = false; return TRUE; } return FALSE; }
void post( const scene::Path& path, scene::Instance& instance ) const { Selectable *selectable = Instance_getSelectable( instance ); if ( selectable && selectable->isSelected() ) { Entity* entity = Node_getEntity( path.top() ); if ( entity == 0 && Node_isPrimitive( path.top() ) ) { NodeSmartReference child( path.top().get() ); NodeSmartReference parent( path.parent().get() ); if ( path.size() >= 3 && parent != worldspawn ) { NodeSmartReference parentparent( path[path.size() - 3].get() ); Node_getTraversable( parent )->erase( child ); Node_getTraversable( group )->insert( child ); if ( Node_getTraversable( parent )->empty() ) { //deleteme.push(DeletionPair(parentparent, parent)); Node_getTraversable( parentparent )->erase( parent ); } } else { Node_getTraversable( parent )->erase( child ); Node_getTraversable( group )->insert( child ); } } } }
void post( const scene::Path& path, scene::Instance& instance ) const { Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 && Instance_getSelectable( instance )->isSelected() && node_is_group( path.top() ) && !groupPath ) { groupPath = &path; groupInstance = &instance; } }
bool pre (const scene::Path& path, scene::Instance& instance) const { if (path.top().get().visible()) { Snappable* snappable = Node_getSnappable(path.top()); if (snappable != 0 && Instance_getSelectable(instance)->isSelected()) { snappable->snapto(m_snap); } } return true; }
bool pre (const scene::Path& path, scene::Instance& instance) const { if (path.top().get().visible()) { // Check if the visited instance is ComponentSnappable ComponentSnappable* componentSnappable = Instance_getComponentSnappable(instance); // Call the snapComponents() method if the instance is also a _selected_ Selectable if (componentSnappable != 0 && Instance_getSelectable(instance)->isSelected()) { componentSnappable->snapComponents(m_snap); } } return true; }
bool pre(const scene::Path& path, scene::Instance& instance) const { if(path.top().get().visible()) { Brush* brush = Node_getBrush(path.top()); if(brush != 0 && Brush_hasShader(*brush, m_name)) { Instance_getSelectable(instance)->setSelected(true); } } return true; }
bool PlaneSelectableSelectPlanes::pre(const scene::Path& path, scene::Instance& instance) const { if(path.top().get().visible()) { Selectable* selectable = Instance_getSelectable(instance); if(selectable != 0 && selectable->isSelected()) { PlaneSelectable* planeSelectable = Instance_getPlaneSelectable(instance); if(planeSelectable != 0) { planeSelectable->selectPlanes(_selector, _test, _selectedPlaneCallback); } } } return true; }
void DEntity::SelectBrushes( bool *selectList ){ if ( selectList == NULL ) { return; } GlobalSelectionSystem().setSelectedAll( false ); scene::Path path( NodeReference( GlobalSceneGraph().root() ) ); path.push( NodeReference( *QER_Entity ) ); for ( std::list<DBrush *>::const_iterator pBrush = brushList.begin(); pBrush != brushList.end(); pBrush++ ) { if ( selectList[( *pBrush )->m_nBrushID] ) { path.push( NodeReference( *( *pBrush )->QER_brush ) ); Instance_getSelectable( *GlobalSceneGraph().find( path ) )->setSelected( true ); path.pop(); } } }
void post( const scene::Path& path, scene::Instance& instance ) const { Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 && ( instance.childSelected() || Instance_getSelectable( instance )->isSelected() ) ) { NodeSmartReference node( GlobalEntityCreator().createEntity( GlobalEntityClassManager().findOrInsert( m_classname, node_is_group( path.top() ) ) ) ); EntityCopyingVisitor visitor( *Node_getEntity( node ) ); entity->forEachKeyValue( visitor ); NodeSmartReference child( path.top().get() ); NodeSmartReference parent( path.parent().get() ); Node_getTraversable( parent )->erase( child ); if ( Node_getTraversable( child ) != 0 && Node_getTraversable( node ) != 0 && node_is_group( node ) ) { parentBrushes( child, node ); } Node_getTraversable( parent )->insert( node ); } }
gboolean treemodel_update_selection(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data) { GtkTreeView* view = reinterpret_cast<GtkTreeView*>(data); scene::Instance* instance; gtk_tree_model_get_pointer(model, iter, 1, &instance); Selectable* selectable = Instance_getSelectable(*instance); if(selectable != 0) { GtkTreeSelection* selection = gtk_tree_view_get_selection(view); if(selectable->isSelected()) { gtk_tree_selection_select_path(selection, path); } else { gtk_tree_selection_unselect_path(selection, path); } } return FALSE; }
void post( const scene::Path& path, scene::Instance& instance ) const { Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 && ( instance.childSelected() || Instance_getSelectable( instance )->isSelected() ) ) { if( path.top().get_pointer() == m_world ){ /* do not want to convert whole worldspawn entity */ if( instance.childSelected() && !m_2world ){ /* create an entity from world brushes instead */ EntityClass* entityClass = GlobalEntityClassManager().findOrInsert( m_classname, true ); if( entityClass->fixedsize ) return; //is important to have retexturing here; if doing in the end, undo doesn't succeed; //don't do this extra now, as it requires retexturing, working for subgraph // if ( string_compare_nocase_n( m_classname, "trigger_", 8 ) == 0 ){ // Scene_PatchSetShader_Selected( GlobalSceneGraph(), GetCommonShader( "trigger" ).c_str() ); // Scene_BrushSetShader_Selected( GlobalSceneGraph(), GetCommonShader( "trigger" ).c_str() ); // } NodeSmartReference node( GlobalEntityCreator().createEntity( entityClass ) ); Node_getTraversable( GlobalSceneGraph().root() )->insert( node ); scene::Path entitypath( makeReference( GlobalSceneGraph().root() ) ); entitypath.push( makeReference( node.get() ) ); scene::Instance& entityInstance = findInstance( entitypath ); if ( g_pGameDescription->mGameType == "doom3" ) { Node_getEntity( node )->setKeyValue( "model", Node_getEntity( node )->getKeyValue( "name" ) ); } //Scene_parentSelectedBrushesToEntity( GlobalSceneGraph(), node ); Scene_parentSubgraphSelectedBrushesToEntity( GlobalSceneGraph(), node, path ); Scene_forEachChildSelectable( SelectableSetSelected( true ), entityInstance.path() ); } return; } else if( m_2world ){ /* ungroupSelectedEntities */ //condition is skipped with world = 0, so code next to this may create multiple worldspawns; todo handle this very special case? if( node_is_group( path.top() ) ){ parentBrushes( path.top(), *m_world ); Path_deleteTop( path ); } return; } EntityClass* eclass = GlobalEntityClassManager().findOrInsert( m_classname, node_is_group( path.top() ) ); NodeSmartReference node( GlobalEntityCreator().createEntity( eclass ) ); if( entity->isContainer() && eclass->fixedsize ){ /* group entity to point one */ char value[64]; sprintf( value, "%g %g %g", instance.worldAABB().origin[0], instance.worldAABB().origin[1], instance.worldAABB().origin[2] ); entity->setKeyValue( "origin", value ); } EntityCopyingVisitor visitor( *Node_getEntity( node ) ); // entity->forEachKeyValue( visitor ); NodeSmartReference child( path.top().get() ); NodeSmartReference parent( path.parent().get() ); // Node_getTraversable( parent )->erase( child ); if ( Node_getTraversable( child ) != 0 && node_is_group( node ) ) { /* group entity to group one */ parentBrushes( child, node ); } Node_getTraversable( parent )->insert( node ); entity->forEachKeyValue( visitor ); /* must do this after inserting node, otherwise problem: targeted + having model + not loaded b4 new entities aren't selectable normally + rendered only while 0 0 0 is rendered */ if( !entity->isContainer() && !eclass->fixedsize ){ /* point entity to group one */ AABB bounds( g_vector3_identity, Vector3( 16, 16, 16 ) ); if ( !string_parse_vector3( entity->getKeyValue( "origin" ), bounds.origin ) ) { bounds.origin = g_vector3_identity; } Brush_ConstructPlacehoderCuboid( node.get(), bounds ); Node_getEntity( node )->setKeyValue( "origin", "" ); } Node_getTraversable( parent )->erase( child ); } }