#include "stdafx.h"
#include <assert.h>
#include "qe3.h"
#include "winding.h"
Include dependency graph for Brush.cpp:

Go to the source code of this file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 2987 of file Brush.cpp. References QEGlobals_t::d_move_points, QEGlobals_t::d_num_move_points, g_qeglobals, and i. Referenced by Brush_SelectFaceForDragging(), SelectFaceEdge(), and SelectVertex(). 02988 {
02989 int i;
02990
02991 for (i=0 ; i<g_qeglobals.d_num_move_points ; i++)
02992 if (g_qeglobals.d_move_points[i] == f)
02993 return 0;
02994 g_qeglobals.d_move_points[g_qeglobals.d_num_move_points++] = f;
02995 return 1;
02996 }
|
|
||||||||||||
Here is the call graph for this function:

|
|
Definition at line 46 of file Brush.cpp. References b, brush_t, and qmalloc(). Referenced by Brush_Clone(), Brush_Create(), Brush_CreatePyramid(), Brush_FullClone(), Brush_MakeSided(), Brush_MakeSidedCone(), Brush_MakeSidedSphere(), Brush_Merge(), Brush_MergeList(), Brush_Parse(), and CPlugInManager::CreateBrushHandle().
|
Here is the call graph for this function:

|
|
Definition at line 751 of file Brush.cpp. References b, brush_s::brush_faces, brush_t, plane_t::dist, f, face_t, face_s::face_winding, face_s::next, plane_t::normal, face_s::plane, value, Winding_Free(), Winding_IsTiny(), and Winding_SplitEpsilon(). Referenced by Brush_MakeConvexBrushes(). 00752 {
00753 face_t *face, *f, *bestface;
00754 winding_t *front, *back;
00755 int splits, tinywindings, value, bestvalue;
00756
00757 bestvalue = 999999;
00758 bestface = NULL;
00759 for (face = b->brush_faces; face; face = face->next)
00760 {
00761 splits = 0;
00762 tinywindings = 0;
00763 for (f = b->brush_faces; f; f = f->next)
00764 {
00765 if (f == face) continue;
00766 //
00767 Winding_SplitEpsilon(f->face_winding, face->plane.normal, face->plane.dist, 0.1, &front, &back);
00768
00769 if (!front)
00770 {
00771 Winding_Free(back);
00772 }
00773 else if (!back)
00774 {
00775 Winding_Free(front);
00776 }
00777 else
00778 {
00779 splits++;
00780 if (Winding_IsTiny(front)) tinywindings++;
00781 if (Winding_IsTiny(back)) tinywindings++;
00782 }
00783 }
00784 if (splits)
00785 {
00786 value = splits + 50 * tinywindings;
00787 if (value < bestvalue)
00788 {
00789 bestvalue = value;
00790 bestface = face;
00791 }
00792 }
00793 }
00794 return bestface;
00795 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 3150 of file Brush.cpp. References b, QEGlobals_t::bNeedConvert, brush_s::brush_faces, Brush_MakeFacePlanes(), Brush_MakeFaceWinding(), Brush_SnapPlanepts(), brush_t, face_s::d_texture, EmitBrushPrimitTextureCoordinates(), EmitTextureCoordinates(), Face_SetColor(), face_t, face_s::face_winding, FaceToBrushPrimitFace(), free(), g_qeglobals, i, j, QEGlobals_t::m_bBrushPrimitMode, brush_s::maxs, brush_s::mins, texdef_t::name, face_s::next, winding_t::numpoints, winding_t::points, face_s::texdef, Texture_ForName(), v, vec_t, and w. Referenced by Brush_Build(), Brush_Merge(), and Brush_MergeList(). 03151 {
03152 winding_t *w;
03153 face_t *face;
03154 vec_t v;
03155
03156 if (bSnap)
03157 Brush_SnapPlanepts( b );
03158
03159 // clear the mins/maxs bounds
03160 b->mins[0] = b->mins[1] = b->mins[2] = 99999;
03161 b->maxs[0] = b->maxs[1] = b->maxs[2] = -99999;
03162
03163 Brush_MakeFacePlanes (b);
03164
03165 face = b->brush_faces;
03166
03167 float fCurveColor = 1.0;
03168
03169 for ( ; face ; face=face->next)
03170 {
03171 int i, j;
03172 free(face->face_winding);
03173 w = face->face_winding = Brush_MakeFaceWinding (b, face);
03174 face->d_texture = Texture_ForName( face->texdef.name );
03175
03176 if (!w)
03177 continue;
03178
03179 for (i=0 ; i<w->numpoints ; i++)
03180 {
03181 // add to bounding box
03182 for (j=0 ; j<3 ; j++)
03183 {
03184 v = w->points[i][j];
03185 if (v > b->maxs[j])
03186 b->maxs[j] = v;
03187 if (v < b->mins[j])
03188 b->mins[j] = v;
03189 }
03190 }
03191 // setup s and t vectors, and set color
03192 //if (!g_PrefsDlg.m_bGLLighting)
03193 //{
03194 Face_SetColor (b, face, fCurveColor);
03195 //}
03196
03197 fCurveColor -= .10;
03198 if (fCurveColor <= 0)
03199 fCurveColor = 1.0;
03200
03201 // computing ST coordinates for the windings
03202 if (g_qeglobals.m_bBrushPrimitMode)
03203 {
03204 if (g_qeglobals.bNeedConvert)
03205 {
03206 // we have parsed old brushes format and need conversion
03207 // convert old brush texture representation to new format
03208 FaceToBrushPrimitFace(face);
03209 #ifdef _DEBUG
03210 // use old texture coordinates code to check against
03211 for (i=0 ; i<w->numpoints ; i++)
03212 EmitTextureCoordinates( w->points[i], face->d_texture, face);
03213 #endif
03214 }
03215 // use new texture representation to compute texture coordinates
03216 // in debug mode we will check against old code and warn if there are differences
03217 EmitBrushPrimitTextureCoordinates(face,w);
03218 }
03219 else
03220 {
03221 for (i=0 ; i<w->numpoints ; i++)
03222 EmitTextureCoordinates( w->points[i], face->d_texture, face);
03223 }
03224 }
03225 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 3285 of file Brush.cpp. References abs(), b, Brush_Move(), brush_t, j, brush_s::maxs, brush_s::mins, vec3_t, and VectorSubtract. 03286 {
03287 vec3_t vMid;
03288 // get center of the brush
03289 for (int j = 0; j < 3; j++)
03290 {
03291 vMid[j] = b->mins[j] + abs((b->maxs[j] - b->mins[j]) * 0.5);
03292 }
03293 // calc distance between centers
03294 VectorSubtract(vNewCenter, vMid, vMid);
03295 Brush_Move(b, vMid, true);
03296
03297 }
|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
|
Definition at line 837 of file Brush.cpp. References b, brush_s::brush_faces, brush_t, plane_t::dist, face_t, face_s::face_winding, face_s::next, plane_t::normal, face_s::plane, and Winding_PlanesConcave(). 00838 {
00839 face_t *face1, *face2;
00840
00841 for (face1 = b->brush_faces; face1; face1 = face1->next)
00842 {
00843 if (!face1->face_winding) continue;
00844 for (face2 = b->brush_faces; face2; face2 = face2->next)
00845 {
00846 if (face1 == face2) continue;
00847 if (!face2->face_winding) continue;
00848 if (Winding_PlanesConcave(face1->face_winding, face2->face_winding,
00849 face1->plane.normal, face2->plane.normal,
00850 face1->plane.dist, face2->plane.dist))
00851 {
00852 return false;
00853 }
00854 }
00855 }
00856 return true;
00857 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 2210 of file Brush.cpp. References b, Brush_Alloc(), brush_s::brush_faces, brush_t, texdef_t::contents, Error(), f, Face_Alloc(), face_t, texdef_t::flags, g_qeglobals, i, j, QEGlobals_t::m_bBrushPrimitMode, face_s::next, face_s::planepts, texdef_t::rotate, texdef_t::scale, texdef_t::shift, Sys_Printf(), face_s::texdef, vec3_t, and VectorCopy. Referenced by AddBrushForPatch(), AddBrushForTerrain(), AddProp(), AddRegionBrushes(), Brush_CreatePyramid(), Brush_Resize(), CPlugInManager::CommitEntityHandleToMap(), CreateEntityBrush(), CreateEntityFromName(), CreateSmartBrush(), Entity_Create(), Entity_Parse(), CXYWnd::NewBrushDrag(), CMainFrame::OnCreate(), and QERApp_CreateBrush(). 02211 {
02212 int i, j;
02213 vec3_t pts[4][2];
02214 face_t *f;
02215 brush_t *b;
02216
02217 // brush primitive mode : convert texdef to brushprimit_texdef ?
02218 // most of the time texdef is empty
02219 if (g_qeglobals.m_bBrushPrimitMode)
02220 {
02221 // check texdef is empty .. if there are cases it's not we need to write some conversion code
02222 if (texdef->shift[0]!=0 || texdef->shift[1]!=0 || texdef->scale[0]!=0 || texdef->scale[1]!=0 || texdef->rotate!=0)
02223 Sys_Printf("Warning : non-zero texdef detected in Brush_Create .. need brush primitive conversion\n");
02224 }
02225
02226 for (i=0 ; i<3 ; i++)
02227 {
02228 if (maxs[i] < mins[i])
02229 Error ("Brush_InitSolid: backwards");
02230 }
02231
02232 b = Brush_Alloc();
02233
02234 pts[0][0][0] = mins[0];
02235 pts[0][0][1] = mins[1];
02236
02237 pts[1][0][0] = mins[0];
02238 pts[1][0][1] = maxs[1];
02239
02240 pts[2][0][0] = maxs[0];
02241 pts[2][0][1] = maxs[1];
02242
02243 pts[3][0][0] = maxs[0];
02244 pts[3][0][1] = mins[1];
02245
02246 for (i=0 ; i<4 ; i++)
02247 {
02248 pts[i][0][2] = mins[2];
02249 pts[i][1][0] = pts[i][0][0];
02250 pts[i][1][1] = pts[i][0][1];
02251 pts[i][1][2] = maxs[2];
02252 }
02253
02254 for (i=0 ; i<4 ; i++)
02255 {
02256 f = Face_Alloc();
02257 f->texdef = *texdef;
02258 f->texdef.flags &= ~SURF_KEEP;
02259 f->texdef.contents &= ~CONTENTS_KEEP;
02260 f->next = b->brush_faces;
02261 b->brush_faces = f;
02262 j = (i+1)%4;
02263
02264 VectorCopy (pts[j][1], f->planepts[0]);
02265 VectorCopy (pts[i][1], f->planepts[1]);
02266 VectorCopy (pts[i][0], f->planepts[2]);
02267 }
02268
02269 f = Face_Alloc();
02270 f->texdef = *texdef;
02271 f->texdef.flags &= ~SURF_KEEP;
02272 f->texdef.contents &= ~CONTENTS_KEEP;
02273 f->next = b->brush_faces;
02274 b->brush_faces = f;
02275
02276 VectorCopy (pts[0][1], f->planepts[0]);
02277 VectorCopy (pts[1][1], f->planepts[1]);
02278 VectorCopy (pts[2][1], f->planepts[2]);
02279
02280 f = Face_Alloc();
02281 f->texdef = *texdef;
02282 f->texdef.flags &= ~SURF_KEEP;
02283 f->texdef.contents &= ~CONTENTS_KEEP;
02284 f->next = b->brush_faces;
02285 b->brush_faces = f;
02286
02287 VectorCopy (pts[2][0], f->planepts[0]);
02288 VectorCopy (pts[1][0], f->planepts[1]);
02289 VectorCopy (pts[0][0], f->planepts[2]);
02290
02291 return b;
02292 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 2302 of file Brush.cpp. References b, bottom, Brush_Alloc(), Brush_Create(), brush_s::brush_faces, brush_t, texdef_t::contents, Error(), f, Face_Alloc(), face_t, texdef_t::flags, i, j, face_s::next, face_s::planepts, Q_rint(), face_s::texdef, top, vec3_t, and VectorCopy. 02303 {
02304 //++timo handle new brush primitive ? return here ??
02305 return Brush_Create(mins, maxs, texdef);
02306
02307 for (int i=0 ; i<3 ; i++)
02308 if (maxs[i] < mins[i])
02309 Error ("Brush_InitSolid: backwards");
02310
02311 brush_t* b = Brush_Alloc();
02312
02313 vec3_t corners[4];
02314
02315 float fMid = Q_rint(mins[2] + (Q_rint((maxs[2] - mins[2]) / 2)));
02316
02317 corners[0][0] = mins[0];
02318 corners[0][1] = mins[1];
02319 corners[0][2] = fMid;
02320
02321 corners[1][0] = mins[0];
02322 corners[1][1] = maxs[1];
02323 corners[1][2] = fMid;
02324
02325 corners[2][0] = maxs[0];
02326 corners[2][1] = maxs[1];
02327 corners[2][2] = fMid;
02328
02329 corners[3][0] = maxs[0];
02330 corners[3][1] = mins[1];
02331 corners[3][2] = fMid;
02332
02333 vec3_t top, bottom;
02334
02335 top[0] = Q_rint(mins[0] + ((maxs[0] - mins[0]) / 2));
02336 top[1] = Q_rint(mins[1] + ((maxs[1] - mins[1]) / 2));
02337 top[2] = Q_rint(maxs[2]);
02338
02339 VectorCopy(top, bottom);
02340 bottom[2] = mins[2];
02341
02342 // sides
02343 for (i = 0; i < 4; i++)
02344 {
02345 face_t* f = Face_Alloc();
02346 f->texdef = *texdef;
02347 f->texdef.flags &= ~SURF_KEEP;
02348 f->texdef.contents &= ~CONTENTS_KEEP;
02349 f->next = b->brush_faces;
02350 b->brush_faces = f;
02351 int j = (i+1)%4;
02352
02353 VectorCopy (top, f->planepts[0]);
02354 VectorCopy (corners[i], f->planepts[1]);
02355 VectorCopy(corners[j], f->planepts[2]);
02356
02357 f = Face_Alloc();
02358 f->texdef = *texdef;
02359 f->texdef.flags &= ~SURF_KEEP;
02360 f->texdef.contents &= ~CONTENTS_KEEP;
02361 f->next = b->brush_faces;
02362 b->brush_faces = f;
02363
02364 VectorCopy (bottom, f->planepts[2]);
02365 VectorCopy (corners[i], f->planepts[1]);
02366 VectorCopy(corners[j], f->planepts[0]);
02367 }
02368
02369 return b;
02370 }
|
Here is the call graph for this function:

|