diff --git a/neo/engine/tools/radiant/CamWnd.cpp b/neo/engine/tools/radiant/CamWnd.cpp index 9e4058d7..b5b25e8d 100644 --- a/neo/engine/tools/radiant/CamWnd.cpp +++ b/neo/engine/tools/radiant/CamWnd.cpp @@ -48,6 +48,7 @@ static char THIS_FILE[] = __FILE__; extern void DrawPathLines(); extern qertrace_t Test_Ray(const idVec3& origin, const idVec3& dir, int flags); +extern brush_t *Brush_CreateFaceExtrusion(brush_t *sourceBrush, face_t *sourceFace, float distance); extern void Select_ShiftTexture(float x, float y); extern void Select_ScaleTexture(float x, float y); extern void Select_RotateTexture(float amt, bool absolute); @@ -1584,6 +1585,279 @@ static bool CamWnd_MenuFilterBrush(CCamWnd* cam, brush_t* brush) { } +/* +======================== +Ctrl+Shift camera face extrusion + +Ctrl+Shift+LMB on a brush face starts a camera-view extrusion preview. The +preview is only drawn while dragging. On mouse release a real brush is created +from the selected face and linked to the same entity as the source brush. +======================== +*/ +#define CAMWND_FACE_EXTRUDE_EPSILON 0.01f + +struct camFaceExtrudeState_t { + bool active; + bool moved; + CCamWnd* cam; + brush_t* sourceBrush; + face_t* sourceFace; + idWinding* sourceWinding; + idVec3 normal; + CPoint startPoint; + float distance; +}; + +static camFaceExtrudeState_t s_faceExtrudeState; + +static bool CamWnd_FaceExtrudeIsActive(CCamWnd* cam) { + return s_faceExtrudeState.active && s_faceExtrudeState.cam == cam; +} + +static void CamWnd_FaceExtrudeReset() { + if (s_faceExtrudeState.sourceWinding) { + delete s_faceExtrudeState.sourceWinding; + } + memset(&s_faceExtrudeState, 0, sizeof(s_faceExtrudeState)); +} + +static float CamWnd_FaceExtrudeGridSize() { + float gridSize = (float)g_qeglobals.d_gridsize; + if (gridSize <= 0.0f) { + gridSize = 1.0f; + } + return gridSize; +} + +static float CamWnd_FaceExtrudeSnapDistance(float distance) { + const float gridSize = CamWnd_FaceExtrudeGridSize(); + if (idMath::Fabs(distance) < gridSize * 0.5f) { + return 0.0f; + } + return floor(distance / gridSize + (distance >= 0.0f ? 0.5f : -0.5f)) * gridSize; +} + +static void CamWnd_FaceExtrudeBuildRay(CCamWnd* cam, const CPoint& point, idVec3& dir) { + CRect rect; + cam->GetClientRect(rect); + + camera_t& camera = cam->Camera(); + const int x = point.x; + const int y = rect.bottom - 1 - point.y; + + float u = 0.0f; + float r = 0.0f; + if (camera.width > 0) { + u = (float)(y - camera.height / 2) / (camera.width / 2); + r = (float)(x - camera.width / 2) / (camera.width / 2); + } + + for (int i = 0; i < 3; i++) { + dir[i] = camera.vpn[i] + camera.vright[i] * r + camera.vup[i] * u; + } + dir.Normalize(); +} + +static bool CamWnd_FaceExtrudeBrushAllowed(CCamWnd* cam, brush_t* brush) { + if (brush == NULL || brush->owner == NULL || brush->owner->eclass == NULL) { + return false; + } + if (brush->pPatch || brush->modelHandle > 0 || brush->entityModel) { + return false; + } + if (brush->owner->eclass->fixedsize) { + return false; + } + if (FilterBrush(brush) || CamWnd_MenuFilterBrush(cam, brush) || Map_IsBrushFiltered(brush)) { + return false; + } + return true; +} + +static bool CamWnd_FaceExtrudeBegin(CCamWnd* cam, const CPoint& point) { + if (cam == NULL || !cam->GetSafeHwnd()) { + return false; + } + + idVec3 dir; + CamWnd_FaceExtrudeBuildRay(cam, point, dir); + + qertrace_t trace = Test_Ray(cam->Camera().origin, dir, 0); + if (trace.brush == NULL || trace.face == NULL || trace.face->face_winding == NULL) { + return false; + } + if (trace.face->face_winding->GetNumPoints() < 3) { + return false; + } + if (!CamWnd_FaceExtrudeBrushAllowed(cam, trace.brush)) { + return false; + } + + idVec3 normal = trace.face->plane.Normal(); + if (normal.LengthSqr() < 0.0001f) { + return false; + } + normal.Normalize(); + + CamWnd_FaceExtrudeReset(); + s_faceExtrudeState.active = true; + s_faceExtrudeState.moved = false; + s_faceExtrudeState.cam = cam; + s_faceExtrudeState.sourceBrush = trace.brush; + s_faceExtrudeState.sourceFace = trace.face; + s_faceExtrudeState.sourceWinding = trace.face->face_winding->Copy(); + s_faceExtrudeState.normal = normal; + s_faceExtrudeState.startPoint = point; + s_faceExtrudeState.distance = 0.0f; + + cam->SetFocus(); + cam->SetCapture(); + Sys_Status("Drag to extrude face; release mouse to create new brush.\n"); + Sys_UpdateWindows(W_CAMERA); + return true; +} + +static float CamWnd_FaceExtrudeMouseDistance(CCamWnd* cam, const CPoint& point) { + const int dx = point.x - s_faceExtrudeState.startPoint.x; + const int dy = point.y - s_faceExtrudeState.startPoint.y; + + camera_t& camera = cam->Camera(); + idVec3 screenMove = camera.vright * (float)dx - camera.vup * (float)dy; + float distance = DotProduct(screenMove, s_faceExtrudeState.normal); + + // When the selected face is nearly screen-facing, projection onto the normal + // is too small to be useful. In that case use vertical mouse motion, with + // the sign chosen so dragging up extrudes toward the camera-facing normal. + float verticalDistance = (float)-dy; + if (DotProduct(camera.vpn, s_faceExtrudeState.normal) > 0.0f) { + verticalDistance = -verticalDistance; + } + if (idMath::Fabs(distance) < idMath::Fabs(verticalDistance) * 0.25f) { + distance = verticalDistance; + } + + return CamWnd_FaceExtrudeSnapDistance(distance); +} + +static bool CamWnd_FaceExtrudeMouseMove(CCamWnd* cam, const CPoint& point) { + if (!CamWnd_FaceExtrudeIsActive(cam)) { + return false; + } + + s_faceExtrudeState.distance = CamWnd_FaceExtrudeMouseDistance(cam, point); + s_faceExtrudeState.moved = true; + Sys_UpdateWindows(W_CAMERA | W_XY | W_Z); + return true; +} + +static void CamWnd_FaceExtrudeEnd(CCamWnd* cam, bool commit) { + if (!CamWnd_FaceExtrudeIsActive(cam)) { + return; + } + + brush_t* sourceBrush = s_faceExtrudeState.sourceBrush; + face_t* sourceFace = s_faceExtrudeState.sourceFace; + float distance = s_faceExtrudeState.distance; + + if (::GetCapture() == cam->GetSafeHwnd()) { + ::ReleaseCapture(); + } + + if (commit && sourceBrush && sourceFace && idMath::Fabs(distance) >= CAMWND_FACE_EXTRUDE_EPSILON) { + brush_t* newBrush = Brush_CreateFaceExtrusion(sourceBrush, sourceFace, distance); + if (newBrush != NULL) { + Brush_AddToList(newBrush, &selected_brushes); + Entity_LinkBrush(sourceBrush->owner ? sourceBrush->owner : world_entity, newBrush); + Brush_Build(newBrush, true, true); + Brush_RemoveEmptyFaces(newBrush); + + if (newBrush->brush_faces == NULL) { + Brush_Free(newBrush); + Sys_Status("Face extrusion produced an empty brush.\n"); + } + else { + Sys_Status("Face extrusion created a new brush.\n"); + } + } + } + + CamWnd_FaceExtrudeReset(); + Sys_UpdateWindows(W_ALL); +} + +static void CamWnd_FaceExtrudeDrawPreview(CCamWnd* cam) { + if (!CamWnd_FaceExtrudeIsActive(cam) || s_faceExtrudeState.sourceWinding == NULL) { + return; + } + if (idMath::Fabs(s_faceExtrudeState.distance) < CAMWND_FACE_EXTRUDE_EPSILON) { + return; + } + + idWinding* w = s_faceExtrudeState.sourceWinding; + const int numPoints = w->GetNumPoints(); + if (numPoints < 3) { + return; + } + + idVec3 offset = s_faceExtrudeState.normal * s_faceExtrudeState.distance; + + glPushAttrib(GL_CURRENT_BIT); + globalImages->BindNull(); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glDisable(GL_BLEND); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glLineWidth(2.0f); + glColor3f(0.1f, 0.9f, 1.0f); + + glBegin(GL_LINES); + for (int i = 0; i < numPoints; i++) { + const int j = (i + 1) % numPoints; + idVec3 a = (*w)[i].ToVec3(); + idVec3 b = (*w)[j].ToVec3(); + idVec3 a2 = a + offset; + idVec3 b2 = b + offset; + + glVertex3fv(a.ToFloatPtr()); + glVertex3fv(b.ToFloatPtr()); + glVertex3fv(a2.ToFloatPtr()); + glVertex3fv(b2.ToFloatPtr()); + glVertex3fv(a.ToFloatPtr()); + glVertex3fv(a2.ToFloatPtr()); + } + glEnd(); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glColor4f(0.1f, 0.9f, 1.0f, 0.18f); + + glBegin(GL_QUADS); + for (int i = 0; i < numPoints; i++) { + idVec3 p = (*w)[i].ToVec3() + offset; + glVertex3fv(p.ToFloatPtr()); + } + glEnd(); + + glBegin(GL_QUADS); + for (int i = 0; i < numPoints; i++) { + const int j = (i + 1) % numPoints; + idVec3 a = (*w)[i].ToVec3(); + idVec3 b = (*w)[j].ToVec3(); + idVec3 a2 = a + offset; + idVec3 b2 = b + offset; + + glVertex3fv(a.ToFloatPtr()); + glVertex3fv(b.ToFloatPtr()); + glVertex3fv(b2.ToFloatPtr()); + glVertex3fv(a2.ToFloatPtr()); + } + glEnd(); + + glPopAttrib(); +} + + static COLORREF CamWnd_LerpColor(COLORREF a, COLORREF b, float t) { const int ar = GetRValue(a); const int ag = GetGValue(a); @@ -1796,6 +2070,7 @@ INT_PTR WINAPI CamWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CWnd* wnd = CWnd::FromHandlePermanent(hWnd); CCamWnd* cam = DYNAMIC_DOWNCAST(CCamWnd, wnd); if (cam) { + CamWnd_FaceExtrudeEnd(cam, false); CameraNav_Stop(cam); } SendMessage(hWnd, WM_NCACTIVATE, FALSE, 0); @@ -1866,6 +2141,10 @@ BOOL CCamWnd::PreCreateWindow(CREATESTRUCT& cs) { ======================================================================================================================= */ void CCamWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { + if (CamWnd_FaceExtrudeIsActive(this) && nChar == VK_ESCAPE) { + CamWnd_FaceExtrudeEnd(this, false); + return; + } if (CameraNav_HandleKeyDown(this, nChar)) { return; } @@ -1911,6 +2190,7 @@ void CCamWnd::SetXYFriend(CXYWnd* pWnd) { ======================================================================================================================= */ void CCamWnd::OnDestroy() { + CamWnd_FaceExtrudeEnd(this, false); CamWnd_DestroyMenuBar(this); CWnd::OnDestroy(); } @@ -1933,6 +2213,11 @@ void CCamWnd::OnMouseMove(UINT nFlags, CPoint point) { CRect r; GetClientRect(r); + if (CamWnd_FaceExtrudeMouseMove(this, point)) { + m_ptLastCursor = point; + return; + } + if (CameraNav_MouseMove(this)) { m_ptLastCursor = point; return; @@ -1977,6 +2262,9 @@ void CCamWnd::OnLButtonDown(UINT nFlags, CPoint point) { Sys_UpdateWindows(W_ALL); return; } + if ((nFlags & MK_CONTROL) && (nFlags & MK_SHIFT) && CamWnd_FaceExtrudeBegin(this, point)) { + return; + } OriginalMouseDown(nFlags, point); } @@ -1985,6 +2273,11 @@ void CCamWnd::OnLButtonDown(UINT nFlags, CPoint point) { ======================================================================================================================= */ void CCamWnd::OnLButtonUp(UINT nFlags, CPoint point) { + if (CamWnd_FaceExtrudeIsActive(this)) { + CamWnd_FaceExtrudeMouseMove(this, point); + CamWnd_FaceExtrudeEnd(this, true); + return; + } OriginalMouseUp(nFlags, point); } @@ -2827,6 +3120,9 @@ void CCamWnd::Cam_Draw() { Face_Draw(face); } } + + CamWnd_FaceExtrudeDrawPreview(this); + // edge / vertex flags if (g_qeglobals.d_select_mode == sel_vertex) { glPointSize(4); diff --git a/neo/engine/tools/radiant/EditorBrush.cpp b/neo/engine/tools/radiant/EditorBrush.cpp index 326d8dfc..bd4d0c2b 100644 --- a/neo/engine/tools/radiant/EditorBrush.cpp +++ b/neo/engine/tools/radiant/EditorBrush.cpp @@ -2,9 +2,9 @@ =========================================================================== IceTech GPL Source Code -Copyright (C) 2026 Justin Marshall +Copyright (C) 2026 Justin Marshall -This file is part of the IceTech GPL Source Code (?IceTech Source Code?). +This file is part of the IceTech GPL Source Code (?IceTech Source Code?). IceTech Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,8 +35,8 @@ If you have questions concerning this license or the applicable additional terms #include "../../renderer/tr_local.h" #include "../../models/model_local.h" // for idRenderModelMD5 -void Brush_UpdateLightPoints(brush_t *b, const idVec3 &offset); -void Brush_DrawCurve( brush_t *b, bool bSelected, bool cam ); +void Brush_UpdateLightPoints(brush_t* b, const idVec3& offset); +void Brush_DrawCurve(brush_t* b, bool bSelected, bool cam); // globals int g_nBrushId = 0; @@ -52,28 +52,28 @@ const int POINTS_PER_KNOT = 50; DrawRenderModel ================ */ -void DrawRenderModel( idRenderModel *model, idVec3 &origin, idMat3 &axis, bool cameraView ) { - for ( int i = 0; i < model->NumSurfaces(); i++ ) { - const modelSurface_t *surf = model->Surface( i ); - const idMaterial *material = surf->shader; +void DrawRenderModel(idRenderModel* model, idVec3& origin, idMat3& axis, bool cameraView) { + for (int i = 0; i < model->NumSurfaces(); i++) { + const modelSurface_t* surf = model->Surface(i); + const idMaterial* material = surf->shader; int nDrawMode = g_pParentWnd->GetCamera()->Camera().draw_mode; - if ( cameraView && (nDrawMode == cd_texture || nDrawMode == cd_light) ) { + if (cameraView && (nDrawMode == cd_texture || nDrawMode == cd_light)) { material->GetEditorImage()->Bind(); } - glBegin( GL_TRIANGLES ); + glBegin(GL_TRIANGLES); - const srfTriangles_t *tri = surf->geometry; - for ( int j = 0; j < tri->numIndexes; j += 3 ) { - for ( int k = 0; k < 3; k++ ) { + const srfTriangles_t* tri = surf->geometry; + for (int j = 0; j < tri->numIndexes; j += 3) { + for (int k = 0; k < 3; k++) { int index = tri->indexes[j + k]; idVec3 v; v = tri->verts[index].xyz * axis + origin; - glTexCoord2f( tri->verts[index].st.x, tri->verts[index].st.y ); - glVertex3fv( v.ToFloatPtr() ); + glTexCoord2f(tri->verts[index].st.x, tri->verts[index].st.y); + glVertex3fv(v.ToFloatPtr()); } } @@ -86,7 +86,7 @@ void DrawRenderModel( idRenderModel *model, idVec3 &origin, idMat3 &axis, bool c SnapVectorToGrid ================ */ -void SnapVectorToGrid(idVec3 &v) { +void SnapVectorToGrid(idVec3& v) { v.x = floor(v.x / g_qeglobals.d_gridsize + 0.5f) * g_qeglobals.d_gridsize; v.y = floor(v.y / g_qeglobals.d_gridsize + 0.5f) * g_qeglobals.d_gridsize; v.z = floor(v.z / g_qeglobals.d_gridsize + 0.5f) * g_qeglobals.d_gridsize; @@ -97,7 +97,7 @@ void SnapVectorToGrid(idVec3 &v) { Brush_Name ================ */ -const char *Brush_Name( brush_t *b ) { +const char* Brush_Name(brush_t* b) { static char cBuff[1024]; b->numberId = g_nBrushId++; @@ -114,8 +114,8 @@ const char *Brush_Name( brush_t *b ) { Brush_Alloc ================ */ -brush_t *Brush_Alloc( void ) { - brush_t *b = new brush_t; +brush_t* Brush_Alloc(void) { + brush_t* b = new brush_t; b->prev = b->next = NULL; b->oprev = b->onext = NULL; b->owner = NULL; @@ -189,7 +189,7 @@ idVec3 baseaxis[18] = { idVec3(0, 0, -1) // north wall }; -void TextureAxisFromPlane( const idPlane &pln, idVec3 &xv, idVec3 &yv) { +void TextureAxisFromPlane(const idPlane& pln, idVec3& xv, idVec3& yv) { int bestaxis; float dot, best; int i; @@ -224,7 +224,7 @@ float ShadeForNormal(idVec3 normal) { // axial plane for (i = 0; i < 3; i++) { - if ( idMath::Fabs(normal[i]) > 0.9f ) { + if (idMath::Fabs(normal[i]) > 0.9f) { f = lightaxis[i]; return f; } @@ -232,7 +232,7 @@ float ShadeForNormal(idVec3 normal) { // between two axial planes for (i = 0; i < 3; i++) { - if ( idMath::Fabs(normal[i]) < 0.1f ) { + if (idMath::Fabs(normal[i]) < 0.1f) { f = (lightaxis[(i + 1) % 3] + lightaxis[(i + 2) % 3]) / 2; return f; } @@ -248,10 +248,10 @@ float ShadeForNormal(idVec3 normal) { Face_Alloc ================ */ -face_t *Face_Alloc(void) { +face_t* Face_Alloc(void) { brushprimit_texdef_t bp; - face_t *f = (face_t *) Mem_ClearedAlloc(sizeof(*f)); + face_t* f = (face_t*)Mem_ClearedAlloc(sizeof(*f)); bp.coords[0][0] = 0.0f; bp.coords[1][1] = 0.0f; @@ -265,7 +265,7 @@ face_t *Face_Alloc(void) { Face_Free ================ */ -void Face_Free(face_t *f) { +void Face_Free(face_t* f) { assert(f != 0); if (f->face_winding) { @@ -282,8 +282,8 @@ void Face_Free(face_t *f) { Face_Clone ================ */ -face_t *Face_Clone(face_t *f) { - face_t *n; +face_t* Face_Clone(face_t* f) { + face_t* n; n = Face_Alloc(); n->texdef = f->texdef; @@ -306,8 +306,8 @@ Face_FullClone Makes an exact copy of the face. ================ */ -face_t *Face_FullClone(face_t *f) { - face_t *n; +face_t* Face_FullClone(face_t* f) { + face_t* n; n = Face_Alloc(); n->texdef = f->texdef; @@ -332,7 +332,7 @@ face_t *Face_FullClone(face_t *f) { Clamp ================ */ -void Clamp(float &f, int nClamp) { +void Clamp(float& f, int nClamp) { float fFrac = f - static_cast(f); f = static_cast(f) % nClamp; f += fFrac; @@ -343,7 +343,7 @@ void Clamp(float &f, int nClamp) { Face_MoveTexture ================ */ -void Face_MoveTexture(face_t *f, idVec3 delta) { +void Face_MoveTexture(face_t* f, idVec3 delta) { idVec3 vX, vY; /* @@ -354,13 +354,13 @@ void Face_MoveTexture(face_t *f, idVec3 delta) { Face_MoveTexture_BrushPrimit(f, delta); } else { - TextureAxisFromPlane( f->plane, vX, vY ); + TextureAxisFromPlane(f->plane, vX, vY); idVec3 vDP, vShift; vDP[0] = DotProduct(delta, vX); vDP[1] = DotProduct(delta, vY); - double fAngle = DEG2RAD( f->texdef.rotate ); + double fAngle = DEG2RAD(f->texdef.rotate); double c = cos(fAngle); double s = sin(fAngle); @@ -389,19 +389,19 @@ void Face_MoveTexture(face_t *f, idVec3 delta) { Face_SetColor ================ */ -void Face_SetColor(brush_t *b, face_t *f, float fCurveColor) { +void Face_SetColor(brush_t* b, face_t* f, float fCurveColor) { float shade; - const idMaterial *q; + const idMaterial* q; q = f->d_texture; // set shading for face - shade = ShadeForNormal( f->plane.Normal() ); + shade = ShadeForNormal(f->plane.Normal()); if (g_pParentWnd->GetCamera()->Camera().draw_mode == cd_texture && (b->owner && !b->owner->eclass->fixedsize)) { // if (b->curveBrush) shade = fCurveColor; f->d_color[0] = f->d_color[1] = f->d_color[2] = shade; } - else if ( f && b && b->owner ) { + else if (f && b && b->owner) { f->d_color[0] = shade * b->owner->eclass->color.x; f->d_color[1] = shade * b->owner->eclass->color.y; f->d_color[2] = shade * b->owner->eclass->color.z; @@ -415,14 +415,14 @@ Face_TextureVectors NOTE: this is never to get called while in brush primitives mode ================ */ -void Face_TextureVectors(face_t *f, float STfromXYZ[2][4]) { +void Face_TextureVectors(face_t* f, float STfromXYZ[2][4]) { idVec3 pvecs[2]; int sv, tv; float ang, sinv, cosv; float ns, nt; int i, j; - const idMaterial *q; - texdef_t *td; + const idMaterial* q; + texdef_t* td; #ifdef _DEBUG @@ -437,7 +437,7 @@ void Face_TextureVectors(face_t *f, float STfromXYZ[2][4]) { td = &f->texdef; q = f->d_texture; - memset(STfromXYZ, 0, 8 * sizeof (float)); + memset(STfromXYZ, 0, 8 * sizeof(float)); if (!td->scale[0]) { td->scale[0] = (g_PrefsDlg.m_bHiColorTextures) ? 2 : 1; @@ -448,7 +448,7 @@ void Face_TextureVectors(face_t *f, float STfromXYZ[2][4]) { } // get natural texture axis - TextureAxisFromPlane( f->plane, pvecs[0], pvecs[1]); + TextureAxisFromPlane(f->plane, pvecs[0], pvecs[1]); // rotate axis if (td->rotate == 0) { @@ -468,7 +468,7 @@ void Face_TextureVectors(face_t *f, float STfromXYZ[2][4]) { cosv = 0; } else { - ang = DEG2RAD( td->rotate ); + ang = DEG2RAD(td->rotate); sinv = sin(ang); cosv = cos(ang); } @@ -522,7 +522,7 @@ void Face_TextureVectors(face_t *f, float STfromXYZ[2][4]) { Face_MakePlane ================ */ -void Face_MakePlane(face_t *f) { +void Face_MakePlane(face_t* f) { int j; idVec3 t1, t2, t3; @@ -535,15 +535,15 @@ void Face_MakePlane(face_t *f) { t3[j] = f->planepts[1][j]; } - f->plane = t1.Cross( t2 ); + f->plane = t1.Cross(t2); //if ( f->plane.Compare( vec3_origin ) ) { // printf("WARNING: brush plane with no normal\n"); //} f->plane.Normalize(false); - f->plane[3] = - (t3 * f->plane.Normal()); + f->plane[3] = -(t3 * f->plane.Normal()); - if ( !f->dirty && !f->plane.Compare( oldPlane, 0.01f ) ) { + if (!f->dirty && !f->plane.Compare(oldPlane, 0.01f)) { f->dirty = true; } } @@ -553,7 +553,7 @@ void Face_MakePlane(face_t *f) { EmitTextureCoordinates ================ */ -void EmitTextureCoordinates(idVec5 &xyzst, const idMaterial *q, face_t *f, bool force) { +void EmitTextureCoordinates(idVec5& xyzst, const idMaterial* q, face_t* f, bool force) { float STfromXYZ[2][4]; if (g_qeglobals.m_bBrushPrimitMode && !force) { @@ -571,8 +571,8 @@ void EmitTextureCoordinates(idVec5 &xyzst, const idMaterial *q, face_t *f, bool Brush_MakeFacePlanes ================ */ -void Brush_MakeFacePlanes(brush_t *b) { - face_t *f; +void Brush_MakeFacePlanes(brush_t* b) { + face_t* f; for (f = b->brush_faces; f; f = f->next) { Face_MakePlane(f); @@ -584,8 +584,8 @@ void Brush_MakeFacePlanes(brush_t *b) { DrawBrushEntityName ================ */ -void DrawBrushEntityName(brush_t *b) { - const char *name; +void DrawBrushEntityName(brush_t* b) { + const char* name; // float a, s, c; vec3_t mid; int i; if (!b->owner) { @@ -604,8 +604,8 @@ void DrawBrushEntityName(brush_t *b) { // draw the angle pointer float a = FloatForKey(b->owner, "angle"); if (a) { - float s = sin( DEG2RAD( a ) ); - float c = cos( DEG2RAD( a ) ); + float s = sin(DEG2RAD(a)); + float c = cos(DEG2RAD(a)); idVec3 mid = (b->mins + b->maxs) / 2.0f; @@ -646,14 +646,14 @@ void DrawBrushEntityName(brush_t *b) { if (g_qeglobals.d_savedinfo.show_names && scale >= 1.0f) { name = ValueForKey(b->owner, "name"); int nameLen = strlen(name); - if ( nameLen == 0 ) { + if (nameLen == 0) { name = ValueForKey(b->owner, "classname"); nameLen = strlen(name); } - if ( nameLen > 0 ) { + if (nameLen > 0) { idVec3 origin = b->owner->origin; - float halfWidth = ( (nameLen / 2) * (7.0f / scale) ); + float halfWidth = ((nameLen / 2) * (7.0f / scale)); float halfHeight = 4.0f / scale; switch (viewType) { @@ -670,7 +670,7 @@ void DrawBrushEntityName(brush_t *b) { origin.z += halfHeight; break; } - glRasterPos3fv( origin.ToFloatPtr() ); + glRasterPos3fv(origin.ToFloatPtr()); glCallLists(nameLen, GL_UNSIGNED_BYTE, name); } } @@ -683,14 +683,14 @@ Brush_MakeFaceWinding returns the visible winding ================ */ -idWinding *Brush_MakeFaceWinding(brush_t *b, face_t *face, bool keepOnPlaneWinding) { - idWinding *w; - face_t *clip; +idWinding* Brush_MakeFaceWinding(brush_t* b, face_t* face, bool keepOnPlaneWinding) { + idWinding* w; + face_t* clip; idPlane plane; bool past; // get a poly that covers an effectively infinite area - w = new idWinding( face->plane ); + w = new idWinding(face->plane); // chop the poly by all of the other faces past = false; @@ -700,8 +700,8 @@ idWinding *Brush_MakeFaceWinding(brush_t *b, face_t *face, bool keepOnPlaneWindi continue; } - if ( DotProduct(face->plane, clip->plane) > 0.999f && - idMath::Fabs(face->plane[3] - clip->plane[3]) < 0.01f ) { // identical plane, use the later one + if (DotProduct(face->plane, clip->plane) > 0.999f && + idMath::Fabs(face->plane[3] - clip->plane[3]) < 0.01f) { // identical plane, use the later one if (past) { delete w; common->Printf("Unable to create face winding on brush\n"); @@ -711,23 +711,23 @@ idWinding *Brush_MakeFaceWinding(brush_t *b, face_t *face, bool keepOnPlaneWindi } // flip the plane, because we want to keep the back side - VectorSubtract(vec3_origin, clip->plane, plane ); + VectorSubtract(vec3_origin, clip->plane, plane); plane[3] = -clip->plane[3]; - w = w->Clip( plane, ON_EPSILON, keepOnPlaneWinding ); - if ( !w ) { + w = w->Clip(plane, ON_EPSILON, keepOnPlaneWinding); + if (!w) { return w; } } - if ( w->GetNumPoints() < 3) { + if (w->GetNumPoints() < 3) { delete w; w = NULL; } if (!w) { Sys_Status("Unable to create face winding on brush\n"); - } + } return w; } @@ -740,7 +740,7 @@ Brush_Build TTimo brush grouping: update the group treeview if necessary ================ */ -void Brush_Build(brush_t *b, bool bSnap, bool bMarkMap, bool bConvert, bool updateLights) { +void Brush_Build(brush_t* b, bool bSnap, bool bMarkMap, bool bConvert, bool updateLights) { bool bLocalConvert = false; #ifdef _DEBUG @@ -782,9 +782,9 @@ Brush_SplitBrushByFace The incoming brush is NOT freed. The incoming face is NOT left referenced. ================ */ -void Brush_SplitBrushByFace(brush_t *in, face_t *f, brush_t **front, brush_t **back) { - brush_t *b; - face_t *nf; +void Brush_SplitBrushByFace(brush_t* in, face_t* f, brush_t** front, brush_t** back) { + brush_t* b; + face_t* nf; idVec3 temp; b = Brush_Clone(in); @@ -838,36 +838,36 @@ Brush_BestSplitFace returns the best face to split the brush with. return NULL if the brush is convex ================ */ -face_t *Brush_BestSplitFace(brush_t *b) { - face_t *face, *f, *bestface; - idWinding *front, *back; +face_t* Brush_BestSplitFace(brush_t* b) { + face_t* face, * f, * bestface; + idWinding* front, * back; int splits, tinywindings, value, bestvalue; bestvalue = 999999; bestface = NULL; - for ( face = b->brush_faces; face; face = face->next ) { + for (face = b->brush_faces; face; face = face->next) { splits = 0; tinywindings = 0; - for ( f = b->brush_faces; f; f = f->next ) { - if ( f == face ) { + for (f = b->brush_faces; f; f = f->next) { + if (f == face) { continue; } - f->face_winding->Split( face->plane, 0.1f, &front, &back ); + f->face_winding->Split(face->plane, 0.1f, &front, &back); - if ( !front ) { + if (!front) { delete back; } - else if ( !back ) { + else if (!back) { delete front; } else { splits++; - if ( front->IsTiny() ) { + if (front->IsTiny()) { tinywindings++; } - if ( back->IsTiny() ) { + if (back->IsTiny()) { tinywindings++; } delete front; @@ -875,9 +875,9 @@ face_t *Brush_BestSplitFace(brush_t *b) { } } - if ( splits ) { + if (splits) { value = splits + 50 * tinywindings; - if ( value < bestvalue ) { + if (value < bestvalue) { bestvalue = value; bestface = face; } @@ -898,9 +898,9 @@ Brush_MakeConvexBrushes NOTE: the input brush should have windings for the faces. ================ */ -brush_t *Brush_MakeConvexBrushes(brush_t *b) { - brush_t *front, *back, *end; - face_t *face; +brush_t* Brush_MakeConvexBrushes(brush_t* b) { + brush_t* front, * back, * end; + face_t* face; b->next = NULL; face = Brush_BestSplitFace(b); @@ -936,8 +936,8 @@ Brush_Convex returns true if the brush is convex ================ */ -int Brush_Convex(brush_t *b) { - face_t *face1, *face2; +int Brush_Convex(brush_t* b) { + face_t* face1, * face2; for (face1 = b->brush_faces; face1; face1 = face1->next) { if (!face1->face_winding) { @@ -953,8 +953,8 @@ int Brush_Convex(brush_t *b) { continue; } - if ( face1->face_winding->PlanesConcave( *face2->face_winding, - face1->plane.Normal(), face2->plane.Normal(), -face1->plane[3], -face2->plane[3] ) ) { + if (face1->face_winding->PlanesConcave(*face2->face_winding, + face1->plane.Normal(), face2->plane.Normal(), -face1->plane[3], -face2->plane[3])) { return false; } } @@ -976,18 +976,18 @@ Brush_MoveVertexes #define MAX_MOVE_FACES 64 #define TINY_EPSILON 0.0325f -int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVec3 &end, bool bSnap) { - face_t *f, *face, *newface, *lastface, *nextface; - face_t *movefaces[MAX_MOVE_FACES]; +int Brush_MoveVertex(brush_t* b, const idVec3& vertex, const idVec3& delta, idVec3& end, bool bSnap) { + face_t* f, * face, * newface, * lastface, * nextface; + face_t* movefaces[MAX_MOVE_FACES]; int movefacepoints[MAX_MOVE_FACES]; - idWinding *w, tmpw(3); + idWinding* w, tmpw(3); idVec3 start, mid; idPlane plane; int i, j, k, nummovefaces, result, done; float dot, front, back, frac, smallestfrac; result = true; - tmpw.SetNumPoints( 3 ); + tmpw.SetNumPoints(3); VectorCopy(vertex, start); VectorAdd(vertex, delta, end); @@ -995,26 +995,26 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe // if (bSnap) { for (i = 0; i < 3; i++) { - end[i] = floor( end[i] / 0.125f + 0.5f ) * 0.125f; + end[i] = floor(end[i] / 0.125f + 0.5f) * 0.125f; } } VectorCopy(end, mid); // if the start and end are the same - if ( start.Compare( end, TINY_EPSILON ) ) { + if (start.Compare(end, TINY_EPSILON)) { return false; } // the end point may not be the same as another vertex - for ( face = b->brush_faces; face; face = face->next ) { + for (face = b->brush_faces; face; face = face->next) { w = face->face_winding; if (!w) { continue; } for (i = 0; i < w->GetNumPoints(); i++) { - if ( end.Compare( (*w)[i].ToVec3(), TINY_EPSILON ) ) { + if (end.Compare((*w)[i].ToVec3(), TINY_EPSILON)) { VectorCopy(vertex, end); return false; } @@ -1035,7 +1035,7 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe } for (i = 0; i < w->GetNumPoints(); i++) { - if ( start.Compare( (*w)[i].ToVec3(), TINY_EPSILON ) ) { + if (start.Compare((*w)[i].ToVec3(), TINY_EPSILON)) { if (face->face_winding->GetNumPoints() <= 3) { movefacepoints[nummovefaces] = i; movefaces[nummovefaces++] = face; @@ -1046,7 +1046,7 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe // if the end point is in front of the face plane //if ( dot > 0.1f ) { - if ( dot > TINY_EPSILON ) { + if (dot > TINY_EPSILON) { // fanout triangle subdivision for (k = i; k < i + w->GetNumPoints() - 3; k++) { VectorCopy((*w)[i], tmpw[0]); @@ -1096,12 +1096,12 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe VectorCopy((*w)[(i + 1) % w->GetNumPoints()], tmpw[2]); // remove the point from the face winding - w->RemovePoint( i ); + w->RemovePoint(i); // get texture crap right Face_SetColor(b, face, 1.0); for (j = 0; j < w->GetNumPoints(); j++) { - EmitTextureCoordinates( (*w)[j], face->d_texture, face ); + EmitTextureCoordinates((*w)[j], face->d_texture, face); } // make a triangle face @@ -1173,9 +1173,9 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe w = movefaces[i]->face_winding; VectorCopy((*w)[(k + 1) % w->GetNumPoints()], tmpw[2]); - if ( !plane.FromPoints( tmpw[0].ToVec3(), tmpw[1].ToVec3(), tmpw[2].ToVec3(), false ) ) { + if (!plane.FromPoints(tmpw[0].ToVec3(), tmpw[1].ToVec3(), tmpw[2].ToVec3(), false)) { VectorCopy((*w)[(k + 2) % w->GetNumPoints()], tmpw[2]); - if ( !plane.FromPoints( tmpw[0].ToVec3(), tmpw[1].ToVec3(), tmpw[2].ToVec3() ), false ) { + if (!plane.FromPoints(tmpw[0].ToVec3(), tmpw[1].ToVec3(), tmpw[2].ToVec3()), false) { // this should never happen otherwise the face merge did // a crappy job a previous pass continue; @@ -1201,7 +1201,7 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe } // if there's no movement orthogonal to this plane at all - if ( idMath::Fabs(front - back) < 0.001f ) { + if (idMath::Fabs(front - back) < 0.001f) { continue; } @@ -1220,15 +1220,15 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe // move the vertex for (i = 0; i < nummovefaces; i++) { // move vertex to end position - VectorCopy( mid, (*movefaces[i]->face_winding)[movefacepoints[i]] ); + VectorCopy(mid, (*movefaces[i]->face_winding)[movefacepoints[i]]); // create new face plane for (j = 0; j < 3; j++) { - VectorCopy( (*movefaces[i]->face_winding)[j], movefaces[i]->planepts[j] ); + VectorCopy((*movefaces[i]->face_winding)[j], movefaces[i]->planepts[j]); } - Face_MakePlane( movefaces[i] ); - if ( movefaces[i]->plane.Normal().Length() < TINY_EPSILON ) { + Face_MakePlane(movefaces[i]); + if (movefaces[i]->plane.Normal().Length() < TINY_EPSILON) { result = false; } } @@ -1237,11 +1237,11 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe if (!result || !Brush_Convex(b)) { for (i = 0; i < nummovefaces; i++) { // move the vertex back to the initial position - VectorCopy( start, (*movefaces[i]->face_winding)[movefacepoints[i]] ); + VectorCopy(start, (*movefaces[i]->face_winding)[movefacepoints[i]]); // create new face plane for (j = 0; j < 3; j++) { - VectorCopy( (*movefaces[i]->face_winding)[j], movefaces[i]->planepts[j] ); + VectorCopy((*movefaces[i]->face_winding)[j], movefaces[i]->planepts[j]); } Face_MakePlane(movefaces[i]); @@ -1257,9 +1257,9 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe // get texture crap right for (i = 0; i < nummovefaces; i++) { - Face_SetColor( b, movefaces[i], 1.0f ); + Face_SetColor(b, movefaces[i], 1.0f); for (j = 0; j < movefaces[i]->face_winding->GetNumPoints(); j++) { - EmitTextureCoordinates( (*movefaces[i]->face_winding)[j], movefaces[i]->d_texture, movefaces[i] ); + EmitTextureCoordinates((*movefaces[i]->face_winding)[j], movefaces[i]->d_texture, movefaces[i]); } } @@ -1272,12 +1272,12 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe continue; } - if ( !face->plane.Compare( face->original->plane, 0.0001f ) ) { + if (!face->plane.Compare(face->original->plane, 0.0001f)) { lastface = face; continue; } - w = face->face_winding->TryMerge( *face->original->face_winding, face->plane.Normal(), true ); + w = face->face_winding->TryMerge(*face->original->face_winding, face->plane.Normal(), true); if (!w) { lastface = face; continue; @@ -1287,9 +1287,9 @@ int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVe face->original->face_winding = w; // get texture crap right - Face_SetColor( b, face->original, 1.0f ); + Face_SetColor(b, face->original, 1.0f); for (j = 0; j < face->original->face_winding->GetNumPoints(); j++) { - EmitTextureCoordinates( (*face->original->face_winding)[j], face->original->d_texture, face->original); + EmitTextureCoordinates((*face->original->face_winding)[j], face->original->d_texture, face->original); } // remove the face that was merged with the original @@ -1314,18 +1314,18 @@ Brush_InsertVertexBetween Adds a vertex to the brush windings between the given two points. ================ */ -int Brush_InsertVertexBetween(brush_t *b, idVec3 p1, idVec3 p2) { - face_t *face; - idWinding *w, *neww; +int Brush_InsertVertexBetween(brush_t* b, idVec3 p1, idVec3 p2) { + face_t* face; + idWinding* w, * neww; idVec3 point; int i, insert; - if ( p1.Compare( p2, TINY_EPSILON ) ) { + if (p1.Compare(p2, TINY_EPSILON)) { return false; } - VectorAdd( p1, p2, point ); - VectorScale( point, 0.5f, point ); + VectorAdd(p1, p2, point); + VectorScale(point, 0.5f, point); insert = false; // the end point may not be the same as another vertex @@ -1337,18 +1337,18 @@ int Brush_InsertVertexBetween(brush_t *b, idVec3 p1, idVec3 p2) { neww = NULL; for (i = 0; i < w->GetNumPoints(); i++) { - if (! p1.Compare((*w)[i].ToVec3(), TINY_EPSILON)) { + if (!p1.Compare((*w)[i].ToVec3(), TINY_EPSILON)) { continue; } - if ( p2.Compare( (*w)[(i + 1) % w->GetNumPoints()].ToVec3(), TINY_EPSILON ) ) { - neww = new idWinding( *w ); - neww->InsertPoint( point, (i + 1) % w->GetNumPoints() ); + if (p2.Compare((*w)[(i + 1) % w->GetNumPoints()].ToVec3(), TINY_EPSILON)) { + neww = new idWinding(*w); + neww->InsertPoint(point, (i + 1) % w->GetNumPoints()); break; } - else if ( p2.Compare( (*w)[(i - 1 + w->GetNumPoints()) % w->GetNumPoints()].ToVec3(), TINY_EPSILON ) ) { - neww = new idWinding( *w ); - neww->InsertPoint( point, i ); + else if (p2.Compare((*w)[(i - 1 + w->GetNumPoints()) % w->GetNumPoints()].ToVec3(), TINY_EPSILON)) { + neww = new idWinding(*w); + neww->InsertPoint(point, i); break; } } @@ -1370,8 +1370,8 @@ Brush_ResetFaceOriginals reset points to original faces to NULL ================ */ -void Brush_ResetFaceOriginals(brush_t *b) { - face_t *face; +void Brush_ResetFaceOriginals(brush_t* b) { + face_t* face; for (face = b->brush_faces; face; face = face->next) { face->original = NULL; @@ -1387,9 +1387,9 @@ Brush_Parse run before each face parsing. It works, but it's a performance hit ================ */ -brush_t *Brush_Parse(idVec3 origin) { - brush_t *b; - face_t *f; +brush_t* Brush_Parse(idVec3 origin) { + brush_t* b; + face_t* f; int i, j; idVec3 useOrigin = origin; @@ -1405,7 +1405,7 @@ brush_t *Brush_Parse(idVec3 origin) { } // handle "Brush" primitive - if ( idStr::Icmp(token, "brushDef") == 0 || idStr::Icmp(token, "brushDef2") == 0 || idStr::Icmp(token, "brushDef3") == 0 ) { + if (idStr::Icmp(token, "brushDef") == 0 || idStr::Icmp(token, "brushDef2") == 0 || idStr::Icmp(token, "brushDef3") == 0) { // Timo parsing new brush format g_qeglobals.bPrimitBrushes = true; @@ -1421,12 +1421,12 @@ brush_t *Brush_Parse(idVec3 origin) { } bool newFormat = false; - if ( idStr::Icmp(token, "brushDef2") == 0 ) { + if (idStr::Icmp(token, "brushDef2") == 0) { newFormat = true; // useOrigin.Zero(); } - else if ( idStr::Icmp(token, "brushDef3") == 0 ) { + else if (idStr::Icmp(token, "brushDef3") == 0) { newFormat = true; } @@ -1436,7 +1436,7 @@ brush_t *Brush_Parse(idVec3 origin) { if (newFormat) { //Brush_BuildWindings(b, true, true, false, false); } - + if (b == NULL) { Warning("parsing brush primitive"); return NULL; @@ -1446,11 +1446,11 @@ brush_t *Brush_Parse(idVec3 origin) { } } - if ( idStr::Icmp(token, "patchDef2") == 0 || idStr::Icmp(token, "patchDef3") == 0 ) { + if (idStr::Icmp(token, "patchDef2") == 0 || idStr::Icmp(token, "patchDef3") == 0) { Brush_Free(b); // double string compare but will go away soon - b = Patch_Parse( idStr::Icmp(token, "patchDef2") == 0 ); + b = Patch_Parse(idStr::Icmp(token, "patchDef2") == 0); if (b == NULL) { Warning("parsing patch/brush"); return NULL; @@ -1485,7 +1485,7 @@ brush_t *Brush_Parse(idVec3 origin) { b->brush_faces = f; } else { - face_t *scan; + face_t* scan; for (scan = b->brush_faces; scan->next; scan = scan->next) ; scan->next = f; @@ -1559,9 +1559,9 @@ QERApp_MapPrintf_FILE carefully initialize ! ================ */ -FILE *g_File; +FILE* g_File; -void WINAPI QERApp_MapPrintf_FILE(char *text, ...) { +void WINAPI QERApp_MapPrintf_FILE(char* text, ...) { va_list argptr; char buf[32768]; @@ -1579,7 +1579,7 @@ Brush_SetEpair sets an epair for the given brush ================ */ -void Brush_SetEpair(brush_t *b, const char *pKey, const char *pValue) { +void Brush_SetEpair(brush_t* b, const char* pKey, const char* pValue) { if (g_qeglobals.m_bBrushPrimitMode) { if (b->pPatch) { Patch_SetEpair(b->pPatch, pKey, pValue); @@ -1598,7 +1598,7 @@ void Brush_SetEpair(brush_t *b, const char *pKey, const char *pValue) { Brush_GetKeyValue ================ */ -const char *Brush_GetKeyValue(brush_t *b, const char *pKey) { +const char* Brush_GetKeyValue(brush_t* b, const char* pKey) { if (g_qeglobals.m_bBrushPrimitMode) { if (b->pPatch) { return Patch_GetKeyValue(b->pPatch, pKey); @@ -1621,9 +1621,9 @@ Brush_Write save all brushes as Brush primitive format ================ */ -void Brush_Write(brush_t *b, FILE *f, const idVec3 &origin, bool newFormat) { - face_t *fa; - char *pname; +void Brush_Write(brush_t* b, FILE* f, const idVec3& origin, bool newFormat) { + face_t* fa; + char* pname; int i; if (b->pPatch) { @@ -1655,11 +1655,12 @@ void Brush_Write(brush_t *b, FILE *f, const idVec3 &origin, bool newFormat) { fa->planepts[0] -= origin; fa->planepts[1] -= origin; fa->planepts[2] -= origin; - plane.FromPoints( fa->planepts[0], fa->planepts[1], fa->planepts[2], false ); + plane.FromPoints(fa->planepts[0], fa->planepts[1], fa->planepts[2], false); fa->planepts[0] += origin; fa->planepts[1] += origin; fa->planepts[2] += origin; - } else { + } + else { plane = fa->originalPlane; } @@ -1714,7 +1715,7 @@ void Brush_Write(brush_t *b, FILE *f, const idVec3 &origin, bool newFormat) { WriteFileString(f, ") ) "); - char *pName = strlen(fa->texdef.name) > 0 ? fa->texdef.name : "notexture"; + char* pName = strlen(fa->texdef.name) > 0 ? fa->texdef.name : "notexture"; WriteFileString(f, "\"%s\" ", pName); WriteFileString(f, "%i %i %i\n", 0, 0, 0); } @@ -1767,7 +1768,7 @@ void Brush_Write(brush_t *b, FILE *f, const idVec3 &origin, bool newFormat) { WriteFileString(f, "%f", (float)fa->texdef.scale[1]); } - WriteFileString(f, " %i %i %i",0, 0, 0); + WriteFileString(f, " %i %i %i", 0, 0, 0); WriteFileString(f, "\n"); } @@ -1784,9 +1785,9 @@ QERApp_MapPrintf_MEMFILE carefully initialize ! ================ */ -CMemFile *g_pMemFile; +CMemFile* g_pMemFile; -void WINAPI QERApp_MapPrintf_MEMFILE(char *text, ...) { +void WINAPI QERApp_MapPrintf_MEMFILE(char* text, ...) { va_list argptr; char buf[32768]; @@ -1804,9 +1805,9 @@ Brush_Write save all brushes as Brush primitive format to a CMemFile* ================ */ -void Brush_Write(brush_t *b, CMemFile *pMemFile, const idVec3 &origin, bool newFormat) { - face_t *fa; - char *pname; +void Brush_Write(brush_t* b, CMemFile* pMemFile, const idVec3& origin, bool newFormat) { + face_t* fa; + char* pname; int i; if (b->pPatch) { @@ -1839,11 +1840,12 @@ void Brush_Write(brush_t *b, CMemFile *pMemFile, const idVec3 &origin, bool newF fa->planepts[0] -= origin; fa->planepts[1] -= origin; fa->planepts[2] -= origin; - plane.FromPoints( fa->planepts[0], fa->planepts[1], fa->planepts[2], false ); + plane.FromPoints(fa->planepts[0], fa->planepts[1], fa->planepts[2], false); fa->planepts[0] += origin; fa->planepts[1] += origin; fa->planepts[2] += origin; - } else { + } + else { plane = fa->originalPlane; } @@ -1899,7 +1901,7 @@ void Brush_Write(brush_t *b, CMemFile *pMemFile, const idVec3 &origin, bool newF MemFile_fprintf(pMemFile, ") ) "); // save texture attribs - char *pName = strlen(fa->texdef.name) > 0 ? fa->texdef.name : "unnamed"; + char* pName = strlen(fa->texdef.name) > 0 ? fa->texdef.name : "unnamed"; MemFile_fprintf(pMemFile, "\"%s\" ", pName); MemFile_fprintf(pMemFile, "%i %i %i\n", 0, 0, 0); } @@ -1969,11 +1971,11 @@ Brush_Create Create non-textured blocks for entities The brush is NOT linked to any list ================ */ -brush_t *Brush_Create(idVec3 mins, idVec3 maxs, texdef_t *texdef) { +brush_t* Brush_Create(idVec3 mins, idVec3 maxs, texdef_t* texdef) { int i, j; idVec3 pts[4][2]; - face_t *f; - brush_t *b; + face_t* f; + brush_t* b; // // brush primitive mode : convert texdef to brushprimit_texdef ? most of the time @@ -2039,15 +2041,155 @@ brush_t *Brush_Create(idVec3 mins, idVec3 maxs, texdef_t *texdef) { return b; } +/* +================ +Brush_AddFaceFromTemplate + +Adds one plane to a brush using the texture state from an existing face. +Only three plane points are needed; Brush_BuildWindings creates the clipped +winding for the final brush. +================ +*/ +static void Brush_AddFaceFromTemplate(brush_t* b, face_t* templateFace, const idVec3& p0, const idVec3& p1, const idVec3& p2) { + face_t* f = Face_Alloc(); + f->texdef = templateFace->texdef; + f->brushprimit_texdef = templateFace->brushprimit_texdef; + f->d_texture = Texture_ForName(f->texdef.name); + + VectorCopy(p0, f->planepts[0]); + VectorCopy(p1, f->planepts[1]); + VectorCopy(p2, f->planepts[2]); + + f->next = b->brush_faces; + b->brush_faces = f; +} + +/* +================ +Brush_GetWindingPlanePoints + +Finds three non-colinear points from a face winding. Reversing the order flips +the generated plane normal. +================ +*/ +static bool Brush_GetWindingPlanePoints(idWinding* w, bool reverse, const idVec3& offset, idVec3& p0, idVec3& p1, idVec3& p2) { + if (w == NULL || w->GetNumPoints() < 3) { + return false; + } + + const int numPoints = w->GetNumPoints(); + for (int i = 0; i < numPoints; i++) { + idVec3 a = (*w)[i].ToVec3() + offset; + idVec3 b = (*w)[(i + 1) % numPoints].ToVec3() + offset; + idVec3 c = (*w)[(i + 2) % numPoints].ToVec3() + offset; + idVec3 edge1 = a - b; + idVec3 edge2 = c - b; + idVec3 cross = edge1.Cross(edge2); + + if (cross.LengthSqr() <= 0.0001f) { + continue; + } + + if (reverse) { + p0 = c; + p1 = b; + p2 = a; + } + else { + p0 = a; + p1 = b; + p2 = c; + } + return true; + } + + return false; +} + +/* +================ +Brush_CreateFaceExtrusion + +Creates an unlinked brush by sweeping sourceFace along its plane normal. The +caller is responsible for Brush_AddToList, Entity_LinkBrush, Brush_Build and +Brush_RemoveEmptyFaces. Positive distance extrudes along the face normal; +negative distance extrudes in the opposite direction. +================ +*/ +brush_t* Brush_CreateFaceExtrusion(brush_t* sourceBrush, face_t* sourceFace, float distance) { + if (sourceBrush == NULL || sourceFace == NULL || sourceFace->face_winding == NULL) { + return NULL; + } + if (sourceFace->face_winding->GetNumPoints() < 3) { + return NULL; + } + if (idMath::Fabs(distance) < 0.01f) { + return NULL; + } + + idVec3 normal = sourceFace->plane.Normal(); + if (normal.LengthSqr() < 0.0001f) { + return NULL; + } + normal.Normalize(); + + idWinding* w = sourceFace->face_winding; + const int numPoints = w->GetNumPoints(); + const bool negativeExtrude = (distance < 0.0f); + const idVec3 zeroOffset(0.0f, 0.0f, 0.0f); + const idVec3 extrudeOffset = normal * distance; + + idVec3 p0, p1, p2; + brush_t* out = Brush_Alloc(); + out->owner = sourceBrush->owner; + + // Base face sits on the source brush face. Its outward normal points back + // toward the source brush for positive extrusions, and flips for negative. + if (!Brush_GetWindingPlanePoints(w, !negativeExtrude, zeroOffset, p0, p1, p2)) { + Brush_Free(out); + return NULL; + } + Brush_AddFaceFromTemplate(out, sourceFace, p0, p1, p2); + + // Cap face at the far end of the sweep. + if (!Brush_GetWindingPlanePoints(w, negativeExtrude, extrudeOffset, p0, p1, p2)) { + Brush_Free(out); + return NULL; + } + Brush_AddFaceFromTemplate(out, sourceFace, p0, p1, p2); + + // Side faces for every source winding edge. + for (int i = 0; i < numPoints; i++) { + const int j = (i + 1) % numPoints; + idVec3 a = (*w)[i].ToVec3(); + idVec3 b = (*w)[j].ToVec3(); + idVec3 a2 = a + extrudeOffset; + idVec3 b2 = b + extrudeOffset; + + if ((b - a).LengthSqr() <= 0.0001f) { + continue; + } + + if (negativeExtrude) { + Brush_AddFaceFromTemplate(out, sourceFace, b, a, a2); + } + else { + Brush_AddFaceFromTemplate(out, sourceFace, a, b, b2); + } + } + + return out; +} + /* ============= Brush_Scale ============= */ void Brush_Scale(brush_t* b) { - for ( face_t *f = b->brush_faces; f; f = f->next ) { - for ( int i = 0; i < 3; i++ ) { - VectorScale( f->planepts[i], g_qeglobals.d_gridsize, f->planepts[i] ); + for (face_t* f = b->brush_faces; f; f = f->next) { + for (int i = 0; i < 3; i++) { + VectorScale(f->planepts[i], g_qeglobals.d_gridsize, f->planepts[i]); } } } @@ -2059,7 +2201,7 @@ Brush_CreatePyramid Create non-textured pyramid for light entities The brush is NOT linked to any list ================ */ -brush_t *Brush_CreatePyramid(idVec3 mins, idVec3 maxs, texdef_t *texdef) { +brush_t* Brush_CreatePyramid(idVec3 mins, idVec3 maxs, texdef_t* texdef) { // ++timo handle new brush primitive ? return here ?? return Brush_Create(mins, maxs, texdef); @@ -2070,7 +2212,7 @@ brush_t *Brush_CreatePyramid(idVec3 mins, idVec3 maxs, texdef_t *texdef) { } } - brush_t *b = Brush_Alloc(); + brush_t* b = Brush_Alloc(); idVec3 corners[4]; @@ -2103,7 +2245,7 @@ brush_t *Brush_CreatePyramid(idVec3 mins, idVec3 maxs, texdef_t *texdef) { // sides for (i = 0; i < 4; i++) { - face_t *f = Face_Alloc(); + face_t* f = Face_Alloc(); f->texdef = *texdef; f->next = b->brush_faces; b->brush_faces = f; @@ -2137,9 +2279,9 @@ Brush_MakeSided void Brush_MakeSided(int sides) { int i, axis; idVec3 mins, maxs; - brush_t *b; - texdef_t *texdef; - face_t *f; + brush_t* b; + texdef_t* texdef; + face_t* f; idVec3 mid; float width; float sv, cv; @@ -2169,15 +2311,15 @@ void Brush_MakeSided(int sides) { if (g_pParentWnd->ActiveXY()) { switch (g_pParentWnd->ActiveXY()->GetViewType()) { - case XY: - axis = 2; - break; - case XZ: - axis = 1; - break; - case YZ: - axis = 0; - break; + case XY: + axis = 2; + break; + case XZ: + axis = 1; + break; + case YZ: + axis = 0; + break; } } else { @@ -2275,16 +2417,16 @@ Brush_Free set bRemoveNode to false to avoid trying to delete the item in group view tree control ================ */ -void Brush_Free(brush_t *b, bool bRemoveNode) { - face_t *f, *next; +void Brush_Free(brush_t* b, bool bRemoveNode) { + face_t* f, * next; // free the patch if it's there - if ( b->pPatch ) { + if (b->pPatch) { Patch_Delete(b->pPatch); } // free faces - for ( f = b->brush_faces; f; f = next ) { + for (f = b->brush_faces; f; f = next) { next = f->next; Face_Free(f); } @@ -2292,12 +2434,12 @@ void Brush_Free(brush_t *b, bool bRemoveNode) { b->epairs.Clear(); // unlink from active/selected list - if ( b->next ) { + if (b->next) { Brush_RemoveFromList(b); } // unlink from entity list - if ( b->onext ) { + if (b->onext) { Entity_UnlinkBrush(b); } @@ -2311,13 +2453,13 @@ Face_MemorySize returns the size in memory of the face ================ */ -int Face_MemorySize(face_t *f) { +int Face_MemorySize(face_t* f) { int size = 0; - if ( f->face_winding ) { - size += sizeof( idWinding ) + f->face_winding->GetNumPoints() * sizeof( (f->face_winding)[0] ); + if (f->face_winding) { + size += sizeof(idWinding) + f->face_winding->GetNumPoints() * sizeof((f->face_winding)[0]); } - size += sizeof( face_t ); + size += sizeof(face_t); return size; } @@ -2328,18 +2470,18 @@ Brush_MemorySize returns the size in memory of the brush ================ */ -int Brush_MemorySize( brush_t *b ) { - face_t *f; +int Brush_MemorySize(brush_t* b) { + face_t* f; int size = 0; - if ( b->pPatch ) { - size += Patch_MemorySize( b->pPatch ); + if (b->pPatch) { + size += Patch_MemorySize(b->pPatch); } - for ( f = b->brush_faces; f; f = f->next ) { + for (f = b->brush_faces; f; f = f->next) { size += Face_MemorySize(f); } - size += sizeof( brush_t ) + b->epairs.Size(); + size += sizeof(brush_t) + b->epairs.Size(); return size; } @@ -2350,12 +2492,12 @@ Brush_Clone does not add the brush to any lists ================ */ -brush_t *Brush_Clone(brush_t *b) { - brush_t *n = NULL; - face_t *f, *nf; +brush_t* Brush_Clone(brush_t* b) { + brush_t* n = NULL; + face_t* f, * nf; if (b->pPatch) { - patchMesh_t *p = Patch_Duplicate(b->pPatch); + patchMesh_t* p = Patch_Duplicate(b->pPatch); Brush_RemoveFromList(p->pSymbiot); Entity_UnlinkBrush(p->pSymbiot); n = p->pSymbiot; @@ -2395,13 +2537,13 @@ Brush_FullClone Does NOT add the new brush to any lists. ================ */ -brush_t *Brush_FullClone(brush_t *b) { - brush_t *n = NULL; - face_t *f, *nf, *f2, *nf2; +brush_t* Brush_FullClone(brush_t* b) { + brush_t* n = NULL; + face_t* f, * nf, * f2, * nf2; int j; if (b->pPatch) { - patchMesh_t *p = Patch_Duplicate(b->pPatch); + patchMesh_t* p = Patch_Duplicate(b->pPatch); Brush_RemoveFromList(p->pSymbiot); Entity_UnlinkBrush(p->pSymbiot); n = p->pSymbiot; @@ -2449,14 +2591,14 @@ brush_t *Brush_FullClone(brush_t *b) { } for (nf = n->brush_faces; nf; nf = nf->next) { - Face_SetColor( n, nf, 1.0f ); + Face_SetColor(n, nf, 1.0f); if (nf->face_winding) { if (g_qeglobals.m_bBrushPrimitMode) { EmitBrushPrimitTextureCoordinates(nf, nf->face_winding); } else { for (j = 0; j < nf->face_winding->GetNumPoints(); j++) { - EmitTextureCoordinates( (*nf->face_winding)[j], nf->d_texture, nf ); + EmitTextureCoordinates((*nf->face_winding)[j], nf->d_texture, nf); } } } @@ -2466,17 +2608,17 @@ brush_t *Brush_FullClone(brush_t *b) { return n; } -extern bool GetMatrixForKey(entity_t *ent, const char *key, idMat3 &mat); -extern bool Patch_Intersect(patchMesh_t *pm, idVec3 origin, idVec3 direction , float &scale); +extern bool GetMatrixForKey(entity_t* ent, const char* key, idMat3& mat); +extern bool Patch_Intersect(patchMesh_t* pm, idVec3 origin, idVec3 direction, float& scale); extern bool RayIntersectsTri - ( - const idVec3 &origin, - const idVec3 &direction, - const idVec3 &vert0, - const idVec3 &vert1, - const idVec3 &vert2, - float &scale - ); +( + const idVec3& origin, + const idVec3& direction, + const idVec3& vert0, + const idVec3& vert1, + const idVec3& vert2, + float& scale +); /* @@ -2484,7 +2626,7 @@ extern bool RayIntersectsTri RotateVector ================ */ -void RotateVector(idVec3 &v, idVec3 origin, float a, float c, float s) { +void RotateVector(idVec3& v, idVec3 origin, float a, float c, float s) { float x = v[0]; float y = v[1]; if (a) { @@ -2502,34 +2644,34 @@ Brush_ModelIntersect ================ */ -bool Brush_ModelIntersect(brush_t *b, idVec3 origin, idVec3 dir,float &scale) { - idRenderModel *model = b->modelHandle; - idRenderModel *md5; - - if ( !model ) - model = b->owner->eclass->entityModel; +bool Brush_ModelIntersect(brush_t* b, idVec3 origin, idVec3 dir, float& scale) { + idRenderModel* model = b->modelHandle; + idRenderModel* md5; - scale = 0; + if (!model) + model = b->owner->eclass->entityModel; + + scale = 0; if (model) { - if ( model->IsDynamicModel() != DM_STATIC ) { - if ( dynamic_cast( model ) ) { + if (model->IsDynamicModel() != DM_STATIC) { + if (dynamic_cast(model)) { // take care of animated models md5 = b->owner->eclass->entityModel; - const char *classname = ValueForKey( b->owner, "classname" ); + const char* classname = ValueForKey(b->owner, "classname"); if (stricmp(classname, "func_static") == 0) { classname = ValueForKey(b->owner, "animclass"); } - const char *anim = ValueForKey( b->owner, "anim" ); - int frame = IntForKey( b->owner, "frame" ) + 1; - if ( frame < 1 ) { + const char* anim = ValueForKey(b->owner, "anim"); + int frame = IntForKey(b->owner, "frame") + 1; + if (frame < 1) { frame = 1; } - if ( !anim || !anim[ 0 ] ) { + if (!anim || !anim[0]) { anim = "idle"; } - model = gameEdit->ANIM_CreateMeshForAnim( md5, classname, anim, frame, false ); - if ( !model ) { + model = gameEdit->ANIM_CreateMeshForAnim(md5, classname, anim, frame, false); + if (!model) { model = renderModelManager->DefaultModel(); } } @@ -2540,20 +2682,21 @@ bool Brush_ModelIntersect(brush_t *b, idVec3 origin, idVec3 dir,float &scale) { float a, s, c; if (GetMatrixForKey(b->owner, "rotation", mat)) { matrix = true; - } else { + } + else { a = FloatForKey(b->owner, "angle"); if (a) { - s = sin( DEG2RAD( a ) ); - c = cos( DEG2RAD( a ) ); + s = sin(DEG2RAD(a)); + c = cos(DEG2RAD(a)); } else { s = c = 0; } } - for (int i = 0; i < model->NumSurfaces() ; i++) { - const modelSurface_t *surf = model->Surface( i ); - srfTriangles_t *tri = surf->geometry; + for (int i = 0; i < model->NumSurfaces(); i++) { + const modelSurface_t* surf = model->Surface(i); + srfTriangles_t* tri = surf->geometry; for (int j = 0; j < tri->numIndexes; j += 3) { idVec3 v1, v2, v3; v1 = tri->verts[tri->indexes[j]].xyz; @@ -2567,7 +2710,8 @@ bool Brush_ModelIntersect(brush_t *b, idVec3 origin, idVec3 dir,float &scale) { v2 += b->owner->origin; v3 *= b->owner->rotation; v3 += b->owner->origin; - } else { + } + else { v1 += b->owner->origin; v2 += b->owner->origin; v3 += b->owner->origin; @@ -2576,7 +2720,7 @@ bool Brush_ModelIntersect(brush_t *b, idVec3 origin, idVec3 dir,float &scale) { RotateVector(v3, b->owner->origin, a, c, s); } - if (RayIntersectsTri(origin, dir, v1, v2, v3,scale)) { + if (RayIntersectsTri(origin, dir, v1, v2, v3, scale)) { return true; } } @@ -2586,12 +2730,12 @@ bool Brush_ModelIntersect(brush_t *b, idVec3 origin, idVec3 dir,float &scale) { return false; } -face_t *Brush_Ray(idVec3 origin, idVec3 dir, brush_t *b, float *dist, bool testPrimitive) { - face_t *f, *firstface = NULL; +face_t* Brush_Ray(idVec3 origin, idVec3 dir, brush_t* b, float* dist, bool testPrimitive) { + face_t* f, * firstface = NULL; idVec3 p1, p2; float frac, d1, d2; int i; - float scale = HUGE_DISTANCE * 2; + float scale = HUGE_DISTANCE * 2; VectorCopy(origin, p1); for (i = 0; i < 3; i++) { p2[i] = p1[i] + dir[i] * HUGE_DISTANCE * 2; @@ -2635,7 +2779,7 @@ face_t *Brush_Ray(idVec3 origin, idVec3 dir, brush_t *b, float *dist, bool testP return NULL; } } - else if ( b->modelHandle != NULL && dynamic_cast( b->modelHandle ) == NULL && dynamic_cast< idRenderModelLiquid*> ( b->modelHandle ) == NULL ) { + else if (b->modelHandle != NULL && dynamic_cast(b->modelHandle) == NULL && dynamic_cast (b->modelHandle) == NULL) { if (!Brush_ModelIntersect(b, origin, dir, scale)) { *dist = 0; return NULL; @@ -2652,8 +2796,8 @@ face_t *Brush_Ray(idVec3 origin, idVec3 dir, brush_t *b, float *dist, bool testP Brush_Point ================ */ -face_t *Brush_Point(idVec3 origin, brush_t *b) { - face_t *f; +face_t* Brush_Point(idVec3 origin, brush_t* b) { + face_t* f; float d1; for (f = b->brush_faces; f; f = f->next) { @@ -2671,7 +2815,7 @@ face_t *Brush_Point(idVec3 origin, brush_t *b) { Brush_AddToList ================ */ -void Brush_AddToList(brush_t *b, brush_t *list) { +void Brush_AddToList(brush_t* b, brush_t* list) { if (b->next || b->prev) { Error("Brush_AddToList: allready linked"); } @@ -2695,7 +2839,7 @@ void Brush_AddToList(brush_t *b, brush_t *list) { Brush_RemoveFromList ================ */ -void Brush_RemoveFromList(brush_t *b) { +void Brush_RemoveFromList(brush_t* b) { if (!b->next || !b->prev) { Error("Brush_RemoveFromList: not linked"); } @@ -2724,7 +2868,7 @@ SetFaceTexdef get ->Copy() of it into the face ( and remember to hook ) if NULL, ask for a default ================ */ -void SetFaceTexdef( brush_t *b, face_t *f, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale ) { +void SetFaceTexdef(brush_t* b, face_t* f, texdef_t* texdef, brushprimit_texdef_t* brushprimit_texdef, bool bFitScale) { if (g_qeglobals.m_bBrushPrimitMode) { f->texdef = *texdef; @@ -2766,12 +2910,12 @@ void SetFaceTexdef( brush_t *b, face_t *f, texdef_t *texdef, brushprimit_texdef_ Brush_SetTexture ================ */ -void Brush_SetTexture(brush_t *b, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale) { +void Brush_SetTexture(brush_t* b, texdef_t* texdef, brushprimit_texdef_t* brushprimit_texdef, bool bFitScale) { if (b->pPatch) { Patch_SetTexture(b->pPatch, texdef); } else { - for (face_t * f = b->brush_faces; f; f = f->next) { + for (face_t* f = b->brush_faces; f; f = f->next) { SetFaceTexdef(b, f, texdef, brushprimit_texdef, bFitScale); } @@ -2784,12 +2928,12 @@ void Brush_SetTexture(brush_t *b, texdef_t *texdef, brushprimit_texdef_t *brushp Brush_SetTextureName ==================== */ -void Brush_SetTextureName(brush_t *b, const char *name) { +void Brush_SetTextureName(brush_t* b, const char* name) { if (b->pPatch) { Patch_SetTextureName(b->pPatch, name); } else { - for (face_t * f = b->brush_faces; f; f = f->next) { + for (face_t* f = b->brush_faces; f; f = f->next) { f->texdef.SetName(name); } Brush_Build(b); @@ -2801,10 +2945,10 @@ void Brush_SetTextureName(brush_t *b, const char *name) { ClipLineToFace ================ */ -bool ClipLineToFace(idVec3 &p1, idVec3 &p2, face_t *f) { +bool ClipLineToFace(idVec3& p1, idVec3& p2, face_t* f) { float d1, d2, fr; int i; - float *v; + float* v; d1 = DotProduct(p1, f->plane) + f->plane[3]; d2 = DotProduct(p2, f->plane) + f->plane[3]; @@ -2838,7 +2982,7 @@ bool ClipLineToFace(idVec3 &p1, idVec3 &p2, face_t *f) { AddPlanept ================ */ -int AddPlanept(idVec3 *f) { +int AddPlanept(idVec3* f) { int i; for (i = 0; i < g_qeglobals.d_num_move_points; i++) { @@ -2849,7 +2993,8 @@ int AddPlanept(idVec3 *f) { if (g_qeglobals.d_num_move_points < MAX_MOVE_POINTS) { g_qeglobals.d_move_points[g_qeglobals.d_num_move_points++] = f; - } else { + } + else { Sys_Status("Trying to move too many points\n"); return 0; } @@ -2862,7 +3007,7 @@ int AddPlanept(idVec3 *f) { AddMovePlane ================ */ -void AddMovePlane( idPlane *p ) { +void AddMovePlane(idPlane* p) { for (int i = 0; i < g_qeglobals.d_num_move_planes; i++) { if (g_qeglobals.d_move_planes[i] == p) { @@ -2872,7 +3017,8 @@ void AddMovePlane( idPlane *p ) { if (g_qeglobals.d_num_move_planes < MAX_MOVE_PLANES) { g_qeglobals.d_move_planes[g_qeglobals.d_num_move_planes++] = p; - } else { + } + else { Sys_Status("Trying to move too many planes\n"); } @@ -2885,12 +3031,12 @@ Brush_SelectFaceForDragging Adds the faces planepts to move_points, and rotates and adds the planepts of adjacent face if shear is set ================ */ -void Brush_SelectFaceForDragging(brush_t *b, face_t *f, bool shear) { +void Brush_SelectFaceForDragging(brush_t* b, face_t* f, bool shear) { int i; - face_t *f2; - idWinding *w; + face_t* f2; + idWinding* w; float d; - brush_t *b2; + brush_t* b2; int c; if (b->owner->eclass->fixedsize || EntityHasModel(b->owner)) { @@ -2948,7 +3094,7 @@ void Brush_SelectFaceForDragging(brush_t *b, face_t *f, bool shear) { // any points on f will become new control points for (i = 0; i < w->GetNumPoints(); i++) { - d = DotProduct( (*w)[i], f->plane ) + f->plane[3]; + d = DotProduct((*w)[i], f->plane) + f->plane[3]; if (d > -ON_EPSILON && d < ON_EPSILON) { break; } @@ -2957,9 +3103,9 @@ void Brush_SelectFaceForDragging(brush_t *b, face_t *f, bool shear) { // if none of the points were on the plane, leave it alone if (i != w->GetNumPoints()) { if (i == 0) { // see if the first clockwise point was the - /// - /// last point on the winding - d = DotProduct( (*w)[w->GetNumPoints() - 1], f->plane ) + f->plane[3]; + /// + /// last point on the winding + d = DotProduct((*w)[w->GetNumPoints() - 1], f->plane) + f->plane[3]; if (d > -ON_EPSILON && d < ON_EPSILON) { i = w->GetNumPoints() - 1; } @@ -2974,18 +3120,18 @@ void Brush_SelectFaceForDragging(brush_t *b, face_t *f, bool shear) { } // see if the next point is also on the plane - d = DotProduct( (*w)[i], f->plane ) + f->plane[3]; + d = DotProduct((*w)[i], f->plane) + f->plane[3]; if (d > -ON_EPSILON && d < ON_EPSILON) { AddPlanept(&f2->planepts[1]); } - VectorCopy( (*w)[i], f2->planepts[1] ); + VectorCopy((*w)[i], f2->planepts[1]); if (++i == w->GetNumPoints()) { i = 0; } // the third point is never on the plane - VectorCopy( (*w)[i], f2->planepts[2] ); + VectorCopy((*w)[i], f2->planepts[2]); } delete w; @@ -2999,8 +3145,8 @@ Brush_SideSelect The mouse click did not hit the brush, so grab one or more side planes for dragging. ================ */ -void Brush_SideSelect(brush_t *b, idVec3 origin, idVec3 dir, bool shear) { - face_t *f, *f2; +void Brush_SideSelect(brush_t* b, idVec3 origin, idVec3 dir, bool shear) { + face_t* f, * f2; idVec3 p1, p2; if (g_moveOnly) { @@ -3024,7 +3170,7 @@ void Brush_SideSelect(brush_t *b, idVec3 origin, idVec3 dir, bool shear) { continue; } - if ( p1.Compare( origin ) ) { + if (p1.Compare(origin)) { continue; } @@ -3036,18 +3182,18 @@ void Brush_SideSelect(brush_t *b, idVec3 origin, idVec3 dir, bool shear) { } } -extern void UpdateSelectablePoint(brush_t *b, idVec3 v, int type); -extern void AddSelectablePoint(brush_t *b, idVec3 v, int type, bool priority); -extern void ClearSelectablePoints(brush_t *b); +extern void UpdateSelectablePoint(brush_t* b, idVec3 v, int type); +extern void AddSelectablePoint(brush_t* b, idVec3 v, int type, bool priority); +extern void ClearSelectablePoints(brush_t* b); /* ================ Brush_TransformedPoint ================ */ -extern void VectorSnapGrid(idVec3 &v); +extern void VectorSnapGrid(idVec3& v); -idMat3 Brush_RotationMatrix(brush_t *b) { +idMat3 Brush_RotationMatrix(brush_t* b) { idMat3 mat; mat.Identity(); if (!GetMatrixForKey(b->owner, "light_rotation", mat)) { @@ -3056,7 +3202,7 @@ idMat3 Brush_RotationMatrix(brush_t *b) { return mat; } -idVec3 Brush_TransformedPoint(brush_t *b, const idVec3 &in) { +idVec3 Brush_TransformedPoint(brush_t* b, const idVec3& in) { idVec3 out = in; out -= b->owner->origin; out *= Brush_RotationMatrix(b); @@ -3068,7 +3214,7 @@ idVec3 Brush_TransformedPoint(brush_t *b, const idVec3 &in) { Brush_UpdateLightPoints ================ */ -void Brush_UpdateLightPoints(brush_t *b, const idVec3 &offset) { +void Brush_UpdateLightPoints(brush_t* b, const idVec3& offset) { if (!(b->owner->eclass->nShowFlags & ECLASS_LIGHT)) { if (b->modelHandle) { @@ -3084,16 +3230,16 @@ void Brush_UpdateLightPoints(brush_t *b, const idVec3 &offset) { } idVec3 vCenter; - idVec3 *origin = (b->trackLightOrigin) ? &b->owner->lightOrigin : &b->owner->origin; + idVec3* origin = (b->trackLightOrigin) ? &b->owner->lightOrigin : &b->owner->origin; if (!GetVectorForKey(b->owner, "_color", b->lightColor)) { b->lightColor[0] = b->lightColor[1] = b->lightColor[2] = 1; } - const char *str = ValueForKey(b->owner, "texture"); + const char* str = ValueForKey(b->owner, "texture"); b->lightTexture = -1; if (str && strlen(str) > 0) { - const idMaterial *q = Texture_LoadLight(str); + const idMaterial* q = Texture_LoadLight(str); if (q) { b->lightTexture = q->GetEditorImage()->texnum; } @@ -3176,9 +3322,9 @@ void Brush_UpdateLightPoints(brush_t *b, const idVec3 &offset) { Brush_BuildWindings ================ */ -void Brush_BuildWindings(brush_t *b, bool bSnap, bool keepOnPlaneWinding, bool updateLights, bool makeFacePlanes) { - idWinding *w; - face_t *face; +void Brush_BuildWindings(brush_t* b, bool bSnap, bool keepOnPlaneWinding, bool updateLights, bool makeFacePlanes) { + idWinding* w; + face_t* face; float v; // clear the mins/maxs bounds @@ -3221,9 +3367,9 @@ void Brush_BuildWindings(brush_t *b, bool bSnap, bool keepOnPlaneWinding, bool u if (makeFacePlanes) { Face_SetColor(b, face, fCurveColor); - // } + // } fCurveColor -= 0.1f; - if ( fCurveColor <= 0.0f ) { + if (fCurveColor <= 0.0f) { fCurveColor = 1.0f; } @@ -3235,12 +3381,12 @@ void Brush_BuildWindings(brush_t *b, bool bSnap, bool keepOnPlaneWinding, bool u // representation to new format // FaceToBrushPrimitFace(face); - #ifdef _DEBUG +#ifdef _DEBUG // use old texture coordinates code to check against for (i = 0; i < w->GetNumPoints(); i++) { EmitTextureCoordinates((*w)[i], face->d_texture, face); } - #endif +#endif } // @@ -3272,8 +3418,8 @@ Brush_RemoveEmptyFaces Frees any overconstraining faces ================ */ -void Brush_RemoveEmptyFaces(brush_t *b) { - face_t *f, *next; +void Brush_RemoveEmptyFaces(brush_t* b) { + face_t* f, * next; f = b->brush_faces; b->brush_faces = NULL; @@ -3295,17 +3441,17 @@ void Brush_RemoveEmptyFaces(brush_t *b) { Brush_SnapToGrid ================ */ -void Brush_SnapToGrid(brush_t *pb) { +void Brush_SnapToGrid(brush_t* pb) { int i; - for (face_t * f = pb->brush_faces; f; f = f->next) { - idWinding *w = f->face_winding; + for (face_t* f = pb->brush_faces; f; f = f->next) { + idWinding* w = f->face_winding; if (!w) { continue; // freed face } for (i = 0; i < w->GetNumPoints(); i++) { - SnapVectorToGrid( (*w)[i].ToVec3() ); + SnapVectorToGrid((*w)[i].ToVec3()); } for (i = 0; i < 3; i++) { @@ -3345,7 +3491,8 @@ void Brush_SnapToGrid(brush_t *pb) { pb->lightEnd = v; SetKeyVec3(pb->owner, "light_end", v); } - } else { + } + else { // point if (GetVectorForKey(pb->owner, "light_center", v)) { SnapVectorToGrid(v); @@ -3354,12 +3501,12 @@ void Brush_SnapToGrid(brush_t *pb) { } } - if ( pb->owner->curve ) { + if (pb->owner->curve) { int c = pb->owner->curve->GetNumValues(); - for ( i = 0; i < c; i++ ) { - v = pb->owner->curve->GetValue( i ); - SnapVectorToGrid( v ); - pb->owner->curve->SetValue( i, v ); + for (i = 0; i < c; i++) { + v = pb->owner->curve->GetValue(i); + SnapVectorToGrid(v); + pb->owner->curve->SetValue(i, v); } } @@ -3371,8 +3518,8 @@ void Brush_SnapToGrid(brush_t *pb) { Brush_Rotate ================ */ -void Brush_Rotate(brush_t *b, idMat3 matrix, idVec3 origin, bool bBuild) { - for (face_t * f = b->brush_faces; f; f = f->next) { +void Brush_Rotate(brush_t* b, idMat3 matrix, idVec3 origin, bool bBuild) { + for (face_t* f = b->brush_faces; f; f = f->next) { for (int i = 0; i < 3; i++) { f->planepts[i] -= origin; f->planepts[i] *= matrix; @@ -3385,15 +3532,15 @@ void Brush_Rotate(brush_t *b, idMat3 matrix, idVec3 origin, bool bBuild) { } } -extern void VectorRotate3Origin( const idVec3 &vIn, const idVec3 &vRotation, const idVec3 &vOrigin, idVec3 &out ); +extern void VectorRotate3Origin(const idVec3& vIn, const idVec3& vRotation, const idVec3& vOrigin, idVec3& out); /* ================ Brush_Rotate ================ */ -void Brush_Rotate(brush_t *b, idVec3 vAngle, idVec3 vOrigin, bool bBuild) { - for (face_t * f = b->brush_faces; f; f = f->next) { +void Brush_Rotate(brush_t* b, idVec3 vAngle, idVec3 vOrigin, bool bBuild) { + for (face_t* f = b->brush_faces; f; f = f->next) { for (int i = 0; i < 3; i++) { VectorRotate3Origin(f->planepts[i], vAngle, vOrigin, f->planepts[i]); } @@ -3409,7 +3556,7 @@ void Brush_Rotate(brush_t *b, idVec3 vAngle, idVec3 vOrigin, bool bBuild) { Brush_Center ================ */ -void Brush_Center(brush_t *b, idVec3 vNewCenter) { +void Brush_Center(brush_t* b, idVec3 vNewCenter) { idVec3 vMid; // get center of the brush @@ -3429,24 +3576,24 @@ Brush_Resize the brush must be a true axial box ================ */ -void Brush_Resize( brush_t *b, idVec3 vMin, idVec3 vMax ) { +void Brush_Resize(brush_t* b, idVec3 vMin, idVec3 vMax) { int i, j; - face_t *f; + face_t* f; - assert( vMin[0] < vMax[0] && vMin[1] < vMax[1] && vMin[2] < vMax[2] ); + assert(vMin[0] < vMax[0] && vMin[1] < vMax[1] && vMin[2] < vMax[2]); - Brush_MakeFacePlanes( b ); + Brush_MakeFacePlanes(b); - for( f = b->brush_faces; f; f = f->next ) { - for ( i = 0; i < 3; i++ ) { - if ( f->plane.Normal()[i] >= 0.999f ) { - for ( j = 0; j < 3; j++ ) { + for (f = b->brush_faces; f; f = f->next) { + for (i = 0; i < 3; i++) { + if (f->plane.Normal()[i] >= 0.999f) { + for (j = 0; j < 3; j++) { f->planepts[j][i] = vMax[i]; } break; } - if ( f->plane.Normal()[i] <= -0.999f ) { - for ( j = 0; j < 3; j++ ) { + if (f->plane.Normal()[i] <= -0.999f) { + for (j = 0; j < 3; j++) { f->planepts[j][i] = vMin[i]; } break; @@ -3455,7 +3602,7 @@ void Brush_Resize( brush_t *b, idVec3 vMin, idVec3 vMax ) { //assert( i < 3 ); } - Brush_Build( b, true ); + Brush_Build(b, true); } /* @@ -3463,7 +3610,7 @@ void Brush_Resize( brush_t *b, idVec3 vMin, idVec3 vMax ) { HasModel ================ */ -eclass_t *HasModel(brush_t *b) { +eclass_t* HasModel(brush_t* b) { idVec3 vMin, vMax; vMin[0] = vMin[1] = vMin[2] = 999999; vMax[0] = vMax[1] = vMax[2] = -999999; @@ -3476,11 +3623,11 @@ eclass_t *HasModel(brush_t *b) { return b->owner->eclass; } - eclass_t *e = NULL; + eclass_t* e = NULL; // FIXME: entity needs to track whether a cache hit failed and not ask again if (b->owner->eclass->nShowFlags & ECLASS_MISCMODEL) { - const char *pModel = ValueForKey(b->owner, "model"); + const char* pModel = ValueForKey(b->owner, "model"); if (pModel != NULL && strlen(pModel) > 0) { e = GetCachedModel(b->owner, pModel, vMin, vMax); if (e != NULL) { @@ -3507,23 +3654,23 @@ eclass_t *HasModel(brush_t *b) { Entity_GetRotationMatrixAngles ================ */ -bool Entity_GetRotationMatrixAngles( entity_t *e, idMat3 &mat, idAngles &angles ) { +bool Entity_GetRotationMatrixAngles(entity_t* e, idMat3& mat, idAngles& angles) { int angle; /* the angle keyword is a yaw value, except for two special markers */ - if ( GetMatrixForKey( e, "rotation", mat ) ) { + if (GetMatrixForKey(e, "rotation", mat)) { angles = mat.ToAngles(); return true; } - else if ( e->epairs.GetInt( "angle", "0", angle ) ) { - if ( angle == -1 ) { // up - angles.Set( 270, 0, 0 ); + else if (e->epairs.GetInt("angle", "0", angle)) { + if (angle == -1) { // up + angles.Set(270, 0, 0); } - else if ( angle == -2 ) { // down - angles.Set( 90, 0, 0 ); + else if (angle == -2) { // down + angles.Set(90, 0, 0); } else { - angles.Set( 0, angle, 0 ); + angles.Set(0, angle, 0); } mat = angles.ToMat3(); return true; @@ -3540,12 +3687,12 @@ bool Entity_GetRotationMatrixAngles( entity_t *e, idMat3 &mat, idAngles &angles FacingVectors ================ */ -static void FacingVectors(entity_t *e, idVec3 &forward, idVec3 &right, idVec3 &up) { +static void FacingVectors(entity_t* e, idVec3& forward, idVec3& right, idVec3& up) { idAngles angles; idMat3 mat; Entity_GetRotationMatrixAngles(e, mat, angles); - angles.ToVectors( &forward, &right, &up); + angles.ToVectors(&forward, &right, &up); } /* @@ -3553,7 +3700,7 @@ static void FacingVectors(entity_t *e, idVec3 &forward, idVec3 &right, idVec3 &u Brush_DrawFacingAngle ================ */ -void Brush_DrawFacingAngle( brush_t *b, entity_t *e, bool particle ) { +void Brush_DrawFacingAngle(brush_t* b, entity_t* e, bool particle) { idVec3 forward, right, up; idVec3 endpoint, tip1, tip2; idVec3 start; @@ -3564,12 +3711,12 @@ void Brush_DrawFacingAngle( brush_t *b, entity_t *e, bool particle ) { dist = (b->maxs[0] - start[0]) * 2.5f; FacingVectors(e, forward, right, up); - VectorMA(start, dist, ( particle ) ? up : forward, endpoint); + VectorMA(start, dist, (particle) ? up : forward, endpoint); dist = (b->maxs[0] - start[0]) * 0.5f; - VectorMA(endpoint, -dist, ( particle ) ? up : forward, tip1); - VectorMA(tip1, -dist, ( particle ) ? forward : up, tip1); - VectorMA(tip1, 2 * dist, ( particle ) ? forward : up, tip2); + VectorMA(endpoint, -dist, (particle) ? up : forward, tip1); + VectorMA(tip1, -dist, (particle) ? forward : up, tip1); + VectorMA(tip1, 2 * dist, (particle) ? forward : up, tip2); globalImages->BindNull(); glColor4f(1, 1, 1, 1); glLineWidth(2); @@ -3589,7 +3736,7 @@ void Brush_DrawFacingAngle( brush_t *b, entity_t *e, bool particle ) { DrawProjectedLight ================ */ -void DrawProjectedLight(brush_t *b, bool bSelected, bool texture) { +void DrawProjectedLight(brush_t* b, bool bSelected, bool texture) { int i; idVec3 v1, v2, cross, vieworg, edge[8][2], v[4]; idVec3 target, start; @@ -3601,17 +3748,17 @@ void DrawProjectedLight(brush_t *b, bool bSelected, bool texture) { // use the renderer to get the volume outline idPlane lightProject[4]; idPlane planes[6]; - srfTriangles_t *tri; + srfTriangles_t* tri; // use the game's epair parsing code so // we can use the same renderLight generation - entity_t *ent = b->owner; + entity_t* ent = b->owner; idDict spawnArgs; renderLight_t parms; spawnArgs = ent->epairs; - gameEdit->ParseSpawnArgsToRenderLight( &spawnArgs, &parms ); - R_RenderLightFrustum( parms, planes ); + gameEdit->ParseSpawnArgsToRenderLight(&spawnArgs, &parms); + R_RenderLightFrustum(parms, planes); tri = R_PolytopeSurface(6, planes, NULL); @@ -3628,7 +3775,7 @@ void DrawProjectedLight(brush_t *b, bool bSelected, bool texture) { // draw different selection points for point lights or projected // lights (FIXME: rotate these based on parms!) - if ( !bSelected ) { + if (!bSelected) { return; } @@ -3638,11 +3785,11 @@ void DrawProjectedLight(brush_t *b, bool bSelected, bool texture) { transform = GetMatrixForKey(b->owner, "rotation", mat); } idVec3 tv; - idVec3 *origin = (b->trackLightOrigin) ? &b->owner->lightOrigin : &b->owner->origin; + idVec3* origin = (b->trackLightOrigin) ? &b->owner->lightOrigin : &b->owner->origin; if (b->pointLight) { - if ( b->lightCenter[0] || b->lightCenter[1] || b->lightCenter[2] ) { + if (b->lightCenter[0] || b->lightCenter[1] || b->lightCenter[2]) { glPointSize(8); - glColor3f( 1.0f, 0.4f, 0.8f ); + glColor3f(1.0f, 0.4f, 0.8f); glBegin(GL_POINTS); tv = b->lightCenter; if (transform) { @@ -3659,7 +3806,7 @@ void DrawProjectedLight(brush_t *b, bool bSelected, bool texture) { // projected light glPointSize(8); - glColor3f( 1.0f, 0.4f, 0.8f ); + glColor3f(1.0f, 0.4f, 0.8f); glBegin(GL_POINTS); tv = b->lightRight; if (transform) { @@ -3685,7 +3832,7 @@ void DrawProjectedLight(brush_t *b, bool bSelected, bool texture) { glEnd(); if (b->startEnd) { - glColor3f( 0.4f, 1.0f, 0.8f ); + glColor3f(0.4f, 1.0f, 0.8f); glBegin(GL_POINTS); glVertex3fv(b->lightStart.ToFloatPtr()); glVertex3fv(b->lightEnd.ToFloatPtr()); @@ -3700,11 +3847,11 @@ void DrawProjectedLight(brush_t *b, bool bSelected, bool texture) { GLCircle ================ */ -void GLCircle(float x, float y, float z, float r) -{ - float ix = 0; - float iy = r; - float ig = 3 - 2 * r; +void GLCircle(float x, float y, float z, float r) +{ + float ix = 0; + float iy = r; + float ig = 3 - 2 * r; float idgr = -6; float idgd = 4 * r - 10; glPointSize(0.5f); @@ -3714,7 +3861,8 @@ void GLCircle(float x, float y, float z, float r) ig += idgd; idgd -= 8; iy--; - } else { + } + else { ig += idgr; idgd -= 4; } @@ -3730,40 +3878,40 @@ void GLCircle(float x, float y, float z, float r) glVertex3f(x - iy, y - ix, z); } glEnd(); -} +} /* ================ DrawSpeaker ================ */ -void DrawSpeaker(brush_t *b, bool bSelected, bool twoD) { +void DrawSpeaker(brush_t* b, bool bSelected, bool twoD) { if (!(g_qeglobals.d_savedinfo.showSoundAlways || (g_qeglobals.d_savedinfo.showSoundWhenSelected && bSelected))) { return; } - + // convert to units ( inches ) - float min = FloatForKey(b->owner, "s_mindistance"); + float min = FloatForKey(b->owner, "s_mindistance"); float max = FloatForKey(b->owner, "s_maxdistance"); - const char *s = b->owner->epairs.GetString("s_shader"); + const char* s = b->owner->epairs.GetString("s_shader"); if (s && *s) { - const idSoundShader *shader = declManager->FindSound( s, false ); - if ( shader ) { - if ( !min ) { + const idSoundShader* shader = declManager->FindSound(s, false); + if (shader) { + if (!min) { min = shader->GetMinDistance(); } - if ( !max ) { + if (!max) { max = shader->GetMaxDistance(); } } - } + } if (min == 0 && max == 0) { return; } - + // convert from meters to doom units min *= METERS_TO_DOOM; @@ -3772,47 +3920,52 @@ void DrawSpeaker(brush_t *b, bool bSelected, bool twoD) { if (twoD) { if (bSelected) { glColor4f(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].x, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].y, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].z, .5); - } else { + } + else { glColor4f(b->owner->eclass->color.x, b->owner->eclass->color.y, b->owner->eclass->color.z, .5); } - glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); GLCircle(b->owner->origin.x, b->owner->origin.y, b->owner->origin.z, min); if (bSelected) { glColor4f(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].x, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].y, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].z, 1); - } else { + } + else { glColor4f(b->owner->eclass->color.x, b->owner->eclass->color.y, b->owner->eclass->color.z, 1); } GLCircle(b->owner->origin.x, b->owner->origin.y, b->owner->origin.z, max); - } else { + } + else { glPushMatrix(); - glTranslatef(b->owner->origin.x, b->owner->origin.y, b->owner->origin.z ); - glColor3f( 0.4f, 0.4f, 0.4f ); - glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); + glTranslatef(b->owner->origin.x, b->owner->origin.y, b->owner->origin.z); + glColor3f(0.4f, 0.4f, 0.4f); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); GLUquadricObj* qobj = gluNewQuadric(); gluSphere(qobj, min, 8, 8); - glColor3f( 0.8f, 0.8f, 0.8f ); + glColor3f(0.8f, 0.8f, 0.8f); gluSphere(qobj, max, 8, 8); glEnable(GL_BLEND); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); globalImages->BindNull(); if (bSelected) { - glColor4f( g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].x, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].y, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].z, 0.35f ); - } else { - glColor4f( b->owner->eclass->color.x, b->owner->eclass->color.y, b->owner->eclass->color.z, 0.35f ); + glColor4f(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].x, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].y, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].z, 0.35f); + } + else { + glColor4f(b->owner->eclass->color.x, b->owner->eclass->color.y, b->owner->eclass->color.z, 0.35f); } gluSphere(qobj, min, 8, 8); if (bSelected) { - glColor4f( g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].x, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].y, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].z, 0.1f ); - } else { - glColor4f( b->owner->eclass->color.x, b->owner->eclass->color.y, b->owner->eclass->color.z, 0.1f ); + glColor4f(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].x, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].y, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].z, 0.1f); + } + else { + glColor4f(b->owner->eclass->color.x, b->owner->eclass->color.y, b->owner->eclass->color.z, 0.1f); } gluSphere(qobj, max, 8, 8); gluDeleteQuadric(qobj); glPopMatrix(); } - + } /* @@ -3820,7 +3973,7 @@ void DrawSpeaker(brush_t *b, bool bSelected, bool twoD) { DrawLight ================ */ -void DrawLight(brush_t *b, bool bSelected) { +void DrawLight(brush_t* b, bool bSelected) { idVec3 vTriColor; bool bTriPaint = false; @@ -3913,15 +4066,15 @@ void DrawLight(brush_t *b, bool bSelected) { Control_Draw ================ */ -void Control_Draw(brush_t *b) { - face_t *face; +void Control_Draw(brush_t* b) { + face_t* face; int i, order; - qtexture_t *prev = 0; - idWinding *w; + qtexture_t* prev = 0; + idWinding* w; // guarantee the texture will be set first prev = NULL; - for ( face = b->brush_faces, order = 0; face; face = face->next, order++ ) { + for (face = b->brush_faces, order = 0; face; face = face->next, order++) { w = face->face_winding; if (!w) { continue; // freed face @@ -3930,7 +4083,7 @@ void Control_Draw(brush_t *b) { glColor4f(1, 1, .5, 1); glBegin(GL_QUADS); for (i = 0; i < w->GetNumPoints(); i++) { - glVertex3fv( (*w)[i].ToFloatPtr() ); + glVertex3fv((*w)[i].ToFloatPtr()); } glEnd(); @@ -3942,54 +4095,56 @@ void Control_Draw(brush_t *b) { Brush_DrawModel ================ */ -void Brush_DrawModel( brush_t *b, bool camera, bool bSelected ) { +void Brush_DrawModel(brush_t* b, bool camera, bool bSelected) { idMat3 axis; idAngles angles; int nDrawMode = g_pParentWnd->GetCamera()->Camera().draw_mode; - if ( camera && g_PrefsDlg.m_nEntityShowState != ENTITY_WIREFRAME && nDrawMode != cd_wire ) { - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + if (camera && g_PrefsDlg.m_nEntityShowState != ENTITY_WIREFRAME && nDrawMode != cd_wire) { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } else { - glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } - idRenderModel *model = b->modelHandle; - if ( model == NULL ) { + idRenderModel* model = b->modelHandle; + if (model == NULL) { model = b->owner->eclass->entityModel; } - if ( model ) { - idRenderModel *model2; + if (model) { + idRenderModel* model2; model2 = NULL; bool fixedBounds = false; - if ( model->IsDynamicModel() != DM_STATIC ) { - if ( dynamic_cast( model ) ) { - const char *classname = ValueForKey( b->owner, "classname" ); + if (model->IsDynamicModel() != DM_STATIC) { + if (dynamic_cast(model)) { + const char* classname = ValueForKey(b->owner, "classname"); if (stricmp(classname, "func_static") == 0) { classname = ValueForKey(b->owner, "animclass"); } - const char *anim = ValueForKey( b->owner, "anim" ); - int frame = IntForKey( b->owner, "frame" ) + 1; - if ( frame < 1 ) { + const char* anim = ValueForKey(b->owner, "anim"); + int frame = IntForKey(b->owner, "frame") + 1; + if (frame < 1) { frame = 1; } - if ( !anim || !anim[ 0 ] ) { + if (!anim || !anim[0]) { anim = "idle"; } - model2 = gameEdit->ANIM_CreateMeshForAnim( model, classname, anim, frame, false ); - } else if ( dynamic_cast( model ) || dynamic_cast( model ) ) { + model2 = gameEdit->ANIM_CreateMeshForAnim(model, classname, anim, frame, false); + } + else if (dynamic_cast(model) || dynamic_cast(model)) { fixedBounds = true; } - if ( !model2 ) { + if (!model2) { idBounds bounds; if (fixedBounds) { bounds.Zero(); bounds.ExpandSelf(12.0f); - } else { - bounds = model->Bounds( NULL ); + } + else { + bounds = model->Bounds(NULL); } idVec4 color; color.w = 1.0f; @@ -3997,74 +4152,76 @@ void Brush_DrawModel( brush_t *b, bool camera, bool bSelected ) { color.x = g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].x; color.y = g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].y; color.z = g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].z; - } else { + } + else { color.x = b->owner->eclass->color.x; color.y = b->owner->eclass->color.y; color.z = b->owner->eclass->color.z; } idVec3 center = bounds.GetCenter(); - glBox(color, b->owner->origin + center, bounds.GetRadius( center ) ); + glBox(color, b->owner->origin + center, bounds.GetRadius(center)); model = renderModelManager->DefaultModel(); - } else { + } + else { model = model2; } } - Entity_GetRotationMatrixAngles( b->owner, axis, angles ); + Entity_GetRotationMatrixAngles(b->owner, axis, angles); idVec4 colorSave; glGetFloatv(GL_CURRENT_COLOR, colorSave.ToFloatPtr()); - if ( bSelected ) { - glColor3fv( g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].ToFloatPtr() ); + if (bSelected) { + glColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].ToFloatPtr()); } - DrawRenderModel( model, b->owner->origin, axis, camera ); + DrawRenderModel(model, b->owner->origin, axis, camera); - glColor4fv( colorSave.ToFloatPtr() ); + glColor4fv(colorSave.ToFloatPtr()); - if ( bSelected && camera ) - { - //draw selection tints + if (bSelected && camera) + { + //draw selection tints /* - if ( camera && g_PrefsDlg.m_nEntityShowState != ENTITY_WIREFRAME ) { - glPolygonMode ( GL_FRONT_AND_BACK , GL_FILL ); - glColor3fv ( g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].ToFloatPtr () ); - glEnable ( GL_BLEND ); - glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - DrawRenderModel( model, b->owner->origin, axis, camera ); - } + if ( camera && g_PrefsDlg.m_nEntityShowState != ENTITY_WIREFRAME ) { + glPolygonMode ( GL_FRONT_AND_BACK , GL_FILL ); + glColor3fv ( g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].ToFloatPtr () ); + glEnable ( GL_BLEND ); + glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + DrawRenderModel( model, b->owner->origin, axis, camera ); + } */ - //draw white triangle outlines + //draw white triangle outlines globalImages->BindNull(); - glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); - glDisable( GL_BLEND ); - glDisable( GL_DEPTH_TEST ); - glColor3f( 1.0f, 1.0f, 1.0f ); - glPolygonOffset( 1.0f, 3.0f ); - DrawRenderModel( model, b->owner->origin, axis, false ); - glEnable( GL_DEPTH_TEST ); - } + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + glColor3f(1.0f, 1.0f, 1.0f); + glPolygonOffset(1.0f, 3.0f); + DrawRenderModel(model, b->owner->origin, axis, false); + glEnable(GL_DEPTH_TEST); + } - if ( model2 ) { + if (model2) { delete model2; model2 = NULL; } } - if ( bSelected && camera ) { - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + if (bSelected && camera) { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } - else if ( camera ) { + else if (camera) { globalImages->BindNull(); } - if ( g_bPatchShowBounds ) { - for ( face_t *face = b->brush_faces; face; face = face->next ) { + if (g_bPatchShowBounds) { + for (face_t* face = b->brush_faces; face; face = face->next) { // only draw polygons facing in a direction we care about - idWinding *w = face->face_winding; + idWinding* w = face->face_winding; if (!w) { continue; } @@ -4075,7 +4232,7 @@ void Brush_DrawModel( brush_t *b, bool camera, bool bSelected ) { // glBegin(GL_LINE_LOOP); for (int i = 0; i < w->GetNumPoints(); i++) { - glVertex3fv( (*w)[i].ToFloatPtr() ); + glVertex3fv((*w)[i].ToFloatPtr()); } glEnd(); } @@ -4088,7 +4245,7 @@ GLTransformedVertex ================ */ void GLTransformedVertex(float x, float y, float z, idMat3 mat, idVec3 origin, idVec3 color, float maxDist) { - idVec3 v(x,y,z); + idVec3 v(x, y, z); v -= origin; v *= mat; v += origin; @@ -4097,9 +4254,11 @@ void GLTransformedVertex(float x, float y, float z, idMat3 mat, idVec3 origin, i float max = n.Length() / maxDist; if (color.x) { color.x = max; - } else if (color.y) { + } + else if (color.y) { color.y = max; - } else { + } + else { color.z = max; } glColor3f(color.x, color.y, color.z); @@ -4120,20 +4279,20 @@ void GLTransformedCircle(int type, idVec3 origin, float r, idMat3 mat, float poi float cy = origin.y; float cz = origin.z; switch (type) { - case 0: - cx += r * cos((float)i); - cy += r * sin((float)i); - break; - case 1: - cx += r * cos((float)i); - cz += r * sin((float)i); - break; - case 2: - cy += r * sin((float)i); - cz += r * cos((float)i); - break; - default: - break; + case 0: + cx += r * cos((float)i); + cy += r * sin((float)i); + break; + case 1: + cx += r * cos((float)i); + cz += r * sin((float)i); + break; + case 2: + cy += r * sin((float)i); + cz += r * cos((float)i); + break; + default: + break; } GLTransformedVertex(cx, cy, cz, mat, origin, color, maxDist); } @@ -4145,18 +4304,19 @@ void GLTransformedCircle(int type, idVec3 origin, float r, idMat3 mat, float poi Brush_DrawAxis ================ */ -void Brush_DrawAxis(brush_t *b) { - if ( g_pParentWnd->ActiveXY()->RotateMode() && b->modelHandle ) { +void Brush_DrawAxis(brush_t* b) { + if (g_pParentWnd->ActiveXY()->RotateMode() && b->modelHandle) { bool matrix = false; idMat3 mat; float a, s, c; if (GetMatrixForKey(b->owner, "rotation", mat)) { matrix = true; - } else { + } + else { a = FloatForKey(b->owner, "angle"); if (a) { - s = sin( DEG2RAD( a ) ); - c = cos( DEG2RAD( a ) ); + s = sin(DEG2RAD(a)); + c = cos(DEG2RAD(a)); } else { s = c = 0; @@ -4189,11 +4349,12 @@ void Brush_DrawAxis(brush_t *b) { if (g_qeglobals.rotateAxis == 0) { wr = zr; type = 2; - } else if (g_qeglobals.rotateAxis == 1) { + } + else if (g_qeglobals.rotateAxis == 1) { wr = yr; type = 1; } - + if (g_qeglobals.flatRotation) { if (yr > wr) { wr = yr; @@ -4209,7 +4370,8 @@ void Brush_DrawAxis(brush_t *b) { if (t > wr) { wr = t; } - } else { + } + else { org = bo.GetCenter(); } idRotation rot(org, vec, 0); @@ -4224,7 +4386,7 @@ void Brush_DrawAxis(brush_t *b) { Brush_DrawModelInfo ================ */ -void Brush_DrawModelInfo(brush_t *b, bool selected) { +void Brush_DrawModelInfo(brush_t* b, bool selected) { if (b->modelHandle > 0) { GLfloat color[4]; glGetFloatv(GL_CURRENT_COLOR, &color[0]); @@ -4238,7 +4400,7 @@ void Brush_DrawModelInfo(brush_t *b, bool selected) { Brush_DrawModel(b, true, selected); glColor4fv(color); - if ( selected ) { + if (selected) { Brush_DrawAxis(b); } return; @@ -4250,19 +4412,20 @@ void Brush_DrawModelInfo(brush_t *b, bool selected) { Brush_DrawEmitter ================ */ -void Brush_DrawEmitter(brush_t *b, bool bSelected, bool cam) { - if ( !( b->owner->eclass->nShowFlags & ECLASS_PARTICLE ) ) { +void Brush_DrawEmitter(brush_t* b, bool bSelected, bool cam) { + if (!(b->owner->eclass->nShowFlags & ECLASS_PARTICLE)) { return; } - + if (bSelected) { glColor4f(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].x, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].y, g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].z, .5); - } else { + } + else { glColor4f(b->owner->eclass->color.x, b->owner->eclass->color.y, b->owner->eclass->color.z, .5); } - if ( cam ) { - Brush_DrawFacingAngle( b, b->owner, true ); + if (cam) { + Brush_DrawFacingAngle(b, b->owner, true); } } @@ -4271,45 +4434,46 @@ void Brush_DrawEmitter(brush_t *b, bool bSelected, bool cam) { Brush_DrawEnv ================ */ -void Brush_DrawEnv( brush_t *b, bool cameraView, bool bSelected ) { +void Brush_DrawEnv(brush_t* b, bool cameraView, bool bSelected) { idVec3 origin, newOrigin; idMat3 axis, newAxis; idAngles newAngles; bool poseIsSet; - idRenderModel *model = gameEdit->AF_CreateMesh( b->owner->epairs, origin, axis, poseIsSet ); + idRenderModel* model = gameEdit->AF_CreateMesh(b->owner->epairs, origin, axis, poseIsSet); - if ( !poseIsSet ) { - if ( Entity_GetRotationMatrixAngles( b->owner, newAxis, newAngles ) ) { + if (!poseIsSet) { + if (Entity_GetRotationMatrixAngles(b->owner, newAxis, newAngles)) { axis = newAxis; } - if ( b->owner->epairs.GetVector( "origin", "0 0 0", newOrigin ) ) { + if (b->owner->epairs.GetVector("origin", "0 0 0", newOrigin)) { origin = newOrigin; } } - if ( model ) { - if ( cameraView && g_PrefsDlg.m_nEntityShowState != ENTITY_WIREFRAME ) { - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + if (model) { + if (cameraView && g_PrefsDlg.m_nEntityShowState != ENTITY_WIREFRAME) { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } else { - glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } idVec4 colorSave; glGetFloatv(GL_CURRENT_COLOR, colorSave.ToFloatPtr()); - if ( bSelected ) { - glColor3fv( g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].ToFloatPtr() ); - } else { - glColor3f( 1.f, 1.f, 1.f ); + if (bSelected) { + glColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].ToFloatPtr()); } - DrawRenderModel( model, origin, axis, true ); + else { + glColor3f(1.f, 1.f, 1.f); + } + DrawRenderModel(model, origin, axis, true); globalImages->BindNull(); delete model; model = NULL; - glColor4fv( colorSave.ToFloatPtr() ); + glColor4fv(colorSave.ToFloatPtr()); } } @@ -4318,36 +4482,37 @@ void Brush_DrawEnv( brush_t *b, bool cameraView, bool bSelected ) { Brush_DrawCombatNode ================ */ -void Brush_DrawCombatNode( brush_t *b, bool cameraView, bool bSelected ) { - float min_dist = b->owner->epairs.GetFloat( "min" ); - float max_dist = b->owner->epairs.GetFloat( "max" ); - float fov = b->owner->epairs.GetFloat( "fov", "60" ); +void Brush_DrawCombatNode(brush_t* b, bool cameraView, bool bSelected) { + float min_dist = b->owner->epairs.GetFloat("min"); + float max_dist = b->owner->epairs.GetFloat("max"); + float fov = b->owner->epairs.GetFloat("fov", "60"); float yaw = b->owner->epairs.GetFloat("angle"); idVec3 offset = b->owner->epairs.GetVector("offset"); - idAngles leftang( 0.0f, yaw + fov * 0.5f - 90.0f, 0.0f ); + idAngles leftang(0.0f, yaw + fov * 0.5f - 90.0f, 0.0f); idVec3 cone_left = leftang.ToForward(); - idAngles rightang( 0.0f, yaw - fov * 0.5f + 90.0f, 0.0f ); + idAngles rightang(0.0f, yaw - fov * 0.5f + 90.0f, 0.0f); idVec3 cone_right = rightang.ToForward(); - bool disabled = b->owner->epairs.GetBool( "start_off" ); + bool disabled = b->owner->epairs.GetBool("start_off"); idVec4 color; - if ( bSelected ) { + if (bSelected) { color = colorRed; - } else { + } + else { color = colorBlue; - } - - idVec3 leftDir( -cone_left.y, cone_left.x, 0.0f ); - idVec3 rightDir( cone_right.y, -cone_right.x, 0.0f ); + } + + idVec3 leftDir(-cone_left.y, cone_left.x, 0.0f); + idVec3 rightDir(cone_right.y, -cone_right.x, 0.0f); leftDir.NormalizeFast(); rightDir.NormalizeFast(); idMat3 axis = idAngles(0, yaw, 0).ToMat3(); idVec3 org = b->owner->origin + offset; idVec3 entorg = b->owner->origin; - float cone_dot = cone_right * axis[ 1 ]; - if ( idMath::Fabs( cone_dot ) > 0.1 ) { + float cone_dot = cone_right * axis[1]; + if (idMath::Fabs(cone_dot) > 0.1) { idVec3 pt, pt1, pt2, pt3, pt4; float cone_dist = max_dist / cone_dot; pt1 = org + leftDir * min_dist; @@ -4356,30 +4521,30 @@ void Brush_DrawCombatNode( brush_t *b, bool cameraView, bool bSelected ) { pt4 = org + rightDir * min_dist; glColor4fv(color.ToFloatPtr()); glBegin(GL_LINE_STRIP); - glVertex3fv( pt1.ToFloatPtr()); - glVertex3fv( pt2.ToFloatPtr()); - glVertex3fv( pt3.ToFloatPtr()); - glVertex3fv( pt4.ToFloatPtr()); - glVertex3fv( pt1.ToFloatPtr()); + glVertex3fv(pt1.ToFloatPtr()); + glVertex3fv(pt2.ToFloatPtr()); + glVertex3fv(pt3.ToFloatPtr()); + glVertex3fv(pt4.ToFloatPtr()); + glVertex3fv(pt1.ToFloatPtr()); glEnd(); glColor4fv(colorGreen.ToFloatPtr()); glBegin(GL_LINE_STRIP); - glVertex3fv( entorg.ToFloatPtr()); + glVertex3fv(entorg.ToFloatPtr()); pt = (pt1 + pt4) * 0.5f; - glVertex3fv( pt.ToFloatPtr()); + glVertex3fv(pt.ToFloatPtr()); pt = (pt2 + pt3) * 0.5f; - glVertex3fv( pt.ToFloatPtr()); + glVertex3fv(pt.ToFloatPtr()); idVec3 tip = pt; idVec3 dir = ((pt1 + pt2) * 0.5f) - tip; dir.Normalize(); pt = tip + dir * 15.0f; - glVertex3fv( pt.ToFloatPtr()); - glVertex3fv( tip.ToFloatPtr()); + glVertex3fv(pt.ToFloatPtr()); + glVertex3fv(tip.ToFloatPtr()); dir = ((pt4 + pt3) * 0.5f) - tip; dir.Normalize(); pt = tip + dir * 15.0f; - glVertex3fv( pt.ToFloatPtr()); + glVertex3fv(pt.ToFloatPtr()); glEnd(); } @@ -4390,22 +4555,22 @@ void Brush_DrawCombatNode( brush_t *b, bool cameraView, bool bSelected ) { Brush_Draw ================ */ -void Brush_Draw(brush_t *b, bool bSelected) { - face_t *face; +void Brush_Draw(brush_t* b, bool bSelected) { + face_t* face; int i, order; - const idMaterial *prev = NULL; - idWinding *w; + const idMaterial* prev = NULL; + idWinding* w; bool model = false; // // (TTimo) NOTE: added by build 173, I check after pPlugEnt so it doesn't // interfere ? // - if ( b->hiddenBrush ) { + if (b->hiddenBrush) { return; } - Brush_DrawCurve( b, bSelected, true ); + Brush_DrawCurve(b, bSelected, true); if (b->pPatch) { Patch_DrawCam(b->pPatch, bSelected); @@ -4418,44 +4583,44 @@ void Brush_Draw(brush_t *b, bool bSelected) { Brush_DrawFacingAngle(b, b->owner, false); } - if ( b->owner->eclass->fixedsize ) { + if (b->owner->eclass->fixedsize) { - DrawSpeaker( b, bSelected, false ); + DrawSpeaker(b, bSelected, false); - if ( g_PrefsDlg.m_bNewLightDraw && (b->owner->eclass->nShowFlags & ECLASS_LIGHT) && !(b->modelHandle || b->entityModel) ) { - DrawLight( b, bSelected ); + if (g_PrefsDlg.m_bNewLightDraw && (b->owner->eclass->nShowFlags & ECLASS_LIGHT) && !(b->modelHandle || b->entityModel)) { + DrawLight(b, bSelected); return; } - if ( b->owner->eclass->nShowFlags & ECLASS_ENV ) { - Brush_DrawEnv( b, true, bSelected ); + if (b->owner->eclass->nShowFlags & ECLASS_ENV) { + Brush_DrawEnv(b, true, bSelected); } - if ( b->owner->eclass->nShowFlags & ECLASS_COMBATNODE ) { - Brush_DrawCombatNode( b, true, bSelected ); + if (b->owner->eclass->nShowFlags & ECLASS_COMBATNODE) { + Brush_DrawCombatNode(b, true, bSelected); } } if (!(b->owner && (b->owner->eclass->nShowFlags & ECLASS_WORLDSPAWN))) { - glColor4f( 1.0f, 0.0f, 0.0f, 0.8f ); + glColor4f(1.0f, 0.0f, 0.0f, 0.8f); glPointSize(4); glBegin(GL_POINTS); glVertex3fv(b->owner->origin.ToFloatPtr()); glEnd(); } - if ( b->owner->eclass->entityModel ) { - glColor3fv( b->owner->eclass->color.ToFloatPtr() ); - Brush_DrawModel( b, true, bSelected ); + if (b->owner->eclass->entityModel) { + glColor3fv(b->owner->eclass->color.ToFloatPtr()); + Brush_DrawModel(b, true, bSelected); return; } - Brush_DrawEmitter( b, bSelected, true ); + Brush_DrawEmitter(b, bSelected, true); - if ( b->modelHandle > 0 && !model ) { - Brush_DrawModelInfo( b, bSelected ); + if (b->modelHandle > 0 && !model) { + Brush_DrawModelInfo(b, bSelected); return; } @@ -4485,7 +4650,7 @@ void Brush_Draw(brush_t *b, bool bSelected) { } } - if ( (nDrawMode == cd_texture || nDrawMode == cd_light) && face->d_texture != prev && !b->forceWireFrame ) { + if ((nDrawMode == cd_texture || nDrawMode == cd_light) && face->d_texture != prev && !b->forceWireFrame) { // set the texture for this face prev = face->d_texture; face->d_texture->GetEditorImage()->Bind(); @@ -4494,19 +4659,20 @@ void Brush_Draw(brush_t *b, bool bSelected) { if (model) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f( face->d_color.x, face->d_color.y, face->d_color.z, 0.1f ); - } else { - glColor4f( face->d_color.x, face->d_color.y, face->d_color.z, face->d_texture->GetEditorAlpha() ); + glColor4f(face->d_color.x, face->d_color.y, face->d_color.z, 0.1f); + } + else { + glColor4f(face->d_color.x, face->d_color.y, face->d_color.z, face->d_texture->GetEditorAlpha()); } glBegin(GL_QUADS); for (i = 0; i < w->GetNumPoints(); i++) { - if ( !b->forceWireFrame && ( nDrawMode == cd_texture || nDrawMode == cd_light ) ) { - glTexCoord2fv( &(*w)[i][3] ); + if (!b->forceWireFrame && (nDrawMode == cd_texture || nDrawMode == cd_light)) { + glTexCoord2fv(&(*w)[i][3]); } - glVertex3fv( (*w)[i].ToFloatPtr() ); + glVertex3fv((*w)[i].ToFloatPtr()); } glEnd(); @@ -4524,7 +4690,7 @@ void Brush_Draw(brush_t *b, bool bSelected) { Face_Draw ================ */ -void Face_Draw(face_t *f) { +void Face_Draw(face_t* f) { int i; if (f->face_winding == NULL) { @@ -4533,41 +4699,42 @@ void Face_Draw(face_t *f) { glBegin(GL_QUADS); for (i = 0; i < f->face_winding->GetNumPoints(); i++) { - glVertex3fv( (*f->face_winding)[i].ToFloatPtr() ); + glVertex3fv((*f->face_winding)[i].ToFloatPtr()); } glEnd(); } -idSurface_SweptSpline *SplineToSweptSpline( idCurve *curve ) { +idSurface_SweptSpline* SplineToSweptSpline(idCurve* curve) { // expects a vec3 curve and creates a vec4 based swept spline // must be either nurbs or catmull - idCurve_Spline *newCurve = NULL; - if ( dynamic_cast*>( curve ) ) { + idCurve_Spline* newCurve = NULL; + if (dynamic_cast*>(curve)) { newCurve = new idCurve_NURBS; - } else if ( dynamic_cast*>( curve ) ) { + } + else if (dynamic_cast*>(curve)) { newCurve = new idCurve_CatmullRomSpline; } - if ( curve == NULL || newCurve == NULL ) { + if (curve == NULL || newCurve == NULL) { return NULL; } int c = curve->GetNumValues(); float len = 0.0f; - for ( int i = 0; i < c; i++ ) { - idVec3 v = curve->GetValue( i ); - newCurve->AddValue( curve->GetTime( i ), idVec4( v.x, v.y, v.z, len ) ); - if ( i < c - 1 ) { - len += curve->GetLengthBetweenKnots( i, i + 1 ) * 0.1f; + for (int i = 0; i < c; i++) { + idVec3 v = curve->GetValue(i); + newCurve->AddValue(curve->GetTime(i), idVec4(v.x, v.y, v.z, len)); + if (i < c - 1) { + len += curve->GetLengthBetweenKnots(i, i + 1) * 0.1f; } } - idSurface_SweptSpline *ss = new idSurface_SweptSpline; - ss->SetSpline( newCurve ); - ss->SetSweptCircle( 10.0f ); - ss->Tessellate( newCurve->GetNumValues() * 6, 6 ); + idSurface_SweptSpline* ss = new idSurface_SweptSpline; + ss->SetSpline(newCurve); + ss->SetSweptCircle(10.0f); + ss->Tessellate(newCurve->GetNumValues() * 6, 6); return ss; } @@ -4577,86 +4744,87 @@ idSurface_SweptSpline *SplineToSweptSpline( idCurve *curve ) { Brush_DrawCurve ================ */ -void Brush_DrawCurve( brush_t *b, bool bSelected, bool cam ) { - if ( b == NULL || b->owner->curve == NULL ) { +void Brush_DrawCurve(brush_t* b, bool bSelected, bool cam) { + if (b == NULL || b->owner->curve == NULL) { return; } int maxage = b->owner->curve->GetNumValues(); int i, time = 0; - glColor3f( 0.0f, 0.0f, 1.0f ); - for ( i = 0; i < maxage; i++) { + glColor3f(0.0f, 0.0f, 1.0f); + for (i = 0; i < maxage; i++) { - if ( bSelected && g_qeglobals.d_select_mode == sel_editpoint ) { - idVec3 v = b->owner->curve->GetValue( i ); - if ( cam ) { - glBox( colorBlue, v, 6.0f ); - if ( PointInMoveList( b->owner->curve->GetValueAddress( i ) ) >= 0 ) { - glBox(colorBlue, v, 8.0f ); + if (bSelected && g_qeglobals.d_select_mode == sel_editpoint) { + idVec3 v = b->owner->curve->GetValue(i); + if (cam) { + glBox(colorBlue, v, 6.0f); + if (PointInMoveList(b->owner->curve->GetValueAddress(i)) >= 0) { + glBox(colorBlue, v, 8.0f); } - } else { - glPointSize( 4.0f ); - glBegin( GL_POINTS ); - glVertex3f( v.x, v.y, v.z ); + } + else { + glPointSize(4.0f); + glBegin(GL_POINTS); + glVertex3f(v.x, v.y, v.z); glEnd(); - if ( PointInMoveList( b->owner->curve->GetValueAddress( i ) ) >= 0 ) { - glBox(colorBlue, v, 4.0f ); + if (PointInMoveList(b->owner->curve->GetValueAddress(i)) >= 0) { + glBox(colorBlue, v, 4.0f); } } } -/* - if ( cam ) { - idSurface_SweptSpline *ss = SplineToSweptSpline( b->owner->curve ); - if ( ss ) { - idMaterial *mat = declManager->FindMaterial( "_default" ); - mat->GetEditorImage()->Bind(); - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - glBegin( GL_TRIANGLES ); - const int *indexes = ss->GetIndexes(); - const idDrawVert *verts = ss->GetVertices(); - for ( j = 0; j < ss->GetNumIndexes(); j += 3 ) { - for ( k = 0; k < 3; k++ ) { - int index = indexes[ j + 2 - k ]; - float f = ShadeForNormal( verts[index].normal ); - glColor3f( f, f, f ); - glTexCoord2fv( verts[index].st.ToFloatPtr() ); - glVertex3fv( verts[index].xyz.ToFloatPtr() ); + /* + if ( cam ) { + idSurface_SweptSpline *ss = SplineToSweptSpline( b->owner->curve ); + if ( ss ) { + idMaterial *mat = declManager->FindMaterial( "_default" ); + mat->GetEditorImage()->Bind(); + glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + glBegin( GL_TRIANGLES ); + const int *indexes = ss->GetIndexes(); + const idDrawVert *verts = ss->GetVertices(); + for ( j = 0; j < ss->GetNumIndexes(); j += 3 ) { + for ( k = 0; k < 3; k++ ) { + int index = indexes[ j + 2 - k ]; + float f = ShadeForNormal( verts[index].normal ); + glColor3f( f, f, f ); + glTexCoord2fv( verts[index].st.ToFloatPtr() ); + glVertex3fv( verts[index].xyz.ToFloatPtr() ); + } + } + glEnd(); + delete ss; } - } - glEnd(); - delete ss; - } - } else { -*/ -/* glPointSize( 1.0f ); - glBegin( GL_POINTS ); - if ( i + 1 < maxage ) { - int start = b->owner->curve->GetTime( i ); - int end = b->owner->curve->GetTime( i + 1 ); - int inc = (end - start) / POINTS_PER_KNOT; - for ( int j = 0; j < POINTS_PER_KNOT; j++ ) { - idVec3 v = b->owner->curve->GetCurrentValue( start ); - glVertex3f( v.x, v.y, v.z ); - start += inc; - } - }*/ - // DHM - _D3XP : Makes it easier to see curve - glBegin( GL_LINE_STRIP ); - if ( i + 1 < maxage ) { - int start = b->owner->curve->GetTime( i ); - int end = b->owner->curve->GetTime( i + 1 ); + } else { + */ + /* glPointSize( 1.0f ); + glBegin( GL_POINTS ); + if ( i + 1 < maxage ) { + int start = b->owner->curve->GetTime( i ); + int end = b->owner->curve->GetTime( i + 1 ); + int inc = (end - start) / POINTS_PER_KNOT; + for ( int j = 0; j < POINTS_PER_KNOT; j++ ) { + idVec3 v = b->owner->curve->GetCurrentValue( start ); + glVertex3f( v.x, v.y, v.z ); + start += inc; + } + }*/ + // DHM - _D3XP : Makes it easier to see curve + glBegin(GL_LINE_STRIP); + if (i + 1 < maxage) { + int start = b->owner->curve->GetTime(i); + int end = b->owner->curve->GetTime(i + 1); int inc = (end - start) / POINTS_PER_KNOT; - for ( int j = 0; j <= POINTS_PER_KNOT; j++ ) { - idVec3 v = b->owner->curve->GetCurrentValue( start ); - glVertex3f( v.x, v.y, v.z ); - start += inc; + for (int j = 0; j <= POINTS_PER_KNOT; j++) { + idVec3 v = b->owner->curve->GetCurrentValue(start); + glVertex3f(v.x, v.y, v.z); + start += inc; } - } - glEnd(); -/* } -*/ + glEnd(); + /* + } + */ } glPointSize(1); @@ -4667,13 +4835,13 @@ void Brush_DrawCurve( brush_t *b, bool bSelected, bool cam ) { Brush_DrawXY ================ */ -void Brush_DrawXY(brush_t *b, int nViewType, bool bSelected, bool ignoreViewType) { - face_t *face; +void Brush_DrawXY(brush_t* b, int nViewType, bool bSelected, bool ignoreViewType) { + face_t* face; int order; - idWinding *w; + idWinding* w; int i; - if ( b->hiddenBrush ) { + if (b->hiddenBrush) { return; } @@ -4681,14 +4849,14 @@ void Brush_DrawXY(brush_t *b, int nViewType, bool bSelected, bool ignoreViewType glGetFloatv(GL_CURRENT_COLOR, colorSave.ToFloatPtr()); if (!(b->owner && (b->owner->eclass->nShowFlags & ECLASS_WORLDSPAWN))) { - glColor4f( 1.0f, 0.0f, 0.0f, 0.8f ); + glColor4f(1.0f, 0.0f, 0.0f, 0.8f); glPointSize(4); glBegin(GL_POINTS); glVertex3fv(b->owner->origin.ToFloatPtr()); glEnd(); } - Brush_DrawCurve( b, bSelected, false ); + Brush_DrawCurve(b, bSelected, false); glColor4fv(colorSave.ToFloatPtr()); @@ -4702,7 +4870,7 @@ void Brush_DrawXY(brush_t *b, int nViewType, bool bSelected, bool ignoreViewType if (b->owner->eclass->fixedsize) { - DrawSpeaker(b, bSelected, true); + DrawSpeaker(b, bSelected, true); if (g_PrefsDlg.m_bNewLightDraw && (b->owner->eclass->nShowFlags & ECLASS_LIGHT) && !(b->modelHandle || b->entityModel)) { idVec3 vCorners[4]; float fMid = b->mins[2] + (b->maxs[2] - b->mins[2]) / 2; @@ -4752,19 +4920,22 @@ void Brush_DrawXY(brush_t *b, int nViewType, bool bSelected, bool ignoreViewType DrawBrushEntityName(b); DrawProjectedLight(b, bSelected, false); return; - } else if (b->owner->eclass->nShowFlags & ECLASS_MISCMODEL) { + } + else if (b->owner->eclass->nShowFlags & ECLASS_MISCMODEL) { // if (PaintedModel(b, false)) return; - } else if (b->owner->eclass->nShowFlags & ECLASS_ENV) { - Brush_DrawEnv( b, false, bSelected ); - } else if (b->owner->eclass->nShowFlags & ECLASS_COMBATNODE) { + } + else if (b->owner->eclass->nShowFlags & ECLASS_ENV) { + Brush_DrawEnv(b, false, bSelected); + } + else if (b->owner->eclass->nShowFlags & ECLASS_COMBATNODE) { Brush_DrawCombatNode(b, false, bSelected); } if (b->owner->eclass->entityModel) { - Brush_DrawModel( b, false, bSelected ); + Brush_DrawModel(b, false, bSelected); DrawBrushEntityName(b); glColor4fv(colorSave.ToFloatPtr()); - return; + return; } } @@ -4772,7 +4943,7 @@ void Brush_DrawXY(brush_t *b, int nViewType, bool bSelected, bool ignoreViewType glColor4fv(colorSave.ToFloatPtr()); if (b->modelHandle > 0) { - Brush_DrawEmitter( b, bSelected, false ); + Brush_DrawEmitter(b, bSelected, false); Brush_DrawModel(b, false, bSelected); glColor4fv(colorSave.ToFloatPtr()); return; @@ -4785,12 +4956,14 @@ void Brush_DrawXY(brush_t *b, int nViewType, bool bSelected, bool ignoreViewType if (face->plane[2] <= 0) { continue; } - } else { + } + else { if (nViewType == XZ) { if (face->plane[1] <= 0) { continue; } - } else { + } + else { if (face->plane[0] <= 0) { continue; } @@ -4809,14 +4982,14 @@ void Brush_DrawXY(brush_t *b, int nViewType, bool bSelected, bool ignoreViewType // glBegin(GL_LINE_LOOP); for (i = 0; i < w->GetNumPoints(); i++) { - glVertex3fv( (*w)[i].ToFloatPtr() ); + glVertex3fv((*w)[i].ToFloatPtr()); } glEnd(); -/* - for (i = 0; i < 3; i++) { - glLabeledPoint(idVec4(1, 0, 0, 1), face->planepts[i], 3, va("%i", i)); - } -*/ + /* + for (i = 0; i < 3; i++) { + glLabeledPoint(idVec4(1, 0, 0, 1), face->planepts[i], 3, va("%i", i)); + } + */ } DrawBrushEntityName(b); @@ -4827,9 +5000,9 @@ void Brush_DrawXY(brush_t *b, int nViewType, bool bSelected, bool ignoreViewType PointValueInPointList ================== */ -static int PointValueInPointList( idVec3 v ) { - for ( int i = 0; i < g_qeglobals.d_numpoints; i++ ) { - if ( v == g_qeglobals.d_points[i] ) { +static int PointValueInPointList(idVec3 v) { + for (int i = 0; i < g_qeglobals.d_numpoints; i++) { + if (v == g_qeglobals.d_points[i]) { return i; } } @@ -4843,9 +5016,9 @@ extern bool Sys_KeyDown(int key); Brush_Move ================ */ -void Brush_Move(brush_t *b, const idVec3 move, bool bSnap, bool updateOrigin) { +void Brush_Move(brush_t* b, const idVec3 move, bool bSnap, bool updateOrigin) { int i; - face_t *f; + face_t* f; char text[128]; for (f = b->brush_faces; f; f = f->next) { @@ -4868,63 +5041,65 @@ void Brush_Move(brush_t *b, const idVec3 move, bool bSnap, bool updateOrigin) { Patch_Move(b->pPatch, move); } - if ( b->owner->curve ) { - b->owner->curve->Translate( move ); - Entity_UpdateCurveData( b->owner ); + if (b->owner->curve) { + b->owner->curve->Translate(move); + Entity_UpdateCurveData(b->owner); } idVec3 temp; // PGM - keep the origin vector up to date on fixed size entities. if (b->owner->eclass->fixedsize || EntityHasModel(b->owner) || (updateOrigin && GetVectorForKey(b->owner, "origin", temp))) { -// if (!b->entityModel) { - bool adjustOrigin = true; - if(b->trackLightOrigin) { - b->owner->lightOrigin += move; - sprintf(text, "%i %i %i", (int)b->owner->lightOrigin[0], (int)b->owner->lightOrigin[1], (int)b->owner->lightOrigin[2]); - SetKeyValue(b->owner, "light_origin", text); - if (QE_SingleBrush(true, true)) { - adjustOrigin = false; - } - } - - if (adjustOrigin && updateOrigin) { - b->owner->origin += move; - if (g_moveOnly) { - sprintf(text, "%g %g %g", b->owner->origin[0], b->owner->origin[1], b->owner->origin[2]); - } else { - sprintf(text, "%i %i %i", (int)b->owner->origin[0], (int)b->owner->origin[1], (int)b->owner->origin[2]); - } - SetKeyValue(b->owner, "origin", text); + // if (!b->entityModel) { + bool adjustOrigin = true; + if (b->trackLightOrigin) { + b->owner->lightOrigin += move; + sprintf(text, "%i %i %i", (int)b->owner->lightOrigin[0], (int)b->owner->lightOrigin[1], (int)b->owner->lightOrigin[2]); + SetKeyValue(b->owner, "light_origin", text); + if (QE_SingleBrush(true, true)) { + adjustOrigin = false; } + } - // rebuild the light dragging points now that the origin has changed - idVec3 offset; + if (adjustOrigin && updateOrigin) { + b->owner->origin += move; + if (g_moveOnly) { + sprintf(text, "%g %g %g", b->owner->origin[0], b->owner->origin[1], b->owner->origin[2]); + } + else { + sprintf(text, "%i %i %i", (int)b->owner->origin[0], (int)b->owner->origin[1], (int)b->owner->origin[2]); + } + SetKeyValue(b->owner, "origin", text); + } + + // rebuild the light dragging points now that the origin has changed + idVec3 offset; + offset.Zero(); + if (controlDown) { + offset.x = -move.x; + offset.y = -move.y; + offset.z = -move.z; + Brush_UpdateLightPoints(b, offset); + } + else { offset.Zero(); - if (controlDown) { - offset.x = -move.x; - offset.y = -move.y; - offset.z = -move.z; - Brush_UpdateLightPoints(b, offset); - } else { - offset.Zero(); - Brush_UpdateLightPoints(b, offset); - } + Brush_UpdateLightPoints(b, offset); + } //} if (b->owner->eclass->nShowFlags & ECLASS_ENV) { - const idKeyValue *arg = b->owner->epairs.MatchPrefix( "body ", NULL ); + const idKeyValue* arg = b->owner->epairs.MatchPrefix("body ", NULL); idStr val; idVec3 org; idAngles ang; - while ( arg ) { - sscanf( arg->GetValue(), "%f %f %f %f %f %f", &org.x, &org.y, &org.z, &ang.pitch, &ang.yaw, &ang.roll ); + while (arg) { + sscanf(arg->GetValue(), "%f %f %f %f %f %f", &org.x, &org.y, &org.z, &ang.pitch, &ang.yaw, &ang.roll); org += move; val = org.ToString(8); val += " "; val += ang.ToString(8); b->owner->epairs.Set(arg->GetKey(), val); - arg = b->owner->epairs.MatchPrefix( "body ", arg ); + arg = b->owner->epairs.MatchPrefix("body ", arg); } } } @@ -4940,7 +5115,7 @@ void Select_AddProjectedLight() { CString str; // if (!QE_SingleBrush ()) return; - brush_t *b = selected_brushes.next; + brush_t* b = selected_brushes.next; if (b->owner->eclass->nShowFlags & ECLASS_LIGHT) { vTemp[0] = vTemp[1] = 0; @@ -4966,9 +5141,9 @@ void Select_AddProjectedLight() { Brush_Print ================ */ -void Brush_Print(brush_t *b) { +void Brush_Print(brush_t* b) { int nFace = 0; - for (face_t * f = b->brush_faces; f; f = f->next) { + for (face_t* f = b->brush_faces; f; f = f->next) { common->Printf("Face %i\n", nFace++); common->Printf("%f %f %f\n", f->planepts[0][0], f->planepts[0][1], f->planepts[0][2]); common->Printf("%f %f %f\n", f->planepts[1][0], f->planepts[1][1], f->planepts[1][2]); @@ -4986,9 +5161,9 @@ Brush_MakeSidedCone void Brush_MakeSidedCone(int sides) { int i; idVec3 mins, maxs; - brush_t *b; - texdef_t *texdef; - face_t *f; + brush_t* b; + texdef_t* texdef; + face_t* f; idVec3 mid; float width; float sv, cv; @@ -5048,16 +5223,16 @@ void Brush_MakeSidedCone(int sides) { sv = sin(i * idMath::TWO_PI / sides); cv = cos(i * idMath::TWO_PI / sides); - f->planepts[0][0] = floor( mid[0] + width * cv + 0.5f ); - f->planepts[0][1] = floor( mid[1] + width * sv + 0.5f ); + f->planepts[0][0] = floor(mid[0] + width * cv + 0.5f); + f->planepts[0][1] = floor(mid[1] + width * sv + 0.5f); f->planepts[0][2] = mins[2]; f->planepts[1][0] = mid[0]; f->planepts[1][1] = mid[1]; f->planepts[1][2] = maxs[2]; - f->planepts[2][0] = floor( f->planepts[0][0] - width * sv + 0.5f ); - f->planepts[2][1] = floor( f->planepts[0][1] + width * cv + 0.5f ); + f->planepts[2][0] = floor(f->planepts[0][0] - width * sv + 0.5f); + f->planepts[2][1] = floor(f->planepts[0][1] + width * cv + 0.5f); f->planepts[2][2] = maxs[2]; } @@ -5080,9 +5255,9 @@ Brush_MakeSidedSphere void Brush_MakeSidedSphere(int sides) { int i, j; idVec3 mins, maxs; - brush_t *b; - texdef_t *texdef; - face_t *f; + brush_t* b; + texdef_t* texdef; + face_t* f; idVec3 mid; float radius; @@ -5105,7 +5280,7 @@ void Brush_MakeSidedSphere(int sides) { // find center of brush radius = 8; - for ( i = 0; i < 3; i++ ) { + for (i = 0; i < 3; i++) { mid[i] = (maxs[i] + mins[i]) * 0.5f; if (maxs[i] - mins[i] > radius) { radius = maxs[i] - mins[i]; @@ -5123,9 +5298,9 @@ void Brush_MakeSidedSphere(int sides) { f->next = b->brush_faces; b->brush_faces = f; - f->planepts[0] = idPolar3(radius, idMath::TWO_PI * i / sides, idMath::PI * ((float)(j) / sides - 0.5f) ).ToVec3() + mid; - f->planepts[1] = idPolar3(radius, idMath::TWO_PI * i / sides, idMath::PI * ((float)(j+1) / sides - 0.5f) ).ToVec3() + mid; - f->planepts[2] = idPolar3(radius, idMath::TWO_PI * (i+1) / sides, idMath::PI * ((float)(j+1) / sides - 0.5f) ).ToVec3() + mid; + f->planepts[0] = idPolar3(radius, idMath::TWO_PI * i / sides, idMath::PI * ((float)(j) / sides - 0.5f)).ToVec3() + mid; + f->planepts[1] = idPolar3(radius, idMath::TWO_PI * i / sides, idMath::PI * ((float)(j + 1) / sides - 0.5f)).ToVec3() + mid; + f->planepts[2] = idPolar3(radius, idMath::TWO_PI * (i + 1) / sides, idMath::PI * ((float)(j + 1) / sides - 0.5f)).ToVec3() + mid; } } @@ -5138,14 +5313,14 @@ void Brush_MakeSidedSphere(int sides) { Sys_UpdateWindows(W_ALL); } -extern void Face_FitTexture_BrushPrimit(face_t *f, idVec3 mins, idVec3 maxs, float nHeight, float nWidth); +extern void Face_FitTexture_BrushPrimit(face_t* f, idVec3 mins, idVec3 maxs, float nHeight, float nWidth); /* ================ Face_FitTexture ================ */ -void Face_FitTexture(face_t *face, float nHeight, float nWidth) { +void Face_FitTexture(face_t* face, float nHeight, float nWidth) { if (g_qeglobals.m_bBrushPrimitMode) { idVec3 mins, maxs; mins[0] = maxs[0] = 0; @@ -5194,27 +5369,27 @@ void Face_FitTexture(face_t *face, float nHeight, float nWidth) { Brush_FitTexture ================ */ -void Brush_FitTexture(brush_t *b, float nHeight, float nWidth) { - face_t *face; +void Brush_FitTexture(brush_t* b, float nHeight, float nWidth) { + face_t* face; for (face = b->brush_faces; face; face = face->next) { Face_FitTexture(face, nHeight, nWidth); } } -void Brush_GetBounds( brush_t *b, idBounds &bo ) { - if ( b == NULL ) { +void Brush_GetBounds(brush_t* b, idBounds& bo) { + if (b == NULL) { return; } bo.Clear(); - bo.AddPoint( b->mins ); - bo.AddPoint( b->maxs ); + bo.AddPoint(b->mins); + bo.AddPoint(b->maxs); - if ( b->owner->curve ) { + if (b->owner->curve) { int c = b->owner->curve->GetNumValues(); - for ( int i = 0; i < c; i++ ) { - bo.AddPoint ( b->owner->curve->GetValue( i ) ); + for (int i = 0; i < c; i++) { + bo.AddPoint(b->owner->curve->GetValue(i)); } - } + } } diff --git a/neo/engine/tools/radiant/EditorBrush.h b/neo/engine/tools/radiant/EditorBrush.h index 0265c7b5..85b04cfd 100644 --- a/neo/engine/tools/radiant/EditorBrush.h +++ b/neo/engine/tools/radiant/EditorBrush.h @@ -2,9 +2,9 @@ =========================================================================== IceTech GPL Source Code -Copyright (C) 2026 Justin Marshall +Copyright (C) 2026 Justin Marshall -This file is part of the IceTech GPL Source Code (?IceTech Source Code?). +This file is part of the IceTech GPL Source Code (?IceTech Source Code?). IceTech Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,52 +28,53 @@ If you have questions concerning this license or the applicable additional terms // brush.h -brush_t * Brush_Alloc(); -void Brush_Free (brush_t *b, bool bRemoveNode = true); -int Brush_MemorySize(brush_t *b); -void Brush_MakeSided (int sides); -void Brush_MakeSidedCone (int sides); -void Brush_Move (brush_t *b, const idVec3 move, bool bSnap = true, bool updateOrigin = true); -int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVec3 &end, bool bSnap); -void Brush_ResetFaceOriginals(brush_t *b); -brush_t * Brush_Parse (const idVec3 origin); -face_t * Brush_Ray (idVec3 origin, idVec3 dir, brush_t *b, float *dist, bool testPrimitive = false); -void Brush_RemoveFromList (brush_t *b); -void Brush_AddToList (brush_t *b, brush_t *list); -void Brush_Build(brush_t *b, bool bSnap = true, bool bMarkMap = true, bool bConvert = false, bool updateLights = true); -void Brush_BuildWindings( brush_t *b, bool bSnap = true, bool keepOnPlaneWinding = false, bool updateLights = true, bool makeFacePlanes = true ); -brush_t * Brush_Clone (brush_t *b); -brush_t * Brush_FullClone(brush_t *b); -brush_t * Brush_Create (idVec3 mins, idVec3 maxs, texdef_t *texdef); -void Brush_Draw( brush_t *b, bool bSelected = false); -void Brush_DrawXY(brush_t *b, int nViewType, bool bSelected = false, bool ignoreViewType = false); -void Brush_SplitBrushByFace (brush_t *in, face_t *f, brush_t **front, brush_t **back); -void Brush_SelectFaceForDragging (brush_t *b, face_t *f, bool shear); -void Brush_SetTexture (brush_t *b, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale = false); -void Brush_SideSelect (brush_t *b, idVec3 origin, idVec3 dir, bool shear); -void Brush_SnapToGrid(brush_t *pb); -void Brush_Rotate(brush_t *b, idVec3 vAngle, idVec3 vOrigin, bool bBuild = true); +brush_t* Brush_Alloc(); +void Brush_Free(brush_t* b, bool bRemoveNode = true); +int Brush_MemorySize(brush_t* b); +void Brush_MakeSided(int sides); +void Brush_MakeSidedCone(int sides); +void Brush_Move(brush_t* b, const idVec3 move, bool bSnap = true, bool updateOrigin = true); +int Brush_MoveVertex(brush_t* b, const idVec3& vertex, const idVec3& delta, idVec3& end, bool bSnap); +void Brush_ResetFaceOriginals(brush_t* b); +brush_t* Brush_Parse(const idVec3 origin); +face_t* Brush_Ray(idVec3 origin, idVec3 dir, brush_t* b, float* dist, bool testPrimitive = false); +void Brush_RemoveFromList(brush_t* b); +void Brush_AddToList(brush_t* b, brush_t* list); +void Brush_Build(brush_t* b, bool bSnap = true, bool bMarkMap = true, bool bConvert = false, bool updateLights = true); +void Brush_BuildWindings(brush_t* b, bool bSnap = true, bool keepOnPlaneWinding = false, bool updateLights = true, bool makeFacePlanes = true); +brush_t* Brush_Clone(brush_t* b); +brush_t* Brush_FullClone(brush_t* b); +brush_t* Brush_Create(idVec3 mins, idVec3 maxs, texdef_t* texdef); +brush_t* Brush_CreateFaceExtrusion(brush_t* sourceBrush, face_t* sourceFace, float distance); +void Brush_Draw(brush_t* b, bool bSelected = false); +void Brush_DrawXY(brush_t* b, int nViewType, bool bSelected = false, bool ignoreViewType = false); +void Brush_SplitBrushByFace(brush_t* in, face_t* f, brush_t** front, brush_t** back); +void Brush_SelectFaceForDragging(brush_t* b, face_t* f, bool shear); +void Brush_SetTexture(brush_t* b, texdef_t* texdef, brushprimit_texdef_t* brushprimit_texdef, bool bFitScale = false); +void Brush_SideSelect(brush_t* b, idVec3 origin, idVec3 dir, bool shear); +void Brush_SnapToGrid(brush_t* pb); +void Brush_Rotate(brush_t* b, idVec3 vAngle, idVec3 vOrigin, bool bBuild = true); void Brush_MakeSidedSphere(int sides); -void Brush_Write (brush_t *b, FILE *f, const idVec3 &origin, bool newFormat); -void Brush_Write (brush_t *b, CMemFile* pMemFile, const idVec3 &origin, bool NewFormat); -void Brush_RemoveEmptyFaces ( brush_t *b ); -idWinding * Brush_MakeFaceWinding (brush_t *b, face_t *face, bool keepOnPlaneWinding = false); -void Brush_SetTextureName(brush_t *b, const char *name); +void Brush_Write(brush_t* b, FILE* f, const idVec3& origin, bool newFormat); +void Brush_Write(brush_t* b, CMemFile* pMemFile, const idVec3& origin, bool NewFormat); +void Brush_RemoveEmptyFaces(brush_t* b); +idWinding* Brush_MakeFaceWinding(brush_t* b, face_t* face, bool keepOnPlaneWinding = false); +void Brush_SetTextureName(brush_t* b, const char* name); void Brush_Print(brush_t* b); -void Brush_FitTexture( brush_t *b, float height, float width ); -void Brush_SetEpair(brush_t *b, const char *pKey, const char *pValue); -const char *Brush_GetKeyValue(brush_t *b, const char *pKey); -const char *Brush_Name(brush_t *b); -void Brush_RebuildBrush(brush_t *b, idVec3 vMins, idVec3 vMaxs, bool patch = true); -void Brush_GetBounds( brush_t *b, idBounds &bo ); +void Brush_FitTexture(brush_t* b, float height, float width); +void Brush_SetEpair(brush_t* b, const char* pKey, const char* pValue); +const char* Brush_GetKeyValue(brush_t* b, const char* pKey); +const char* Brush_Name(brush_t* b); +void Brush_RebuildBrush(brush_t* b, idVec3 vMins, idVec3 vMaxs, bool patch = true); +void Brush_GetBounds(brush_t* b, idBounds& bo); -face_t * Face_Alloc( void ); -void Face_Free( face_t *f ); -face_t * Face_Clone (face_t *f); -void Face_MakePlane (face_t *f); -void Face_Draw( face_t *face ); -void Face_TextureVectors (face_t *f, float STfromXYZ[2][4]); -void Face_FitTexture( face_t * face, float height, float width ); -void SetFaceTexdef (brush_t *b, face_t *f, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale = false); +face_t* Face_Alloc(void); +void Face_Free(face_t* f); +face_t* Face_Clone(face_t* f); +void Face_MakePlane(face_t* f); +void Face_Draw(face_t* face); +void Face_TextureVectors(face_t* f, float STfromXYZ[2][4]); +void Face_FitTexture(face_t* face, float height, float width); +void SetFaceTexdef(brush_t* b, face_t* f, texdef_t* texdef, brushprimit_texdef_t* brushprimit_texdef, bool bFitScale = false); -int AddPlanept (idVec3 *f); +int AddPlanept(idVec3* f);