Added terrain editing tool.

This commit is contained in:
Justin Marshall
2026-05-28 17:15:52 -07:00
parent 05d547a27b
commit e4c87fd5a4
91 changed files with 21538 additions and 199 deletions
+4
View File
@@ -366,7 +366,11 @@ void Dmap( const idCmdArgs &args ) {
// create the collision map
start = Sys_Milliseconds();
#if defined(PREY) || defined(QUAKE4)
collisionModelManager->LoadMap( dmapGlobals.dmapFile );
#else
collisionModelManager->LoadMap( dmapGlobals.dmapFile, true );
#endif
#ifdef QUAKE4
collisionModelManager->FreeMap(NULL);
#else
+175 -2
View File
@@ -34,6 +34,7 @@ If you have questions concerning this license or the applicable additional terms
#include "EditorMap.h"
#include "XYWnd.h"
#include "CamWnd.h"
#include "Terrain.h"
#include "OutlinerDlg.h"
#include "splines.h"
#include <GL/glu.h>
@@ -1099,6 +1100,19 @@ static const char* CAMWND_PROP_DECAL_EDITING = "QER_CamWnd_DecalEditing";
#define CAMWND_MENU_CMD_DECAL_SCALE_DOWN 62112
#define CAMWND_MENU_CMD_DECAL_ROTATE_CCW 62113
#define CAMWND_MENU_CMD_DECAL_ROTATE_CW 62114
#define CAMWND_MENU_CMD_TERRAIN_EDITING 62115
#define CAMWND_MENU_CMD_TERRAIN_CREATE 62116
#define CAMWND_MENU_CMD_TERRAIN_RADIUS_UP 62117
#define CAMWND_MENU_CMD_TERRAIN_RADIUS_DOWN 62118
#define CAMWND_MENU_CMD_TERRAIN_STRENGTH_UP 62119
#define CAMWND_MENU_CMD_TERRAIN_STRENGTH_DOWN 62120
#define CAMWND_MENU_CMD_TERRAIN_LAYERS 62121
#define CAMWND_MENU_CMD_PAINT_MODE 62122
#define CAMWND_MENU_CMD_PAINT_LAYER_BASE 62123
#define CAMWND_MENU_CMD_PAINT_LAYER_1 62123
#define CAMWND_MENU_CMD_PAINT_LAYER_2 62124
#define CAMWND_MENU_CMD_PAINT_LAYER_3 62125
#define CAMWND_MENU_CMD_PAINT_LAYER_4 62126
#define CAMWND_FILTER_HIDE_WORLD 0x00000001
#define CAMWND_FILTER_HIDE_PATCHES 0x00000002
@@ -1198,15 +1212,23 @@ static void CamWnd_GetMenuItemRect(HWND hWnd, int item, RECT& rect) {
rect.left = 86;
rect.right = 156;
}
else {
else if (item == 2) {
rect.left = 156;
rect.right = 236;
}
else if (item == 3) {
rect.left = 236;
rect.right = 326;
}
else {
rect.left = 326;
rect.right = 396;
}
}
static int CamWnd_MenuHitTest(HWND hWnd, int x, int y) {
RECT rect;
for (int i = 0; i < 3; i++) {
for (int i = 0; i < 5; i++) {
CamWnd_GetMenuItemRect(hWnd, i, rect);
if (x >= rect.left && x < rect.right && y >= rect.top && y < rect.bottom) {
return i;
@@ -1373,7 +1395,24 @@ static void CamWnd_ToggleCubicClipping(CCamWnd* cam) {
}
}
static void CamWnd_SelectTerrainPaintLayer(CCamWnd* cam, int layer) {
if (Terrain_NumTerrains() <= 0) {
Sys_Status("Create a terrain before painting\n", 0);
return;
}
Terrain_SetEditMode(true);
Terrain_SetPaintMode(true);
Terrain_SelectPaintLayer(layer);
CamWnd_RequestRedraw(cam);
}
static void CamWnd_HandleMenuCommand(CCamWnd* cam, int command) {
if (command >= CAMWND_MENU_CMD_PAINT_LAYER_BASE && command < CAMWND_MENU_CMD_PAINT_LAYER_BASE + 4) {
CamWnd_SelectTerrainPaintLayer(cam, command - CAMWND_MENU_CMD_PAINT_LAYER_BASE);
return;
}
switch (command) {
case CAMWND_MENU_CMD_REALTIME_LIGHTING:
CamWnd_ToggleRealtimeLighting(cam);
@@ -1396,6 +1435,45 @@ static void CamWnd_HandleMenuCommand(CCamWnd* cam, int command) {
case CAMWND_MENU_CMD_DECAL_ROTATE_CW:
CamWnd_RotateStencil(cam, 15.0f);
break;
case CAMWND_MENU_CMD_TERRAIN_EDITING:
Terrain_ToggleEditMode();
CamWnd_RequestRedraw(cam);
break;
case CAMWND_MENU_CMD_TERRAIN_CREATE:
Terrain_CreateDefaultAtCamera(cam);
CamWnd_RequestRedraw(cam);
break;
case CAMWND_MENU_CMD_TERRAIN_LAYERS:
if (Terrain_ShowLayersDialog(cam)) {
CamWnd_RequestRedraw(cam);
}
break;
case CAMWND_MENU_CMD_TERRAIN_RADIUS_UP:
Terrain_AdjustBrushRadius(1.25f);
CamWnd_RequestRedraw(cam);
break;
case CAMWND_MENU_CMD_TERRAIN_RADIUS_DOWN:
Terrain_AdjustBrushRadius(0.8f);
CamWnd_RequestRedraw(cam);
break;
case CAMWND_MENU_CMD_TERRAIN_STRENGTH_UP:
Terrain_AdjustBrushStrength(1.25f);
CamWnd_RequestRedraw(cam);
break;
case CAMWND_MENU_CMD_TERRAIN_STRENGTH_DOWN:
Terrain_AdjustBrushStrength(0.8f);
CamWnd_RequestRedraw(cam);
break;
case CAMWND_MENU_CMD_PAINT_MODE:
if (Terrain_NumTerrains() > 0) {
Terrain_SetEditMode(true);
Terrain_SetPaintMode(true);
CamWnd_RequestRedraw(cam);
}
else {
Sys_Status("Create a terrain before painting\n", 0);
}
break;
case CAMWND_MENU_CMD_SHOW_WORLD:
CamWnd_ToggleFilterBit(cam, CAMWND_FILTER_HIDE_WORLD);
break;
@@ -1483,6 +1561,69 @@ static void CamWnd_ShowDecalsMenu(HWND hWnd, CCamWnd* cam) {
}
}
static void CamWnd_ShowTerrainMenu(HWND hWnd, CCamWnd* cam) {
RECT itemRect;
POINT pt;
HMENU menu;
int command;
CamWnd_GetMenuItemRect(hWnd, 3, itemRect);
pt.x = itemRect.left;
pt.y = itemRect.bottom;
ClientToScreen(hWnd, &pt);
menu = CreatePopupMenu();
AppendMenu(menu, MF_STRING | (Terrain_IsEditMode() ? MF_CHECKED : 0), CAMWND_MENU_CMD_TERRAIN_EDITING, "Enable terrain editing (T)");
AppendMenu(menu, MF_STRING, CAMWND_MENU_CMD_TERRAIN_CREATE, "Create default terrain (Ctrl+T)");
UINT terrainFlags = MF_STRING | (Terrain_NumTerrains() > 0 ? 0 : MF_GRAYED);
AppendMenu(menu, terrainFlags, CAMWND_MENU_CMD_TERRAIN_LAYERS, "Terrain layers...");
AppendMenu(menu, MF_SEPARATOR, 0, NULL);
UINT toolFlags = terrainFlags;
AppendMenu(menu, toolFlags, CAMWND_MENU_CMD_TERRAIN_RADIUS_UP, "Increase brush radius (])");
AppendMenu(menu, toolFlags, CAMWND_MENU_CMD_TERRAIN_RADIUS_DOWN, "Decrease brush radius ([)");
AppendMenu(menu, toolFlags, CAMWND_MENU_CMD_TERRAIN_STRENGTH_UP, "Increase brush strength (+)");
AppendMenu(menu, toolFlags, CAMWND_MENU_CMD_TERRAIN_STRENGTH_DOWN, "Decrease brush strength (-)");
command = TrackPopupMenu(menu, TPM_RETURNCMD | TPM_LEFTALIGN | TPM_TOPALIGN, pt.x, pt.y, 0, hWnd, NULL);
DestroyMenu(menu);
if (command) {
CamWnd_HandleMenuCommand(cam, command);
}
}
static void CamWnd_ShowPaintMenu(HWND hWnd, CCamWnd* cam) {
RECT itemRect;
POINT pt;
HMENU menu;
int command;
CamWnd_GetMenuItemRect(hWnd, 4, itemRect);
pt.x = itemRect.left;
pt.y = itemRect.bottom;
ClientToScreen(hWnd, &pt);
const bool hasTerrain = Terrain_NumTerrains() > 0;
const UINT paintFlags = MF_STRING | (hasTerrain ? 0 : MF_GRAYED);
menu = CreatePopupMenu();
AppendMenu(menu, paintFlags | (Terrain_IsEditMode() && Terrain_IsPaintMode() ? MF_CHECKED : 0), CAMWND_MENU_CMD_PAINT_MODE, "Paint mode (P)");
AppendMenu(menu, MF_SEPARATOR, 0, NULL);
for (int layer = 0; layer < 4; layer++) {
UINT layerFlags = paintFlags;
if (Terrain_GetPaintLayer() == layer) {
layerFlags |= MF_CHECKED;
}
AppendMenu(menu, layerFlags, CAMWND_MENU_CMD_PAINT_LAYER_BASE + layer, va("Paint layer %i (%i)", layer + 1, layer + 1));
}
command = TrackPopupMenu(menu, TPM_RETURNCMD | TPM_LEFTALIGN | TPM_TOPALIGN, pt.x, pt.y, 0, hWnd, NULL);
DestroyMenu(menu);
if (command) {
CamWnd_HandleMenuCommand(cam, command);
}
}
static void CamWnd_ShowFiltersMenu(HWND hWnd, CCamWnd* cam) {
RECT itemRect;
POINT pt;
@@ -1531,6 +1672,12 @@ static void CamWnd_ShowTopMenu(HWND hWnd, int item) {
else if (item == 2) {
CamWnd_ShowDecalsMenu(hWnd, cam);
}
else if (item == 3) {
CamWnd_ShowTerrainMenu(hWnd, cam);
}
else if (item == 4) {
CamWnd_ShowPaintMenu(hWnd, cam);
}
}
static void CamWnd_RegisterMenuBarClass() {
@@ -3096,6 +3243,12 @@ static LRESULT CALLBACK CamWnd_MenuBarProc(HWND hWnd, UINT uMsg, WPARAM wParam,
CamWnd_GetMenuItemRect(hWnd, 2, itemRect);
RoundRect(hDC, itemRect.left + 3, itemRect.top + 2, itemRect.right - 3, itemRect.bottom - 2, 6, 6);
DrawText(hDC, "Decals", -1, &itemRect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
CamWnd_GetMenuItemRect(hWnd, 3, itemRect);
RoundRect(hDC, itemRect.left + 3, itemRect.top + 2, itemRect.right - 3, itemRect.bottom - 2, 6, 6);
DrawText(hDC, "Terrain", -1, &itemRect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
CamWnd_GetMenuItemRect(hWnd, 4, itemRect);
RoundRect(hDC, itemRect.left + 3, itemRect.top + 2, itemRect.right - 3, itemRect.bottom - 2, 6, 6);
DrawText(hDC, "Paint", -1, &itemRect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
::SelectObject(hDC, oldPen);
::SelectObject(hDC, oldBrush);
::DeleteObject(borderPen);
@@ -3207,6 +3360,7 @@ INT_PTR WINAPI CamWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (cam) {
CamWnd_FaceExtrudeEnd(cam, false);
CamWnd_GizmoEnd(cam, false);
Terrain_CancelStroke();
CameraNav_Stop(cam);
}
SendMessage(hWnd, WM_NCACTIVATE, FALSE, 0);
@@ -3289,6 +3443,9 @@ void CCamWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
Map_DeleteSelectedDecal();
return;
}
if (Terrain_HandleKeyDown(this, nChar)) {
return;
}
if (CameraNav_HandleKeyDown(this, nChar)) {
return;
}
@@ -3303,6 +3460,9 @@ void CCamWnd::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) {
if (CamWnd_HandleDecalTransformChar(this, nChar)) {
return;
}
if (Terrain_HandleChar(this, nChar)) {
return;
}
CWnd::OnChar(nChar, nRepCnt, nFlags);
}
@@ -3347,6 +3507,7 @@ void CCamWnd::SetXYFriend(CXYWnd* pWnd) {
void CCamWnd::OnDestroy() {
CamWnd_FaceExtrudeEnd(this, false);
CamWnd_GizmoEnd(this, false);
Terrain_CancelStroke();
CamWnd_ClearDecalPreview(this);
CamWnd_DestroyMenuBar(this);
CWnd::OnDestroy();
@@ -3370,6 +3531,11 @@ void CCamWnd::OnMouseMove(UINT nFlags, CPoint point) {
CRect r;
GetClientRect(r);
if (Terrain_MouseMove(this, point, nFlags)) {
m_ptLastCursor = point;
return;
}
if (GetCapture() != this) {
CamWnd_UpdateDecalPreview(this, point);
}
@@ -3428,6 +3594,9 @@ void CCamWnd::OnLButtonDown(UINT nFlags, CPoint point) {
Sys_UpdateWindows(W_ALL);
return;
}
if (Terrain_LButtonDown(this, point, nFlags)) {
return;
}
if ((nFlags & MK_CONTROL) && (nFlags & MK_SHIFT) && CamWnd_FaceExtrudeBegin(this, point)) {
return;
}
@@ -3448,6 +3617,9 @@ void CCamWnd::OnLButtonDown(UINT nFlags, CPoint point) {
=======================================================================================================================
*/
void CCamWnd::OnLButtonUp(UINT nFlags, CPoint point) {
if (Terrain_LButtonUp(this, point, nFlags)) {
return;
}
if (CamWnd_GizmoIsActive(this)) {
CamWnd_GizmoMouseMove(this, point, nFlags);
CamWnd_GizmoEnd(this, true);
@@ -4448,6 +4620,7 @@ void CCamWnd::Cam_Draw() {
CamWnd_DrawActiveBrushes(this, renderMode, entityMode, brushFilter);
CamWnd_DrawRadiantLightFrustums(this);
Terrain_DrawCam(this);
//glDepthMask ( 1 ); // Ok, write now
+4
View File
@@ -30,6 +30,7 @@ If you have questions concerning this license or the applicable additional terms
#pragma hdrstop
#include "qe3.h"
#include "Terrain.h"
int mapModified; // for quit confirmation (0 = clean, 1 = unsaved,
@@ -521,6 +522,7 @@ void Map_Free(void) {
// clear all the render and sound system data
g_qeglobals.rw->InitFromMap( NULL );
g_qeglobals.sw->ClearAllSoundEmitters();
Terrain_Clear();
Texture_ClearInuse();
Pointfile_Clear();
@@ -840,6 +842,7 @@ void Map_LoadFile(const char *filename) {
g_pParentWnd->GetCamera()->BuildRendererState();
}
Map_LoadDecals(filename);
Terrain_Load(filename);
Sys_EndWait();
Sys_UpdateWindows(W_ALL);
@@ -1086,6 +1089,7 @@ bool Map_SaveFile(const char *filename, bool use_region, bool autosave) {
map.Write(mapFile, mapExt, !(autosave || localFile));
if (!use_region) {
Map_SaveDecals(filename);
Terrain_Save(filename);
}
mapModified = 0;
+11 -2
View File
@@ -48,6 +48,7 @@ If you have questions concerning this license or the applicable additional terms
#include "DialogThick.h"
#include "PatchDialog.h"
#include "Undo.h"
#include "Terrain.h"
#include "NewTexWnd.h"
#include "splines.h"
#include "dlgcamera.h"
@@ -5502,6 +5503,10 @@ void CMainFrame::OnEditPastebrush() {
*/
void CMainFrame::OnEditUndo() {
// if (ActiveXY()) ActiveXY()->Undo();
if (Terrain_UndoAvailable() && (Terrain_IsEditMode() || !Undo_UndoAvailable())) {
Terrain_Undo();
return;
}
Undo_Undo();
}
@@ -5510,6 +5515,10 @@ void CMainFrame::OnEditUndo() {
=======================================================================================================================
*/
void CMainFrame::OnEditRedo() {
if (Terrain_RedoAvailable() && (Terrain_IsEditMode() || !Undo_RedoAvailable())) {
Terrain_Redo();
return;
}
Undo_Redo();
}
@@ -5522,7 +5531,7 @@ void CMainFrame::OnUpdateEditUndo(CCmdUI* pCmdUI) {
* BOOL bEnable = false; if (ActiveXY()) bEnable = ActiveXY()->UndoAvailable();
* pCmdUI->Enable(bEnable);
*/
pCmdUI->Enable(Undo_UndoAvailable());
pCmdUI->Enable(Undo_UndoAvailable() || Terrain_UndoAvailable());
}
/*
@@ -5530,7 +5539,7 @@ void CMainFrame::OnUpdateEditUndo(CCmdUI* pCmdUI) {
=======================================================================================================================
*/
void CMainFrame::OnUpdateEditRedo(CCmdUI* pCmdUI) {
pCmdUI->Enable(Undo_RedoAvailable());
pCmdUI->Enable(Undo_RedoAvailable() || Terrain_RedoAvailable());
}
/*
+181
View File
@@ -0,0 +1,181 @@
/*
===========================================================================
IceTech GPL Source Code
Copyright (C) 2026 Justin Marshall
This file is part of the IceTech GPL Source Code.
===========================================================================
*/
#ifndef __RADIANTGLTEXT_H__
#define __RADIANTGLTEXT_H__
static ID_INLINE const unsigned char* RadiantGLText_GlyphRows(char c) {
static const unsigned char glyphBlank[7] = { 0, 0, 0, 0, 0, 0, 0 };
static const unsigned char glyph0[7] = { 14, 17, 19, 21, 25, 17, 14 };
static const unsigned char glyph1[7] = { 4, 12, 4, 4, 4, 4, 14 };
static const unsigned char glyph2[7] = { 14, 17, 1, 2, 4, 8, 31 };
static const unsigned char glyph3[7] = { 30, 1, 1, 14, 1, 1, 30 };
static const unsigned char glyph4[7] = { 2, 6, 10, 18, 31, 2, 2 };
static const unsigned char glyph5[7] = { 31, 16, 16, 30, 1, 1, 30 };
static const unsigned char glyph6[7] = { 14, 16, 16, 30, 17, 17, 14 };
static const unsigned char glyph7[7] = { 31, 1, 2, 4, 8, 8, 8 };
static const unsigned char glyph8[7] = { 14, 17, 17, 14, 17, 17, 14 };
static const unsigned char glyph9[7] = { 14, 17, 17, 15, 1, 1, 14 };
static const unsigned char glyphA[7] = { 14, 17, 17, 31, 17, 17, 17 };
static const unsigned char glyphB[7] = { 30, 17, 17, 30, 17, 17, 30 };
static const unsigned char glyphC[7] = { 14, 17, 16, 16, 16, 17, 14 };
static const unsigned char glyphD[7] = { 30, 17, 17, 17, 17, 17, 30 };
static const unsigned char glyphE[7] = { 31, 16, 16, 30, 16, 16, 31 };
static const unsigned char glyphF[7] = { 31, 16, 16, 30, 16, 16, 16 };
static const unsigned char glyphG[7] = { 14, 17, 16, 23, 17, 17, 14 };
static const unsigned char glyphH[7] = { 17, 17, 17, 31, 17, 17, 17 };
static const unsigned char glyphI[7] = { 14, 4, 4, 4, 4, 4, 14 };
static const unsigned char glyphJ[7] = { 7, 2, 2, 2, 18, 18, 12 };
static const unsigned char glyphK[7] = { 17, 18, 20, 24, 20, 18, 17 };
static const unsigned char glyphL[7] = { 16, 16, 16, 16, 16, 16, 31 };
static const unsigned char glyphM[7] = { 17, 27, 21, 21, 17, 17, 17 };
static const unsigned char glyphN[7] = { 17, 25, 21, 19, 17, 17, 17 };
static const unsigned char glyphO[7] = { 14, 17, 17, 17, 17, 17, 14 };
static const unsigned char glyphP[7] = { 30, 17, 17, 30, 16, 16, 16 };
static const unsigned char glyphQ[7] = { 14, 17, 17, 17, 21, 18, 13 };
static const unsigned char glyphR[7] = { 30, 17, 17, 30, 20, 18, 17 };
static const unsigned char glyphS[7] = { 15, 16, 16, 14, 1, 1, 30 };
static const unsigned char glyphT[7] = { 31, 4, 4, 4, 4, 4, 4 };
static const unsigned char glyphU[7] = { 17, 17, 17, 17, 17, 17, 14 };
static const unsigned char glyphV[7] = { 17, 17, 17, 17, 17, 10, 4 };
static const unsigned char glyphW[7] = { 17, 17, 17, 21, 21, 21, 10 };
static const unsigned char glyphX[7] = { 17, 17, 10, 4, 10, 17, 17 };
static const unsigned char glyphY[7] = { 17, 17, 10, 4, 4, 4, 4 };
static const unsigned char glyphZ[7] = { 31, 1, 2, 4, 8, 16, 31 };
static const unsigned char glyphColon[7] = { 0, 4, 4, 0, 4, 4, 0 };
static const unsigned char glyphXChar[7] = { 0, 0, 17, 10, 4, 10, 17 };
static const unsigned char glyphSlash[7] = { 1, 1, 2, 4, 8, 16, 16 };
static const unsigned char glyphBackslash[7] = { 16, 16, 8, 4, 2, 1, 1 };
static const unsigned char glyphDot[7] = { 0, 0, 0, 0, 0, 12, 12 };
static const unsigned char glyphDash[7] = { 0, 0, 0, 31, 0, 0, 0 };
static const unsigned char glyphUnderscore[7] = { 0, 0, 0, 0, 0, 0, 31 };
if (c >= 'a' && c <= 'z' && c != 'x') {
c = c - 'a' + 'A';
}
switch (c) {
case '0': return glyph0;
case '1': return glyph1;
case '2': return glyph2;
case '3': return glyph3;
case '4': return glyph4;
case '5': return glyph5;
case '6': return glyph6;
case '7': return glyph7;
case '8': return glyph8;
case '9': return glyph9;
case 'A': return glyphA;
case 'B': return glyphB;
case 'C': return glyphC;
case 'D': return glyphD;
case 'E': return glyphE;
case 'F': return glyphF;
case 'G': return glyphG;
case 'H': return glyphH;
case 'I': return glyphI;
case 'J': return glyphJ;
case 'K': return glyphK;
case 'L': return glyphL;
case 'M': return glyphM;
case 'N': return glyphN;
case 'O': return glyphO;
case 'P': return glyphP;
case 'Q': return glyphQ;
case 'R': return glyphR;
case 'S': return glyphS;
case 'T': return glyphT;
case 'U': return glyphU;
case 'V': return glyphV;
case 'W': return glyphW;
case 'X': return glyphX;
case 'x': return glyphXChar;
case 'Y': return glyphY;
case 'Z': return glyphZ;
case ':': return glyphColon;
case '/': return glyphSlash;
case '\\': return glyphBackslash;
case '.': return glyphDot;
case '-': return glyphDash;
case '_': return glyphUnderscore;
default: return glyphBlank;
}
}
static ID_INLINE float RadiantGLText_Abs(float value) {
return (value < 0.0f) ? -value : value;
}
static ID_INLINE float RadiantGLText_Width(const char* text, float scale) {
if (!text || !text[0]) {
return 0.0f;
}
return (float)strlen(text) * 6.0f * RadiantGLText_Abs(scale);
}
static ID_INLINE float RadiantGLText_Height(float scale) {
return 7.0f * RadiantGLText_Abs(scale);
}
static ID_INLINE void RadiantGLText_DrawScaled(const char* text, float x, float y, float xScale, float yScale) {
if (!text || !text[0]) {
return;
}
const float glyphAdvance = 6.0f * RadiantGLText_Abs(xScale);
float penX = x;
glBegin(GL_QUADS);
for (const char* p = text; *p; p++) {
const char c = *p;
if (c == ' ') {
penX += glyphAdvance;
continue;
}
const unsigned char* rows = RadiantGLText_GlyphRows(c);
for (int row = 0; row < 7; row++) {
for (int col = 0; col < 5; col++) {
if (!(rows[row] & (1 << (4 - col)))) {
continue;
}
const float x0 = penX + col * xScale;
const float y0 = y + row * yScale;
const float x1 = x0 + xScale;
const float y1 = y0 + yScale;
glVertex2f(x0, y0);
glVertex2f(x1, y0);
glVertex2f(x1, y1);
glVertex2f(x0, y1);
}
}
penX += glyphAdvance;
}
glEnd();
}
static ID_INLINE void RadiantGLText_Draw(const char* text, float x, float y, float scale) {
RadiantGLText_DrawScaled(text, x, y, scale, scale);
}
static ID_INLINE void RadiantGLText_DrawCentered(const char* text, float centerX, float centerY, float scale) {
const float x = centerX - RadiantGLText_Width(text, scale) * 0.5f;
const float y = centerY - RadiantGLText_Height(scale) * 0.5f;
RadiantGLText_Draw(text, x, y, scale);
}
static ID_INLINE void RadiantGLText_DrawCenteredYUp(const char* text, float centerX, float centerY, float scale) {
const float x = centerX - RadiantGLText_Width(text, scale) * 0.5f;
const float y = centerY + RadiantGLText_Height(scale) * 0.5f;
RadiantGLText_DrawScaled(text, x, y, scale, -scale);
}
#endif // __RADIANTGLTEXT_H__
File diff suppressed because it is too large Load Diff
+48
View File
@@ -0,0 +1,48 @@
/*
===========================================================================
Radiant terrain authoring
Editor-only heightfield terrain source data, live drawing, camera sculpt input,
and sidecar persistence.
===========================================================================
*/
#ifndef __RADIANT_TERRAIN_H__
#define __RADIANT_TERRAIN_H__
class CCamWnd;
void Terrain_Clear(void);
void Terrain_Load(const char *mapFileName);
void Terrain_Save(const char *mapFileName);
bool Terrain_IsEditMode(void);
void Terrain_SetEditMode(bool enabled);
void Terrain_ToggleEditMode(void);
bool Terrain_IsPaintMode(void);
void Terrain_SetPaintMode(bool enabled);
int Terrain_GetPaintLayer(void);
void Terrain_SelectPaintLayer(int layer);
int Terrain_NumTerrains(void);
void Terrain_CreateDefaultAtCamera(CCamWnd *cam);
bool Terrain_ShowLayersDialog(CCamWnd *cam);
bool Terrain_HandleKeyDown(CCamWnd *cam, UINT key);
bool Terrain_HandleChar(CCamWnd *cam, UINT key);
bool Terrain_MouseMove(CCamWnd *cam, const CPoint &point, UINT flags);
bool Terrain_LButtonDown(CCamWnd *cam, const CPoint &point, UINT flags);
bool Terrain_LButtonUp(CCamWnd *cam, const CPoint &point, UINT flags);
void Terrain_CancelStroke(void);
void Terrain_DrawCam(CCamWnd *cam);
void Terrain_DrawXY(int viewType);
void Terrain_AdjustBrushRadius(float scale);
void Terrain_AdjustBrushStrength(float scale);
bool Terrain_UndoAvailable(void);
bool Terrain_RedoAvailable(void);
bool Terrain_Undo(void);
bool Terrain_Redo(void);
#endif
+3
View File
@@ -32,6 +32,7 @@ If you have questions concerning this license or the applicable additional terms
#include "qe3.h"
#include "Radiant.h"
#include "XYWnd.h"
#include "Terrain.h"
#include "ModelViewDock.h"
#include "ZWnd.h"
#include "DialogInfo.h"
@@ -5838,6 +5839,8 @@ void CXYWnd::XY_Draw() {
brush->Brush_DrawXY(m_nViewType );
}
Terrain_DrawXY(m_nViewType);
DrawPathLines();
// draw pointfile