]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/surfaceplugin.cpp
* applied Shamus Jedi Academy patch for Zeroradiant (gamepack will follow soon)
[xonotic/netradiant.git] / radiant / surfaceplugin.cpp
index 320ee86cb786354fbe3c1da6bf2e7ea01027f9b7..0e04f9895b36d0013cd5910faa2b506d095bad36 100644 (file)
@@ -73,6 +73,7 @@ void SI_GetSelFacesTexdef(texdef_to_face_t *allocd_block_texdef)
   face_t       *f;
   brush_t      *b;
   texdef_to_face_t *position, *prev_pos;
+  brushprimit_texdef_t bp;
 
   if(selected_brushes.next != &selected_brushes)
   {
@@ -85,8 +86,14 @@ void SI_GetSelFacesTexdef(texdef_to_face_t *allocd_block_texdef)
         {
             position->face = f;
             position->brush = b;
-            position->texdef = f->texdef;
-            position->orig_texdef = f->texdef;
+                       position->texdef = f->texdef;
+                       if(g_qeglobals.m_bBrushPrimitMode)
+                       {
+                               ConvertTexMatWithQTexture(&f->brushprimit_texdef, QERApp_Shader_ForName( f->texdef.GetName() )->getTexture(), &bp, NULL);
+                               TexMatToFakeTexCoords(bp.coords, position->texdef.shift, &position->texdef.rotate, position->texdef.scale);
+                               position->orig_bp_texdef = bp;
+                       }
+                       position->orig_texdef = position->texdef;
             prev_pos->next = position;
             prev_pos = position;
             position++;
@@ -103,7 +110,13 @@ void SI_GetSelFacesTexdef(texdef_to_face_t *allocd_block_texdef)
     position->face = f;
     position->brush = b;
     position->texdef = f->texdef;
-    position->orig_texdef = f->texdef;
+       if(g_qeglobals.m_bBrushPrimitMode)
+       {
+               ConvertTexMatWithQTexture(&f->brushprimit_texdef, QERApp_Shader_ForName( f->texdef.GetName() )->getTexture(), &bp, NULL);
+               TexMatToFakeTexCoords(bp.coords, position->texdef.shift, &position->texdef.rotate, position->texdef.scale);
+               position->orig_bp_texdef = bp;
+       }
+    position->orig_texdef = position->texdef;
     prev_pos = position;
     for(i=1; i<g_ptrSelectedFaces.GetSize(); i++)
     {
@@ -113,7 +126,13 @@ void SI_GetSelFacesTexdef(texdef_to_face_t *allocd_block_texdef)
       position->face = f;
       position->brush = b;
       position->texdef = f->texdef;
-      position->orig_texdef = f->texdef;
+         if(g_qeglobals.m_bBrushPrimitMode)
+         {
+                 ConvertTexMatWithQTexture(&f->brushprimit_texdef, QERApp_Shader_ForName( f->texdef.GetName() )->getTexture(), &bp, NULL);
+                 TexMatToFakeTexCoords(bp.coords, position->texdef.shift, &position->texdef.rotate, position->texdef.scale);
+                 position->orig_bp_texdef = bp;
+         }
+      position->orig_texdef = position->texdef;
       prev_pos->next = position;
       prev_pos = position;
     }
@@ -168,14 +187,14 @@ void SI_SetTexdef_FaceList(texdef_to_face_t* texdef_face_list, bool b_SetUndoPoi
   texdef_to_face_t* texdef_to_face;
   bool b_isQuake2;
 
-  if ( ( g_pGameDescription->quake2 ) || ( g_pGameDescription->mGameFile == "q2.game" ) || ( g_pGameDescription->mGameFile == "heretic2.game" ) )
+  if (g_pGameDescription->quake2)
     b_isQuake2 = true;
   else
     b_isQuake2 = false;
 
   if (!texdef_face_list)
     return;
-    
+
  if (b_SetUndoPoint)
  {
     if(g_ptrSelectedFaces.GetSize() > 1)
@@ -187,51 +206,59 @@ void SI_SetTexdef_FaceList(texdef_to_face_t* texdef_face_list, bool b_SetUndoPoi
       if (b_isQuake2)
         SetFaceTexdef_Q2(texdef_to_face->face, &texdef_to_face->orig_texdef, bFit_to_Scale);
       else
-        SetFaceTexdef(texdef_to_face->face, &texdef_to_face->orig_texdef, NULL);
+        SetFaceTexdef(texdef_to_face->face, &texdef_to_face->orig_texdef, &texdef_to_face->orig_bp_texdef, bFit_to_Scale);
 
       Undo_Start("set facelist texdefs");
-      
+
       if( selected_brushes.next != &selected_brushes )
-        Undo_AddBrushList(&selected_brushes); 
+        Undo_AddBrushList(&selected_brushes);
       else
         Undo_AddBrush(texdef_face_list->brush);
-      
+
     }
- }  
-    
+ }
+
   for(texdef_to_face = texdef_face_list; texdef_to_face; texdef_to_face = texdef_to_face->next)
   {
     if (b_isQuake2)
       SetFaceTexdef_Q2(texdef_to_face->face, &texdef_to_face->texdef,  bFit_to_Scale);
     else
-      SetFaceTexdef(texdef_to_face->face, &texdef_to_face->texdef, NULL , bFit_to_Scale);
-    Brush_Build(texdef_to_face->brush); 
+       {
+         brushprimit_texdef_t brushprimit_texdef;
+         FakeTexCoordsToTexMat(texdef_to_face->texdef.shift, texdef_to_face->texdef.rotate, texdef_to_face->texdef.scale, brushprimit_texdef.coords);
+      SetFaceTexdef(texdef_to_face->face, &texdef_to_face->texdef, &brushprimit_texdef , bFit_to_Scale);
+       }
+    Brush_Build(texdef_to_face->brush);
     if(bFit_to_Scale)
       texdef_to_face->texdef = texdef_to_face->face->texdef;
   }
-  
+
   if ( b_SetUndoPoint )
   {
       if( (selected_brushes.next != &selected_brushes) || (g_ptrSelectedFaces.GetSize() == 1) )
       {
         if(selected_brushes.next != &selected_brushes)
-          Undo_EndBrushList(&selected_brushes); 
+          Undo_EndBrushList(&selected_brushes);
        else
          Undo_EndBrush(texdef_face_list->brush);
-         
+
         Undo_End();
        // Over-write the orig_texdef list, cementing the change.
        for(texdef_to_face = texdef_face_list; texdef_to_face; texdef_to_face = texdef_to_face->next)
+       {
          texdef_to_face->orig_texdef = texdef_to_face->texdef;
+         texdef_to_face->orig_bp_texdef = texdef_to_face->face->brushprimit_texdef;
+       }
       }
   }
-  
+
   Sys_UpdateWindows (W_ALL);
 }
 
 void SI_FaceList_FitTexture(texdef_to_face_t* si_texdef_face_list, int nHeight, int nWidth)
 {
   texdef_to_face_t* temp_texdef_face_list;
+  brushprimit_texdef_t bp;
 
   if (!si_texdef_face_list)
     return;
@@ -239,8 +266,14 @@ void SI_FaceList_FitTexture(texdef_to_face_t* si_texdef_face_list, int nHeight,
   for (temp_texdef_face_list = si_texdef_face_list; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
   {
     Face_FitTexture(temp_texdef_face_list->face, nHeight, nWidth);
-    Brush_Build(temp_texdef_face_list->brush,true,true,false,false); 
+    Brush_Build(temp_texdef_face_list->brush,true,true,false,false);
     // Write changes to our working Texdef list
+       
+       if(g_qeglobals.m_bBrushPrimitMode)
+       {
+               ConvertTexMatWithQTexture(&temp_texdef_face_list->face->brushprimit_texdef, QERApp_Shader_ForName( temp_texdef_face_list->face->texdef.GetName() )->getTexture(), &bp, NULL);
+               TexMatToFakeTexCoords(bp.coords, temp_texdef_face_list->face->texdef.shift, &temp_texdef_face_list->face->texdef.rotate, temp_texdef_face_list->face->texdef.scale);
+       }
     temp_texdef_face_list->texdef = temp_texdef_face_list->face->texdef;
   }