]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/selectedface.cpp
create a branch for AB sync
[xonotic/netradiant.git] / radiant / selectedface.cpp
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \r
7 GtkRadiant is free software; you can redistribute it and/or modify\r
8 it under the terms of the GNU General Public License as published by\r
9 the Free Software Foundation; either version 2 of the License, or\r
10 (at your option) any later version.\r
11 \r
12 GtkRadiant is distributed in the hope that it will be useful,\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 GNU General Public License for more details.\r
16 \r
17 You should have received a copy of the GNU General Public License\r
18 along with GtkRadiant; if not, write to the Free Software\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
20 */\r
21 \r
22 //-----------------------------------------------------------------------------\r
23 //\r
24 // DESCRIPTION:\r
25 // Quick interface hack for selected face interface\r
26 // this one really needs more work, but I'm in a hurry with TexTool\r
27 \r
28 #include "stdafx.h"\r
29 \r
30 int WINAPI QERApp_GetSelectedFaceCount()\r
31 {\r
32   return g_ptrSelectedFaces.GetSize();\r
33 }\r
34 \r
35 face_t* WINAPI QERApp_GetSelectedFace(int iface)\r
36 {\r
37   if (iface>=g_ptrSelectedFaces.GetSize())\r
38   {\r
39     Sys_FPrintf (SYS_ERR, "QERApp_GetFace: selected faces count exceeded\n");\r
40     return NULL;\r
41   }\r
42   return reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(iface));\r
43 }\r
44 \r
45 brush_t* WINAPI QERApp_GetSelectedFaceBrush(int iface)\r
46 {\r
47   if (iface>=g_ptrSelectedFaceBrushes.GetSize())\r
48   {\r
49     Sys_FPrintf (SYS_ERR, "QERApp_GetFace: selected faces count exceeded\n");\r
50     return NULL;\r
51   }\r
52   return reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(iface));\r
53 }\r
54 \r
55 // NOTE: we expect pWinding to have MAX_POINTS_ON_WINDING points ready for writing\r
56 int WINAPI QERApp_GetFaceInfo(int iface, _QERFaceData *pFaceData, winding_t *pWinding)\r
57 {\r
58   int size;\r
59 \r
60   if (iface>=g_ptrSelectedFaces.GetSize())\r
61   {\r
62     Sys_FPrintf (SYS_ERR, "QERApp_GetFaceInfo: selected faces count exceeded\n");\r
63     return 0;\r
64   }\r
65   if (!g_qeglobals.m_bBrushPrimitMode)\r
66   {\r
67     Sys_Printf("Warning: unexpected QERApp_GetFaceInfo out of brush primitive mode\n");\r
68     return 0;\r
69   }\r
70   face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(iface));\r
71   strcpy( pFaceData->m_TextureName, selFace->texdef.GetName() );\r
72   VectorCopy( selFace->planepts[0], pFaceData->m_v1 );\r
73   VectorCopy( selFace->planepts[1], pFaceData->m_v2 );\r
74   VectorCopy( selFace->planepts[2], pFaceData->m_v3 );\r
75   pFaceData->m_bBPrimit = true;\r
76   memcpy( &pFaceData->brushprimit_texdef, &selFace->brushprimit_texdef, sizeof(brushprimit_texdef_t) );\r
77   size = (int)((winding_t *)0)->points[selFace->face_winding->numpoints];\r
78   memcpy( pWinding, selFace->face_winding, size );\r
79   return 1;\r
80 }\r
81 \r
82 int WINAPI QERApp_SetFaceInfo(int iface, _QERFaceData *pFaceData)\r
83 {\r
84   if (iface>=g_ptrSelectedFaces.GetSize())\r
85   {\r
86     Sys_FPrintf (SYS_ERR, "QERApp_SetFaceInfo: selected faces count exceeded\n");\r
87     return 0;\r
88   }\r
89   if (!g_qeglobals.m_bBrushPrimitMode)\r
90   {\r
91     Sys_Printf("Warning: unexpected QERApp_SetFaceInfo out of brush primitive mode\n");\r
92     return 0;\r
93   }\r
94   face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(iface));\r
95   brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(iface));\r
96   //strcpy( selected_face->texdef.name, pFaceData->m_TextureName );\r
97   selFace->texdef.SetName(pFaceData->m_TextureName);\r
98   VectorCopy( pFaceData->m_v1, selFace->planepts[0] );\r
99   VectorCopy( pFaceData->m_v2, selFace->planepts[1] );\r
100   VectorCopy( pFaceData->m_v3, selFace->planepts[2] );\r
101   memcpy( &selFace->brushprimit_texdef, &pFaceData->brushprimit_texdef, sizeof(brushprimit_texdef_t) );\r
102   Brush_Build( selBrush );\r
103   Sys_UpdateWindows(W_ALL);\r
104   return 1;\r
105 }\r
106 \r
107 int WINAPI QERApp_ISelectedFace_GetTextureNumber(int iface)\r
108 {\r
109   if (iface>=g_ptrSelectedFaces.GetSize())\r
110   {\r
111     Sys_FPrintf (SYS_ERR, "QERApp_ISelectedFace_GetTextureNumber: selected faces count exceeded\n");\r
112     return 0;\r
113   }\r
114   face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(iface));\r
115   return selFace->d_texture->texture_number;\r
116 }\r
117 \r
118 void WINAPI QERApp_GetTextureSize (int iface, int Size[2])\r
119 {\r
120   if (iface>=g_ptrSelectedFaces.GetSize())\r
121   {\r
122     Sys_FPrintf (SYS_ERR, "QERApp_GetTextureSize: selected faces count exceeded\n");\r
123     return;\r
124   }\r
125   face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(iface));\r
126   Size[0] = selFace->d_texture->width;\r
127   Size[1] = selFace->d_texture->height;\r
128 }\r