use Instance_isSelected() function

This commit is contained in:
Thomas Debesse 2017-07-11 05:36:00 +02:00 committed by Garux
parent 1acf0bb221
commit 66e6781c9b
9 changed files with 60 additions and 104 deletions

View File

@ -379,7 +379,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Brush* brush = Node_getBrush( path.top() );
if ( brush != 0
&& Instance_getSelectable( instance )->isSelected() ) {
&& Instance_isSelected( instance ) ) {
m_brushlist.push_back( brush );
}
}
@ -397,7 +397,7 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Brush* brush = Node_getBrush( path.top() );
if ( brush != 0
&& Instance_getSelectable( instance )->isSelected()
&& Instance_isSelected( instance )
&& path.size() > 1 ) {
Path_deleteTop( path );
}
@ -424,7 +424,7 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Brush* brush = Node_getBrush( path.top() );
if ( brush != 0
&& Instance_getSelectable( instance )->isSelected()
&& Instance_isSelected( instance )
&& path.size() > 1
&& path.top().get_pointer() != m_keepNode ) {
scene::Node& parent = path.parent();
@ -622,7 +622,7 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Brush* brush = Node_getBrush( path.top() );
if ( brush != 0
&& !Instance_getSelectable( instance )->isSelected() ) {
&& !Instance_isSelected( instance ) ) {
brush_vector_t buffer[2];
bool swap = false;
Brush* original = new Brush( *brush );
@ -734,7 +734,7 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Brush* brush = Node_getBrush( path.top() );
if ( brush != 0
&& Instance_getSelectable( instance )->isSelected() ) {
&& Instance_isSelected( instance ) ) {
const brushsplit_t split = Brush_classifyPlane( *brush, m_plane );
if ( split.counts[ePlaneBack] && split.counts[ePlaneFront] ) {
// the plane intersects this brush

View File

@ -75,7 +75,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
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() ) ) {
&& ( instance.childSelected() || Instance_isSelected( instance ) ) ) {
entity->setKeyValue( m_key, m_value );
}
}
@ -95,7 +95,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
}
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 ( entity != 0 && ( instance.childSelected() || Instance_isSelected( instance ) ) ) {
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 );
@ -230,7 +230,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
void post( const scene::Path& path, scene::Instance& instance ) const {
Entity* entity = Node_getEntity( path.top() );
if ( entity != 0
&& Instance_getSelectable( instance )->isSelected()
&& Instance_isSelected( instance )
&& node_is_group( path.top() )
&& !groupPath ) {
groupPath = &path;
@ -251,8 +251,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
return true;
}
void post( const scene::Path& path, scene::Instance& instance ) const {
Selectable *selectable = Instance_getSelectable( instance );
if ( selectable && selectable->isSelected() ) {
if ( Instance_isSelected( instance ) ) {
Entity* entity = Node_getEntity( path.top() );
if ( entity == 0 && Node_isPrimitive( path.top() ) ) {
NodeSmartReference child( path.top().get() );

View File

@ -340,22 +340,19 @@ gboolean searchEntryScroll( GtkWidget* widget, GdkEventScroll* event, gpointer u
if( node ){
scene::Instance* instance;
gtk_tree_model_get_pointer( model, &iter, 1, &instance );
Selectable* selectable = Instance_getSelectable( *instance );
if( selectable ){
if( selectable->isSelected() || instance->childSelected() ){
if( iter_first.stamp == 0 ){
iter_first = iter;
}
if( iter_found.stamp != 0 ){
iter_next = iter;
break;
}
if( node == getEntityList().m_search_focus_node ){
iter_found = iter;
}
else{
iter_prev = iter;
}
if( Instance_isSelected( *instance ) || instance->childSelected() ){
if( iter_first.stamp == 0 ){
iter_first = iter;
}
if( iter_found.stamp != 0 ){
iter_next = iter;
break;
}
if( node == getEntityList().m_search_focus_node ){
iter_found = iter;
}
else{
iter_prev = iter;
}
}
}

View File

@ -1246,9 +1246,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
}
if ( !path.top().get().isRoot() ) {
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0
&& selectable->isSelected() ) {
if ( Instance_isSelected( instance ) ) {
return false;
}
if( m_makeUnique && instance.childSelected() ){ /* clone group entity primitives to new group entity */
@ -1271,9 +1269,7 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
}
if ( !path.top().get().isRoot() ) {
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0
&& selectable->isSelected() ) {
if ( Instance_isSelected( instance ) ) {
NodeSmartReference clone( Node_Clone( path.top() ) );
Map_gatherNamespaced( clone );
Node_getTraversable( path.parent().get() )->insert( clone );
@ -1748,7 +1744,7 @@ 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() ) {
&& Instance_isSelected( instance ) ) {
snappable->snapto( m_snap );
}
}
@ -1771,7 +1767,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
ComponentSnappable* componentSnappable = Instance_getComponentSnappable( instance );
if ( componentSnappable != 0
&& Instance_getSelectable( instance )->isSelected() ) {
&& Instance_isSelected( instance ) ) {
componentSnappable->snapComponents( m_snap );
}
}

View File

@ -1219,9 +1219,7 @@ AnyInstanceSelected( bool& selected ) : m_selected( selected ){
m_selected = false;
}
void visit( scene::Instance& instance ) const {
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0
&& selectable->isSelected() ) {
if ( Instance_isSelected( instance ) ) {
m_selected = true;
}
}
@ -1819,8 +1817,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
}
void post( const scene::Path& path, scene::Instance& instance ) const {
if ( Node_isPrimitive( path.top() ) ){
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable && selectable->isSelected() ){
if ( Instance_isSelected( instance ) ){
NodeSmartReference node( path.top().get() );
scene::Traversable* parent_traversable = Node_getTraversable( path.parent() );
parent_traversable->erase( node );
@ -1856,9 +1853,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( ++m_depth != 1 && path.top().get().isRoot() ) {
return false;
}
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0
&& selectable->isSelected()
if ( Instance_isSelected( instance )
&& Node_isPrimitive( path.top() ) ) {
++m_count;
}

View File

@ -1881,7 +1881,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Patch* patch = Node_getPatch( path.top() );
if ( patch != 0
&& Instance_getSelectable( instance )->isSelected() ) {
&& Instance_isSelected( instance ) ) {
m_functor( *patch );
}
}

View File

@ -141,8 +141,7 @@ bool pre( const scene::Path& path, scene::Instance& instance, VolumeIntersection
renderable->viewChanged();
}
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0 && selectable->isSelected() ) {
if ( Instance_isSelected( instance ) ) {
if ( GlobalSelectionSystem().Mode() != SelectionSystem::eComponent ) {
m_renderer.Highlight( Renderer::eFace );
}

View File

@ -80,9 +80,7 @@ void visit( scene::Instance& instance ) const {
return;
}
Selectable* selectable = Instance_getSelectable( instance );
if ( ( selectable != 0 )
&& instance.isSelected() ) {
if ( Instance_isSelected( instance ) ) {
// brushes only
if ( Instance_getBrush( instance ) != 0 ) {
m_bounds[m_count] = instance.worldAABB();
@ -226,9 +224,7 @@ DeleteSelected()
bool pre( const scene::Path& path, scene::Instance& instance ) const {
m_removedChild = false;
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0
&& selectable->isSelected()
if ( Instance_isSelected( instance )
&& path.size() > 1
&& !path.top().get().isRoot() ) {
m_remove = true;
@ -782,8 +778,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
Entity* entity = Node_getEntity( path.top() );
if ( entity != 0 ){
if( path.top().get_pointer() != m_world ){
Selectable* selectable = Instance_getSelectable( instance );
if ( ( selectable != 0 && selectable->isSelected() ) || instance.childSelected() ) {
if ( Instance_isSelected( instance ) || instance.childSelected() ) {
if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
m_propertyvalues.push_back( entity->getKeyValue( m_prop ) );
}
@ -806,9 +801,7 @@ EntityGetSelectedPropertyValuesWalker( const char *prop, PropertyValues& propert
: m_propertyvalues( propertyvalues ), m_prop( prop ), m_selected_children( false ), m_world( Map_FindWorldspawn( g_map ) ){
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0
&& selectable->isSelected() ) {
if ( Instance_isSelected( instance ) ) {
Entity* entity = Node_getEntity( path.top() );
if ( entity != 0 ) {
if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
@ -931,9 +924,7 @@ HideSelectedWalker( bool hide )
: m_hide( hide ){
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0
&& selectable->isSelected() ) {
if ( Instance_isSelected( instance ) ) {
g_nodes_be_hidden = m_hide;
hide_node( path.top(), m_hide );
}
@ -1491,8 +1482,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
Entity* entity = Node_getEntity( path.top() );
if ( entity != 0 ){
if( path.top().get_pointer() != m_world ){
Selectable* selectable = Instance_getSelectable( instance );
if ( ( selectable != 0 && selectable->isSelected() ) || instance.childSelected() ) {
if ( Instance_isSelected( instance ) || instance.childSelected() ) {
const char* keyvalue = entity->getKeyValue( m_prop );
if ( !string_empty( keyvalue ) && !propertyvalues_contain( m_propertyvalues, keyvalue ) ) {
m_propertyvalues.push_back( keyvalue );

View File

@ -2678,13 +2678,10 @@ PlaneSelectableSelectPlanes( Selector& selector, SelectionTest& test, const Plan
: m_selector( selector ), m_test( test ), m_selectedPlaneCallback( selectedPlaneCallback ){
}
bool 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( m_selector, m_test, m_selectedPlaneCallback );
}
if ( path.top().get().visible() && Instance_isSelected( instance ) ) {
PlaneSelectable* planeSelectable = Instance_getPlaneSelectable( instance );
if ( planeSelectable != 0 ) {
planeSelectable->selectPlanes( m_selector, m_test, m_selectedPlaneCallback );
}
}
return true;
@ -2700,13 +2697,10 @@ PlaneSelectableSelectReversedPlanes( Selector& selector, const SelectedPlanes& s
: m_selector( selector ), m_selectedPlanes( selectedPlanes ){
}
bool 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->selectReversedPlanes( m_selector, m_selectedPlanes );
}
if ( path.top().get().visible() && Instance_isSelected( instance ) ) {
PlaneSelectable* planeSelectable = Instance_getPlaneSelectable( instance );
if ( planeSelectable != 0 ) {
planeSelectable->selectReversedPlanes( m_selector, m_selectedPlanes );
}
}
return true;
@ -2809,13 +2803,10 @@ PlaneSelectable_bestPlaneDirect( SelectionTest& test, Plane3& plane )
: m_test( test ), m_plane( plane ), m_intersection(){
}
bool 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->bestPlaneDirect( m_test, m_plane, m_intersection );
}
if ( path.top().get().visible() && Instance_isSelected( instance ) ) {
PlaneSelectable* planeSelectable = Instance_getPlaneSelectable( instance );
if ( planeSelectable != 0 ) {
planeSelectable->bestPlaneDirect( m_test, m_plane, m_intersection );
}
}
return true;
@ -2832,13 +2823,10 @@ PlaneSelectable_bestPlaneIndirect( SelectionTest& test, Plane3& plane, Vector3&
: m_test( test ), m_plane( plane ), m_intersection( intersection ), m_dist( FLT_MAX ){
}
bool 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->bestPlaneIndirect( m_test, m_plane, m_intersection, m_dist );
}
if ( path.top().get().visible() && Instance_isSelected( instance ) ) {
PlaneSelectable* planeSelectable = Instance_getPlaneSelectable( instance );
if ( planeSelectable != 0 ) {
planeSelectable->bestPlaneIndirect( m_test, m_plane, m_intersection, m_dist );
}
}
return true;
@ -2853,13 +2841,10 @@ PlaneSelectable_selectByPlane( const Plane3& plane )
: m_plane( plane ){
}
bool 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->selectByPlane( m_plane );
}
if ( path.top().get().visible() && Instance_isSelected( instance ) ) {
PlaneSelectable* planeSelectable = Instance_getPlaneSelectable( instance );
if ( planeSelectable != 0 ) {
planeSelectable->selectByPlane( m_plane );
}
}
return true;
@ -7386,8 +7371,7 @@ testselect_component_visible_selected( Selector& selector, SelectionTest& test,
: m_selector( selector ), m_test( test ), m_mode( mode ){
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0 && selectable->isSelected() ) {
if ( Instance_isSelected( instance ) ) {
ComponentSelectionTestable* componentSelectionTestable = Instance_getComponentSelectionTestable( instance );
if ( componentSelectionTestable ) {
componentSelectionTestable->testSelectComponents( m_selector, m_test, m_mode );
@ -7551,9 +7535,7 @@ bounds_selected( AABB& bounds )
m_bounds = AABB();
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0
&& selectable->isSelected() ) {
if ( Instance_isSelected( instance ) ) {
aabb_extend_by_aabb_safe( m_bounds, Instance_getPivotBounds( instance ) );
}
return true;
@ -7569,9 +7551,7 @@ bounds_selected_component( AABB& bounds )
m_bounds = AABB();
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0
&& selectable->isSelected() ) {
if ( Instance_isSelected( instance ) ) {
ComponentEditable* componentEditable = Instance_getComponentEditable( instance );
if ( componentEditable ) {
aabb_extend_by_aabb_safe( m_bounds, aabb_for_oriented_aabb_safe( componentEditable->getSelectedComponentsBounds(), instance.localToWorld() ) );