* fix clone, clone-make-unique, select all of type, expand selection to entities/primitives for maps w/o worldspawn
This commit is contained in:
parent
5c48131eba
commit
cc997fd5a1
|
|
@ -1207,19 +1207,17 @@ void SelectFaceMode(){
|
||||||
|
|
||||||
class CloneSelected : public scene::Graph::Walker
|
class CloneSelected : public scene::Graph::Walker
|
||||||
{
|
{
|
||||||
bool doMakeUnique;
|
const bool m_makeUnique;
|
||||||
NodeSmartReference worldspawn;
|
const scene::Node* m_world;
|
||||||
public:
|
public:
|
||||||
CloneSelected( bool d ) : doMakeUnique( d ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
|
CloneSelected( bool makeUnique ) : m_makeUnique( makeUnique ), m_world( Map_FindWorldspawn( g_map ) ){
|
||||||
}
|
}
|
||||||
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
if ( path.size() == 1 ) {
|
if ( path.size() == 1 ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore worldspawn, but keep checking children
|
if ( path.top().get_pointer() == m_world ) { // ignore worldspawn, but keep checking children
|
||||||
NodeSmartReference me( path.top().get() );
|
|
||||||
if ( me == worldspawn ) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1229,7 +1227,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
&& selectable->isSelected() ) {
|
&& selectable->isSelected() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( doMakeUnique && instance.childSelected() ){
|
if( m_makeUnique && instance.childSelected() ){
|
||||||
NodeSmartReference clone( Node_Clone_Selected( path.top() ) );
|
NodeSmartReference clone( Node_Clone_Selected( path.top() ) );
|
||||||
Map_gatherNamespaced( clone );
|
Map_gatherNamespaced( clone );
|
||||||
Node_getTraversable( path.parent().get() )->insert( clone );
|
Node_getTraversable( path.parent().get() )->insert( clone );
|
||||||
|
|
@ -1244,9 +1242,7 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore worldspawn, but keep checking children
|
if ( path.top().get_pointer() == m_world ) { // ignore worldspawn
|
||||||
NodeSmartReference me( path.top().get() );
|
|
||||||
if ( me == worldspawn ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1255,7 +1251,7 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
if ( selectable != 0
|
if ( selectable != 0
|
||||||
&& selectable->isSelected() ) {
|
&& selectable->isSelected() ) {
|
||||||
NodeSmartReference clone( Node_Clone( path.top() ) );
|
NodeSmartReference clone( Node_Clone( path.top() ) );
|
||||||
if ( doMakeUnique ) {
|
if ( m_makeUnique ) {
|
||||||
Map_gatherNamespaced( clone );
|
Map_gatherNamespaced( clone );
|
||||||
}
|
}
|
||||||
Node_getTraversable( path.parent().get() )->insert( clone );
|
Node_getTraversable( path.parent().get() )->insert( clone );
|
||||||
|
|
@ -1264,8 +1260,8 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void Scene_Clone_Selected( scene::Graph& graph, bool doMakeUnique ){
|
void Scene_Clone_Selected( scene::Graph& graph, bool makeUnique ){
|
||||||
graph.traverse( CloneSelected( doMakeUnique ) );
|
graph.traverse( CloneSelected( makeUnique ) );
|
||||||
|
|
||||||
Map_mergeClonedNames();
|
Map_mergeClonedNames();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -333,19 +333,20 @@ void Select_Invert(){
|
||||||
Scene_Invert_Selection( GlobalSceneGraph() );
|
Scene_Invert_Selection( GlobalSceneGraph() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
//interesting printings
|
//interesting printings
|
||||||
class ExpandSelectionToEntitiesWalker_dbg : public scene::Graph::Walker
|
class ExpandSelectionToEntitiesWalker_dbg : public scene::Graph::Walker
|
||||||
{
|
{
|
||||||
mutable std::size_t m_depth;
|
mutable std::size_t m_depth;
|
||||||
NodeSmartReference worldspawn;
|
const scene::Node* m_world;
|
||||||
public:
|
public:
|
||||||
ExpandSelectionToEntitiesWalker_dbg() : m_depth( 0 ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
|
ExpandSelectionToEntitiesWalker_dbg() : m_depth( 0 ), m_world( Map_FindWorldspawn( g_map ) ){
|
||||||
}
|
}
|
||||||
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
++m_depth;
|
++m_depth;
|
||||||
globalOutputStream() << "pre depth_" << m_depth;
|
globalOutputStream() << "pre depth_" << m_depth;
|
||||||
globalOutputStream() << " path.size()_" << path.size();
|
globalOutputStream() << " path.size()_" << path.size();
|
||||||
if ( path.top().get() == worldspawn )
|
if ( path.top().get_pointer() == m_world )
|
||||||
globalOutputStream() << " worldspawn";
|
globalOutputStream() << " worldspawn";
|
||||||
if( path.top().get().isRoot() )
|
if( path.top().get().isRoot() )
|
||||||
globalOutputStream() << " path.top().get().isRoot()";
|
globalOutputStream() << " path.top().get().isRoot()";
|
||||||
|
|
@ -367,7 +368,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
void post( const scene::Path& path, scene::Instance& instance ) const {
|
void post( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
globalOutputStream() << "post depth_" << m_depth;
|
globalOutputStream() << "post depth_" << m_depth;
|
||||||
globalOutputStream() << " path.size()_" << path.size();
|
globalOutputStream() << " path.size()_" << path.size();
|
||||||
if ( path.top().get() == worldspawn )
|
if ( path.top().get_pointer() == m_world )
|
||||||
globalOutputStream() << " worldspawn";
|
globalOutputStream() << " worldspawn";
|
||||||
if( path.top().get().isRoot() )
|
if( path.top().get().isRoot() )
|
||||||
globalOutputStream() << " path.top().get().isRoot()";
|
globalOutputStream() << " path.top().get().isRoot()";
|
||||||
|
|
@ -383,13 +384,14 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
--m_depth;
|
--m_depth;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
class ExpandSelectionToPrimitivesWalker : public scene::Graph::Walker
|
class ExpandSelectionToPrimitivesWalker : public scene::Graph::Walker
|
||||||
{
|
{
|
||||||
mutable std::size_t m_depth;
|
mutable std::size_t m_depth;
|
||||||
NodeSmartReference worldspawn;
|
const scene::Node* m_world;
|
||||||
public:
|
public:
|
||||||
ExpandSelectionToPrimitivesWalker() : m_depth( 0 ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
|
ExpandSelectionToPrimitivesWalker() : m_depth( 0 ), m_world( Map_FindWorldspawn( g_map ) ){
|
||||||
}
|
}
|
||||||
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
++m_depth;
|
++m_depth;
|
||||||
|
|
@ -397,11 +399,8 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
if( !path.top().get().visible() )
|
if( !path.top().get().visible() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// ignore worldspawn
|
// if ( path.top().get_pointer() == m_world ) // ignore worldspawn
|
||||||
// NodeSmartReference me( path.top().get() );
|
|
||||||
// if ( me == worldspawn ) {
|
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
|
||||||
|
|
||||||
if ( m_depth == 2 ) { // entity depth
|
if ( m_depth == 2 ) { // entity depth
|
||||||
// traverse and select children if any one is selected
|
// traverse and select children if any one is selected
|
||||||
|
|
@ -431,9 +430,9 @@ void Scene_ExpandSelectionToPrimitives(){
|
||||||
class ExpandSelectionToEntitiesWalker : public scene::Graph::Walker
|
class ExpandSelectionToEntitiesWalker : public scene::Graph::Walker
|
||||||
{
|
{
|
||||||
mutable std::size_t m_depth;
|
mutable std::size_t m_depth;
|
||||||
NodeSmartReference worldspawn;
|
const scene::Node* m_world;
|
||||||
public:
|
public:
|
||||||
ExpandSelectionToEntitiesWalker() : m_depth( 0 ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
|
ExpandSelectionToEntitiesWalker() : m_depth( 0 ), m_world( Map_FindWorldspawn( g_map ) ){
|
||||||
}
|
}
|
||||||
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
++m_depth;
|
++m_depth;
|
||||||
|
|
@ -441,18 +440,15 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
if( !path.top().get().visible() )
|
if( !path.top().get().visible() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// ignore worldspawn
|
// if ( path.top().get_pointer() == m_world ) // ignore worldspawn
|
||||||
// NodeSmartReference me( path.top().get() );
|
|
||||||
// if ( me == worldspawn ) {
|
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
|
||||||
|
|
||||||
if ( m_depth == 2 ) { // entity depth
|
if ( m_depth == 2 ) { // entity depth
|
||||||
// traverse and select children if any one is selected
|
// traverse and select children if any one is selected
|
||||||
bool beselected = false;
|
bool beselected = false;
|
||||||
if ( instance.childSelected() || instance.isSelected() ) {
|
if ( instance.childSelected() || instance.isSelected() ) {
|
||||||
beselected = true;
|
beselected = true;
|
||||||
if( path.top().get() != worldspawn ){
|
if( path.top().get_pointer() != m_world ){ //avoid selecting world node
|
||||||
Instance_setSelected( instance, true );
|
Instance_setSelected( instance, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -743,17 +739,17 @@ class EntityFindByPropertyValueWalker : public scene::Graph::Walker
|
||||||
{
|
{
|
||||||
const PropertyValues& m_propertyvalues;
|
const PropertyValues& m_propertyvalues;
|
||||||
const char *m_prop;
|
const char *m_prop;
|
||||||
const NodeSmartReference worldspawn;
|
const scene::Node* m_world;
|
||||||
public:
|
public:
|
||||||
EntityFindByPropertyValueWalker( const char *prop, const PropertyValues& propertyvalues )
|
EntityFindByPropertyValueWalker( const char *prop, const PropertyValues& propertyvalues )
|
||||||
: m_propertyvalues( propertyvalues ), m_prop( prop ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
|
: m_propertyvalues( propertyvalues ), m_prop( prop ), m_world( Map_FindWorldspawn( g_map ) ){
|
||||||
}
|
}
|
||||||
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
if( !path.top().get().visible() ){
|
if( !path.top().get().visible() ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// ignore worldspawn
|
// ignore worldspawn
|
||||||
if ( path.top().get() == worldspawn ) {
|
if ( path.top().get_pointer() == m_world ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -782,15 +778,15 @@ class EntityGetSelectedPropertyValuesWalker : public scene::Graph::Walker
|
||||||
{
|
{
|
||||||
PropertyValues& m_propertyvalues;
|
PropertyValues& m_propertyvalues;
|
||||||
const char *m_prop;
|
const char *m_prop;
|
||||||
const NodeSmartReference worldspawn;
|
const scene::Node* m_world;
|
||||||
public:
|
public:
|
||||||
EntityGetSelectedPropertyValuesWalker( const char *prop, PropertyValues& propertyvalues )
|
EntityGetSelectedPropertyValuesWalker( const char *prop, PropertyValues& propertyvalues )
|
||||||
: m_propertyvalues( propertyvalues ), m_prop( prop ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
|
: m_propertyvalues( propertyvalues ), m_prop( prop ), m_world( Map_FindWorldspawn( g_map ) ){
|
||||||
}
|
}
|
||||||
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
Entity* entity = Node_getEntity( path.top() );
|
Entity* entity = Node_getEntity( path.top() );
|
||||||
if ( entity != 0 ){
|
if ( entity != 0 ){
|
||||||
if( path.top().get() != worldspawn ){
|
if( path.top().get_pointer() != m_world ){
|
||||||
Selectable* selectable = Instance_getSelectable( instance );
|
Selectable* selectable = Instance_getSelectable( instance );
|
||||||
if ( ( selectable != 0 && selectable->isSelected() ) || instance.childSelected() ) {
|
if ( ( selectable != 0 && selectable->isSelected() ) || instance.childSelected() ) {
|
||||||
if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
|
if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
|
||||||
|
|
@ -809,10 +805,10 @@ class EntityGetSelectedPropertyValuesWalker : public scene::Graph::Walker
|
||||||
PropertyValues& m_propertyvalues;
|
PropertyValues& m_propertyvalues;
|
||||||
const char *m_prop;
|
const char *m_prop;
|
||||||
mutable bool m_selected_children;
|
mutable bool m_selected_children;
|
||||||
const NodeSmartReference worldspawn;
|
const scene::Node* m_world;
|
||||||
public:
|
public:
|
||||||
EntityGetSelectedPropertyValuesWalker( const char *prop, PropertyValues& propertyvalues )
|
EntityGetSelectedPropertyValuesWalker( const char *prop, PropertyValues& propertyvalues )
|
||||||
: m_propertyvalues( propertyvalues ), m_prop( prop ), m_selected_children( false ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
|
: 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 {
|
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
Selectable* selectable = Instance_getSelectable( instance );
|
Selectable* selectable = Instance_getSelectable( instance );
|
||||||
|
|
@ -835,7 +831,7 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
Entity* entity = Node_getEntity( path.top() );
|
Entity* entity = Node_getEntity( path.top() );
|
||||||
if( entity != 0 && m_selected_children ){
|
if( entity != 0 && m_selected_children ){
|
||||||
m_selected_children = false;
|
m_selected_children = false;
|
||||||
if( path.top().get() == worldspawn )
|
if( path.top().get_pointer() == m_world )
|
||||||
return;
|
return;
|
||||||
if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
|
if ( !propertyvalues_contain( m_propertyvalues, entity->getKeyValue( m_prop ) ) ) {
|
||||||
m_propertyvalues.push_back( entity->getKeyValue( m_prop ) );
|
m_propertyvalues.push_back( entity->getKeyValue( m_prop ) );
|
||||||
|
|
@ -1486,15 +1482,15 @@ class EntityGetSelectedPropertyValuesWalker_nonEmpty : public scene::Graph::Walk
|
||||||
{
|
{
|
||||||
PropertyValues& m_propertyvalues;
|
PropertyValues& m_propertyvalues;
|
||||||
const char *m_prop;
|
const char *m_prop;
|
||||||
const NodeSmartReference worldspawn;
|
const scene::Node* m_world;
|
||||||
public:
|
public:
|
||||||
EntityGetSelectedPropertyValuesWalker_nonEmpty( const char *prop, PropertyValues& propertyvalues )
|
EntityGetSelectedPropertyValuesWalker_nonEmpty( const char *prop, PropertyValues& propertyvalues )
|
||||||
: m_propertyvalues( propertyvalues ), m_prop( prop ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
|
: m_propertyvalues( propertyvalues ), m_prop( prop ), m_world( Map_FindWorldspawn( g_map ) ){
|
||||||
}
|
}
|
||||||
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
bool pre( const scene::Path& path, scene::Instance& instance ) const {
|
||||||
Entity* entity = Node_getEntity( path.top() );
|
Entity* entity = Node_getEntity( path.top() );
|
||||||
if ( entity != 0 ){
|
if ( entity != 0 ){
|
||||||
if( path.top().get() != worldspawn ){
|
if( path.top().get_pointer() != m_world ){
|
||||||
Selectable* selectable = Instance_getSelectable( instance );
|
Selectable* selectable = Instance_getSelectable( instance );
|
||||||
if ( ( selectable != 0 && selectable->isSelected() ) || instance.childSelected() ) {
|
if ( ( selectable != 0 && selectable->isSelected() ) || instance.childSelected() ) {
|
||||||
const char* keyvalue = entity->getKeyValue( m_prop );
|
const char* keyvalue = entity->getKeyValue( m_prop );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user