simplify terrain generation plugin API interaction

This commit is contained in:
Garux
2026-06-24 21:55:31 +05:00
parent 03eb929bfb
commit 81ff3f50e0
9 changed files with 10 additions and 45 deletions
+4 -6
View File
@@ -8,6 +8,9 @@
#include "qerplugin.h" #include "qerplugin.h"
#include "scenelib.h" #include "scenelib.h"
const unsigned int BRUSH_DETAIL_FLAG = 27;
const unsigned int BRUSH_DETAIL_MASK = ( 1 << BRUSH_DETAIL_FLAG );
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Helpers // Helpers
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -26,7 +29,7 @@ static void fill_face( _QERFaceData& face,
face.m_texdef.shift[0] = 0; face.m_texdef.shift[0] = 0;
face.m_texdef.shift[1] = 0; face.m_texdef.shift[1] = 0;
face.m_texdef.rotate = 0; face.m_texdef.rotate = 0;
face.contents = 0; face.contents = BRUSH_DETAIL_MASK;
face.flags = 0; face.flags = 0;
face.value = 0; face.value = 0;
} }
@@ -186,7 +189,6 @@ void build_terrain_brushes( const BrushData& target, double step_x, double step_
} }
select_generated( entity ); select_generated( entity );
GlobalRadiant().Brush_setDetail( entity );
SceneChangeNotify(); SceneChangeNotify();
} }
@@ -467,9 +469,5 @@ void build_tunnel_brushes( const BrushData& target, double step_x, double step_y
select_generated( ceil_entity ); select_generated( ceil_entity );
select_generated( lwall_entity ); select_generated( lwall_entity );
select_generated( rwall_entity ); select_generated( rwall_entity );
GlobalRadiant().Brush_setDetail( floor_entity );
GlobalRadiant().Brush_setDetail( ceil_entity );
GlobalRadiant().Brush_setDetail( lwall_entity );
GlobalRadiant().Brush_setDetail( rwall_entity );
SceneChangeNotify(); SceneChangeNotify();
} }
+1 -4
View File
@@ -143,6 +143,7 @@ struct _QERFuncTable_1
Vector3 ( *Camera_getOrigin )(); Vector3 ( *Camera_getOrigin )();
const char* ( *TextureBrowser_getSelectedShader )( ); const char* ( *TextureBrowser_getSelectedShader )( );
void ( *TextureBrowser_show )( );
// Qt functions // Qt functions
PFN_QERAPP_MESSAGEBOX m_pfnMessageBox; PFN_QERAPP_MESSAGEBOX m_pfnMessageBox;
@@ -150,10 +151,6 @@ struct _QERFuncTable_1
PFN_QERAPP_DIRDIALOG m_pfnDirDialog; PFN_QERAPP_DIRDIALOG m_pfnDirDialog;
PFN_QERAPP_COLORDIALOG m_pfnColorDialog; PFN_QERAPP_COLORDIALOG m_pfnColorDialog;
PFN_QERAPP_NEWICON m_pfnNewIcon; PFN_QERAPP_NEWICON m_pfnNewIcon;
// Plugin extensions — always append new members here to preserve ABI
void ( *TextureBrowser_show )( );
void ( *Brush_setDetail )( scene::Node& node );
}; };
#include "modulesystem.h" #include "modulesystem.h"
+2 -1
View File
@@ -1982,12 +1982,13 @@ public:
} }
/// \brief Appends a new face constructed from the parameters to the end of the face list. /// \brief Appends a new face constructed from the parameters to the end of the face list.
Face* addPlane( const DoubleVector3& p0, const DoubleVector3& p1, const DoubleVector3& p2, const char* shader, const TextureProjection& projection ){ Face* addPlane( const DoubleVector3& p0, const DoubleVector3& p1, const DoubleVector3& p2, const char* shader, const TextureProjection& projection, int contentFlags = 0 ){
if ( m_faces.size() == c_brush_maxFaces ) { if ( m_faces.size() == c_brush_maxFaces ) {
return 0; return 0;
} }
undoSave(); undoSave();
push_back( FaceSmartPointer( new Face( p0, p1, p2, shader, projection, this ) ) ); push_back( FaceSmartPointer( new Face( p0, p1, p2, shader, projection, this ) ) );
m_faces.back()->getShader().m_flags.m_contentFlags = contentFlags;
m_faces.back()->setDetail( isDetail() ); m_faces.back()->setDetail( isDetail() );
planeChanged(); planeChanged();
return m_faces.back(); return m_faces.back();
-20
View File
@@ -658,26 +658,6 @@ void Scene_BrushSetDetail_Selected( scene::Graph& graph, bool detail ){
SceneChangeNotify(); SceneChangeNotify();
} }
class BrushSetDetailWalker : public scene::Traversable::Walker
{
public:
bool pre( scene::Node& node ) const override {
if ( Brush* brush = Node_getBrush( node ) ) {
Brush_forEachFace( *brush, []( Face& face ){ face.setDetail( true ); } );
}
return true;
}
};
void Brush_setDetail( scene::Node& node ){
if ( Brush* brush = Node_getBrush( node ) ) {
Brush_forEachFace( *brush, []( Face& face ){ face.setDetail( true ); } );
}
else if ( scene::Traversable* traversable = Node_getTraversable( node ) ) {
traversable->traverse( BrushSetDetailWalker() );
}
}
bool Face_FindReplaceShader( Face& face, const char* find, const char* replace ){ bool Face_FindReplaceShader( Face& face, const char* find, const char* replace ){
if ( shader_equal( face.GetShader(), find ) ) { if ( shader_equal( face.GetShader(), find ) ) {
face.SetShader( replace ); face.SetShader( replace );
-3
View File
@@ -45,9 +45,6 @@ class Graph;
class Node; class Node;
} }
void Scene_BrushConstructPrefab( scene::Graph& graph, EBrushPrefab type, std::size_t sides, bool option, const char* shader ); void Scene_BrushConstructPrefab( scene::Graph& graph, EBrushPrefab type, std::size_t sides, bool option, const char* shader );
// Flag every brush in 'node' (a brush, or any node whose subgraph contains
// brushes, e.g. a group entity) as detail.
void Brush_setDetail( scene::Node& node );
class AABB; class AABB;
void Scene_BrushResize_Cuboid( scene::Node*& node, const AABB& bounds ); void Scene_BrushResize_Cuboid( scene::Node*& node, const AABB& bounds );
void Brush_ConstructPlacehoderCuboid( scene::Node& node, const AABB& bounds ); void Brush_ConstructPlacehoderCuboid( scene::Node& node, const AABB& bounds );
+1 -1
View File
@@ -236,7 +236,7 @@ public:
} }
bool Brush_addFace( scene::Node& brush, const _QERFaceData& faceData ) override { bool Brush_addFace( scene::Node& brush, const _QERFaceData& faceData ) override {
Node_getBrush( brush )->undoSave(); Node_getBrush( brush )->undoSave();
return Node_getBrush( brush )->addPlane( faceData.m_p0, faceData.m_p1, faceData.m_p2, faceData.m_shader, TextureProjection( faceData.m_texdef, brushprimit_texdef_t(), Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ) ) ) != 0; return Node_getBrush( brush )->addPlane( faceData.m_p0, faceData.m_p1, faceData.m_p2, faceData.m_shader, TextureProjection( faceData.m_texdef, brushprimit_texdef_t(), Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ) ), faceData.contents ) != 0;
} }
}; };
-2
View File
@@ -39,7 +39,5 @@ inline void RawStringExport( const char* string, const StringImportCallback& imp
typedef ConstPointerCaller<char, void(const StringImportCallback&), RawStringExport> RawStringExportCaller; typedef ConstPointerCaller<char, void(const StringImportCallback&), RawStringExport> RawStringExportCaller;
QWidget* GroupDialog_addPage( const char* tabLabel, QWidget* widget, const StringExportCallback& title ); QWidget* GroupDialog_addPage( const char* tabLabel, QWidget* widget, const StringExportCallback& title );
bool GroupDialog_isShown();
QWidget* GroupDialog_getPage();
void GroupDialog_showPage( QWidget* page ); void GroupDialog_showPage( QWidget* page );
void GroupDialog_updatePageTitle( QWidget* page ); void GroupDialog_updatePageTitle( QWidget* page );
-2
View File
@@ -58,7 +58,6 @@
#include "texwindow.h" #include "texwindow.h"
#include "modelwindow.h" #include "modelwindow.h"
#include "mainframe.h" #include "mainframe.h"
#include "brushmanip.h"
#include "build.h" #include "build.h"
#include "mru.h" #include "mru.h"
#include "surfacedialog.h" #include "surfacedialog.h"
@@ -153,7 +152,6 @@ public:
m_radiantcore.TextureBrowser_getSelectedShader = TextureBrowser_GetSelectedShader; m_radiantcore.TextureBrowser_getSelectedShader = TextureBrowser_GetSelectedShader;
m_radiantcore.TextureBrowser_show = TextureBrowser_show; m_radiantcore.TextureBrowser_show = TextureBrowser_show;
m_radiantcore.Brush_setDetail = Brush_setDetail;
m_radiantcore.m_pfnMessageBox = &qt_MessageBox; m_radiantcore.m_pfnMessageBox = &qt_MessageBox;
m_radiantcore.m_pfnFileDialog = &file_dialog; m_radiantcore.m_pfnFileDialog = &file_dialog;
+2 -6
View File
@@ -625,12 +625,8 @@ void TextureBrowser_toggleShow(){
} }
void TextureBrowser_show(){ void TextureBrowser_show(){
if ( !g_page_textures ) if ( g_page_textures != nullptr )
return; GroupDialog_showPage( g_page_textures );
if ( GroupDialog_isShown() && GroupDialog_getPage() == g_page_textures )
GroupDialog_show(); // already on textures tab — just raise/focus
else
GroupDialog_showPage( g_page_textures ); // switch to textures tab and show
} }
void TextureBrowser_updateTitle(){ void TextureBrowser_updateTitle(){