* region XY: only deselect excluded objects for convenience

This commit is contained in:
Garux 2019-03-24 23:05:14 +03:00
parent 12d010446b
commit 213b680a3c
4 changed files with 31 additions and 49 deletions

View File

@ -866,12 +866,9 @@ inline void Instance_setSelected( scene::Instance& instance, bool selected ){
}
}
inline bool Instance_isSelected( scene::Instance& instance ){
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0 ) {
return selectable->isSelected();
}
return false;
inline bool Instance_isSelected( const scene::Instance& instance ){
const Selectable* selectable = Instance_getSelectable( instance );
return selectable != 0 && selectable->isSelected();
}
inline scene::Instance& findInstance( const scene::Path& path ){

View File

@ -1537,11 +1537,6 @@ void Scene_Exclude_All( bool exclude ){
GlobalSceneGraph().traverse( ExcludeAllWalker( exclude ) );
}
bool Instance_isSelected( const scene::Instance& instance ){
const Selectable* selectable = Instance_getSelectable( instance );
return selectable != 0 && selectable->isSelected();
}
class ExcludeSelectedWalker : public scene::Graph::Walker
{
bool m_exclude;
@ -1562,25 +1557,19 @@ void Scene_Exclude_Selected( bool exclude ){
class ExcludeRegionedWalker : public scene::Graph::Walker
{
bool m_exclude;
const bool m_exclude;
const AABB m_region = aabb_for_minmax( g_region_mins, g_region_maxs );
public:
ExcludeRegionedWalker( bool exclude )
: m_exclude( exclude ){
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if( !path.top().get().isRoot() ) /* don't touch model node: disabling one will disable all its instances! */
exclude_node(
path.top(),
!(
(
aabb_intersects_aabb(
instance.worldAABB(),
aabb_for_minmax( g_region_mins, g_region_maxs )
) != 0
) ^ m_exclude
)
);
if( !path.top().get().isRoot() ){ /* don't touch model node: disabling one will disable all its instances! */
const bool exclude = m_exclude == aabb_intersects_aabb( instance.worldAABB(), m_region );
exclude_node( path.top(), exclude );
if( exclude )
Instance_setSelected( instance, false );
}
return true;
}
};
@ -1614,12 +1603,9 @@ void Map_ApplyRegion(){
g_region_item.update();
Scene_Exclude_Region( false );
/* newly created brushes have to visible! */
/* newly created brushes have to be visible! */
if( scene::Node* w = Map_FindWorldspawn( g_map ) )
exclude_node( *w, false );
if( GlobalSelectionSystem().countSelected() != 0 )
GlobalSelectionSystem().setSelectedAll( false );
}
@ -1638,7 +1624,7 @@ void Map_RegionSelectedBrushes(){
Select_GetBounds( g_region_mins, g_region_maxs );
Scene_Exclude_Selected( false );
/* newly created brushes have to visible! */
/* newly created brushes have to be visible! */
if( scene::Node* w = Map_FindWorldspawn( g_map ) )
exclude_node( *w, false );
@ -1669,8 +1655,6 @@ void Map_RegionBounds( const AABB& bounds ){
g_region_mins = vector3_subtracted( bounds.origin, bounds.extents );
g_region_maxs = vector3_added( bounds.origin, bounds.extents );
// deleteSelection();
Map_ApplyRegion();
}
@ -1684,10 +1668,11 @@ void Map_RegionBrush( void ){
scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
Map_RegionBounds( instance.worldAABB() );
if( Selectable* selectable = Instance_getSelectable( instance ) ){
selectable->setSelected( true );
deleteSelection();
if( GlobalSelectionSystem().countSelected() != 1 ){
GlobalSelectionSystem().setSelectedAll( false );
Instance_setSelected( instance, true );
}
deleteSelection();
}
else{
globalErrorStream() << "Nothing is selected!\n";
@ -2079,17 +2064,17 @@ void RegionOff(){
}
void RegionXY(){
VIEWTYPE viewtype = GlobalXYWnd_getCurrentViewType();
int nDim1 = ( viewtype == YZ ) ? 1 : 0;
int nDim2 = ( viewtype == XY ) ? 1 : 2;
int nDim = static_cast<int>( viewtype );
XYWnd* wnd = g_pParentWnd->ActiveXY();
const VIEWTYPE viewtype = GlobalXYWnd_getCurrentViewType();
const int nDim1 = ( viewtype == YZ ) ? 1 : 0;
const int nDim2 = ( viewtype == XY ) ? 1 : 2;
const int nDim = static_cast<int>( viewtype );
const XYWnd& wnd = *( g_pParentWnd->ActiveXY() );
Vector3 min, max;
min[nDim1] = wnd->GetOrigin()[nDim1] - 0.5f * wnd->Width() / wnd->Scale();
min[nDim2] = wnd->GetOrigin()[nDim2] - 0.5f * wnd->Height() / wnd->Scale();
min[nDim1] = wnd.GetOrigin()[nDim1] - 0.5f * wnd.Width() / wnd.Scale();
min[nDim2] = wnd.GetOrigin()[nDim2] - 0.5f * wnd.Height() / wnd.Scale();
min[nDim] = g_MinWorldCoord + 64;
max[nDim1] = wnd->GetOrigin()[nDim1] + 0.5f * wnd->Width() / wnd->Scale();
max[nDim2] = wnd->GetOrigin()[nDim2] + 0.5f * wnd->Height() / wnd->Scale();
max[nDim1] = wnd.GetOrigin()[nDim1] + 0.5f * wnd.Width() / wnd.Scale();
max[nDim2] = wnd.GetOrigin()[nDim2] + 0.5f * wnd.Height() / wnd.Scale();
max[nDim] = g_MaxWorldCoord - 64;
Map_RegionXY( min, max );

View File

@ -687,7 +687,7 @@ void XYWnd::releaseStates(){
GlobalShaderCache().release( "$XY_OVERLAY" );
}
const Vector3& XYWnd::GetOrigin(){
const Vector3& XYWnd::GetOrigin() const {
return m_vOrigin;
}

View File

@ -114,7 +114,7 @@ static void recaptureStates(){
}
void PositionView( const Vector3& position );
const Vector3& GetOrigin();
const Vector3& GetOrigin() const;
void SetOrigin( const Vector3& origin );
void Scroll( int x, int y );
@ -244,13 +244,13 @@ VIEWTYPE GetViewType(){
return m_viewType;
}
void SetScale( float f );
float Scale(){
float Scale() const {
return m_fScale;
}
int Width(){
int Width() const {
return m_nWidth;
}
int Height(){
int Height() const {
return m_nHeight;
}