]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/entity.cpp
Merge commit '461d008daa6328113ea4ccda37e5604d3df14ba3' into garux-merge
[xonotic/netradiant.git] / radiant / entity.cpp
index 9f36b89c0f4e2c11495c7436b00542e73518fd69..3a7eddb258218c287da5bc146daeca682c1f6a0c 100644 (file)
@@ -103,17 +103,20 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
 
                EntityCopyingVisitor visitor( *Node_getEntity( node ) );
 
-               entity->forEachKeyValue( visitor );
+               //entity->forEachKeyValue( visitor );
 
                NodeSmartReference child( path.top().get() );
                NodeSmartReference parent( path.parent().get() );
-               Node_getTraversable( parent )->erase( child );
+               //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 );
+               /* 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 */
+               entity->forEachKeyValue( visitor );
+               Node_getTraversable( parent )->erase( child );
        }
 }
 };
@@ -313,6 +316,19 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){
 
        bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0;
 
+       //is important to have retexturing here; if doing in the end, undo doesn't succeed;
+       if ( string_compare_nocase_n( name, "trigger_", 8 ) == 0 && brushesSelected ){
+               const char* shader = g_pGameDescription->getKeyValue( "shader_trigger" );
+               if ( shader && *shader ){
+                       Scene_PatchSetShader_Selected( GlobalSceneGraph(), shader );
+                       Scene_BrushSetShader_Selected( GlobalSceneGraph(), shader );
+               }
+               else{
+                       Scene_PatchSetShader_Selected( GlobalSceneGraph(), "textures/common/trigger" );
+                       Scene_BrushSetShader_Selected( GlobalSceneGraph(), "textures/common/trigger" );
+               }
+       }
+
        if ( !( entityClass->fixedsize || isModel ) && !brushesSelected ) {
                globalErrorStream() << "failed to create a group entity - no brushes are selected\n";
                return;
@@ -399,18 +415,6 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){
                        Node_getEntity( node )->setKeyValue( "model", model );
                }
        }
-
-       if ( string_compare_nocase_n( name, "trigger_", 8 ) == 0 && brushesSelected ){
-               const char* shader = g_pGameDescription->getKeyValue( "shader_trigger" );
-               if ( shader && *shader ){
-                       Scene_PatchSetShader_Selected( GlobalSceneGraph(), shader );
-                       Scene_BrushSetShader_Selected( GlobalSceneGraph(), shader );
-               }
-               else{
-                       Scene_PatchSetShader_Selected( GlobalSceneGraph(), "textures/common/trigger" );
-                       Scene_BrushSetShader_Selected( GlobalSceneGraph(), "textures/common/trigger" );
-               }
-       }
 }
 
 #if 0
@@ -487,6 +491,10 @@ void Entity_normalizeColor(){
                const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
                Entity* entity = Node_getEntity( path.top() );
 
+               if( entity == 0 && path.size() == 3 ){
+                       entity = Node_getEntity( path.parent() );
+               }
+
                if ( entity != 0 ) {
                        const char* strColor = entity->getKeyValue( "_color" );
                        if ( !string_empty( strColor ) ) {
@@ -514,6 +522,11 @@ void Entity_setColour(){
        if ( GlobalSelectionSystem().countSelected() != 0 ) {
                const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
                Entity* entity = Node_getEntity( path.top() );
+
+               if( entity == 0 && path.size() == 3 ){
+                       entity = Node_getEntity( path.parent() );
+               }
+
                if ( entity != 0 ) {
                        const char* strColor = entity->getKeyValue( "_color" );
                        if ( !string_empty( strColor ) ) {