29 #include "../../idlib/precompiled.h"
47 #define strnicmp idStr::Icmpn
56 mins[0] = mins[1] = mins[2] = 99999;
57 maxs[0] = maxs[1] = maxs[2] = -99999;
78 for (
int i=0 ;
i<3 ;
i++)
80 mins[
i] = floor(mins[
i] + 0.5);
81 maxs[
i] = floor(maxs[
i] + 0.5);
88 return va(
"%.3ff,%.3f,%.3f",v3[0],v3[1],v3[2]);
100 FacesToCaulk.
Clear();
102 int iSystemBrushesSkipped = 0;
103 face_t *pSelectedFace;
108 next = pSelectedBrush->next;
110 if (pSelectedBrush->owner->eclass->fixedsize)
115 bool bSystemFacePresent =
false;
116 for ( pSelectedFace = pSelectedBrush->brush_faces; pSelectedFace; pSelectedFace = pSelectedFace->next)
118 if (!
strnicmp(pSelectedFace->d_texture->GetName(),
"system/",7))
120 bSystemFacePresent =
true;
124 if (bSystemFacePresent)
126 iSystemBrushesSkipped++;
130 for (
int iBrushListToScan = 0; iBrushListToScan<2; iBrushListToScan++)
135 snext = pScannedBrush->next;
137 if ( pScannedBrush == pSelectedBrush)
140 if (pScannedBrush->owner->eclass->fixedsize || pScannedBrush->pPatch || pScannedBrush->hiddenBrush)
155 for (i=0 ; i<3 ; i++)
157 if (pSelectedBrush->mins[i] > pScannedBrush->maxs[i] ||
158 pSelectedBrush->maxs[i] < pScannedBrush->mins[i])
169 for (pSelectedFace = pSelectedBrush->brush_faces; pSelectedFace; pSelectedFace = pSelectedFace->next)
171 idWinding *pSelectedWinding = pSelectedFace->face_winding;
173 if (!pSelectedWinding)
179 for (face_t *pScannedFace = pScannedBrush->brush_faces; pScannedFace; pScannedFace = pScannedFace->next)
183 if (!
strnicmp(pScannedFace->d_texture->GetName(),
"system/",7))
188 if (pScannedFace->d_texture->TestMaterialFlag(QER_TRANS))
191 idWinding *pScannedWinding = pScannedFace->face_winding;
193 if (!pScannedWinding)
212 VectorAdd(pSelectedFace->plane.Normal(),pScannedFace->plane.Normal(),v3ZeroTest);
213 if (v3ZeroTest == v3Zero)
219 float fTotalDist = 0;
220 for (
int _i=0; _i<3; _i++)
222 fTotalDist += fabs(
DotProduct(pSelectedFace->plane.Normal(),(*pSelectedWinding)[0])
224 DotProduct(pSelectedFace->plane.Normal(),(*pScannedWinding)[
i])
229 if (fTotalDist > 0.01)
237 idVec3 v3ScannedBoundsMins, v3ScannedBoundsMaxs;
238 ClearBounds (v3ScannedBoundsMins, v3ScannedBoundsMaxs);
240 for (iPoint=0; iPoint<pScannedWinding->
GetNumPoints(); iPoint++)
242 AddPointToBounds( (*pScannedWinding)[iPoint].ToVec3(), v3ScannedBoundsMins, v3ScannedBoundsMaxs);
246 FloorBounds(v3ScannedBoundsMins, v3ScannedBoundsMaxs);
252 for (iPoint=0; iPoint < pSelectedWinding->
GetNumPoints(); iPoint++)
254 for (
int iXYZ=0; iXYZ<3; iXYZ++)
256 float f = floor((*pSelectedWinding)[iPoint][iXYZ] + 0.5);
259 f >= v3ScannedBoundsMins[iXYZ]
261 f <= v3ScannedBoundsMaxs[iXYZ]
273 PairBrushFace.
pFace = pSelectedFace;
274 PairBrushFace.
pBrush= pSelectedBrush;
275 FacesToCaulk.
Append(PairBrushFace);
288 int iFacesCaulked = 0;
289 if (FacesToCaulk.
Num())
291 LPCSTR psCaulkName =
"textures/common/caulk";
300 memset (&tex, 0,
sizeof(tex));
306 tex.SetName( pCaulk->
GetName() );
310 for (
int iListEntry = 0; iListEntry < FacesToCaulk.
Num(); iListEntry++)
313 face_t *pFace = PairBrushFace.
pFace;
314 brush_t*pBrush= PairBrushFace.
pBrush;
316 pFace->d_texture = pCaulk;
327 common->
Printf(
" Unable to locate caulk texture at: \"%s\"!\n",psCaulkName);
333 if (iSystemBrushesSkipped)
335 common->
Printf(
"( %d system-faced brushes skipped )\n",iSystemBrushesSkipped);
bool FilterBrush(brush_t *pb)
void Face_FitTexture(face_t *face, float nHeight, float nWidth)
void WINAPI Sys_UpdateWindows(int nBits)
void ClearBounds(idVec3 &mins, idVec3 &maxs)
const char * GetName(void) const
#define VectorAdd(a, b, c)
void Brush_Build(brush_t *b, bool bSnap, bool bMarkMap, bool bConvert, bool updateLights)
int GetNumPoints(void) const
const idMaterial * Texture_ForName(const char *name)
virtual void Printf(const char *fmt,...) id_attribute((format(printf
GLfloat GLfloat GLfloat GLfloat v3
int Append(const type &obj)
char * va(const char *fmt,...)
void AddPointToBounds(const idVec3 &v, idVec3 &mins, idVec3 &maxs)
idList< PairBrushFace_t > FacesToCaulk