mirror of
https://github.com/Garux/netradiant-custom.git
synced 2026-09-28 00:00:03 +02:00
simplify terrain generation plugin API interaction
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
#include "qerplugin.h"
|
||||
#include "scenelib.h"
|
||||
|
||||
const unsigned int BRUSH_DETAIL_FLAG = 27;
|
||||
const unsigned int BRUSH_DETAIL_MASK = ( 1 << BRUSH_DETAIL_FLAG );
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -26,7 +29,7 @@ static void fill_face( _QERFaceData& face,
|
||||
face.m_texdef.shift[0] = 0;
|
||||
face.m_texdef.shift[1] = 0;
|
||||
face.m_texdef.rotate = 0;
|
||||
face.contents = 0;
|
||||
face.contents = BRUSH_DETAIL_MASK;
|
||||
face.flags = 0;
|
||||
face.value = 0;
|
||||
}
|
||||
@@ -186,7 +189,6 @@ void build_terrain_brushes( const BrushData& target, double step_x, double step_
|
||||
}
|
||||
|
||||
select_generated( entity );
|
||||
GlobalRadiant().Brush_setDetail( entity );
|
||||
SceneChangeNotify();
|
||||
}
|
||||
|
||||
@@ -467,9 +469,5 @@ void build_tunnel_brushes( const BrushData& target, double step_x, double step_y
|
||||
select_generated( ceil_entity );
|
||||
select_generated( lwall_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();
|
||||
}
|
||||
|
||||
+1
-4
@@ -143,6 +143,7 @@ struct _QERFuncTable_1
|
||||
Vector3 ( *Camera_getOrigin )();
|
||||
|
||||
const char* ( *TextureBrowser_getSelectedShader )( );
|
||||
void ( *TextureBrowser_show )( );
|
||||
|
||||
// Qt functions
|
||||
PFN_QERAPP_MESSAGEBOX m_pfnMessageBox;
|
||||
@@ -150,10 +151,6 @@ struct _QERFuncTable_1
|
||||
PFN_QERAPP_DIRDIALOG m_pfnDirDialog;
|
||||
PFN_QERAPP_COLORDIALOG m_pfnColorDialog;
|
||||
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"
|
||||
|
||||
+2
-1
@@ -1982,12 +1982,13 @@ public:
|
||||
}
|
||||
|
||||
/// \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 ) {
|
||||
return 0;
|
||||
}
|
||||
undoSave();
|
||||
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() );
|
||||
planeChanged();
|
||||
return m_faces.back();
|
||||
|
||||
@@ -658,26 +658,6 @@ void Scene_BrushSetDetail_Selected( scene::Graph& graph, bool detail ){
|
||||
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 ){
|
||||
if ( shader_equal( face.GetShader(), find ) ) {
|
||||
face.SetShader( replace );
|
||||
|
||||
@@ -45,9 +45,6 @@ class Graph;
|
||||
class Node;
|
||||
}
|
||||
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;
|
||||
void Scene_BrushResize_Cuboid( scene::Node*& node, const AABB& bounds );
|
||||
void Brush_ConstructPlacehoderCuboid( scene::Node& node, const AABB& bounds );
|
||||
|
||||
@@ -236,7 +236,7 @@ public:
|
||||
}
|
||||
bool Brush_addFace( scene::Node& brush, const _QERFaceData& faceData ) override {
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,7 +39,5 @@ inline void RawStringExport( const char* string, const StringImportCallback& imp
|
||||
typedef ConstPointerCaller<char, void(const StringImportCallback&), RawStringExport> RawStringExportCaller;
|
||||
QWidget* GroupDialog_addPage( const char* tabLabel, QWidget* widget, const StringExportCallback& title );
|
||||
|
||||
bool GroupDialog_isShown();
|
||||
QWidget* GroupDialog_getPage();
|
||||
void GroupDialog_showPage( QWidget* page );
|
||||
void GroupDialog_updatePageTitle( QWidget* page );
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
#include "texwindow.h"
|
||||
#include "modelwindow.h"
|
||||
#include "mainframe.h"
|
||||
#include "brushmanip.h"
|
||||
#include "build.h"
|
||||
#include "mru.h"
|
||||
#include "surfacedialog.h"
|
||||
@@ -153,7 +152,6 @@ public:
|
||||
|
||||
m_radiantcore.TextureBrowser_getSelectedShader = TextureBrowser_GetSelectedShader;
|
||||
m_radiantcore.TextureBrowser_show = TextureBrowser_show;
|
||||
m_radiantcore.Brush_setDetail = Brush_setDetail;
|
||||
|
||||
m_radiantcore.m_pfnMessageBox = &qt_MessageBox;
|
||||
m_radiantcore.m_pfnFileDialog = &file_dialog;
|
||||
|
||||
@@ -625,12 +625,8 @@ void TextureBrowser_toggleShow(){
|
||||
}
|
||||
|
||||
void TextureBrowser_show(){
|
||||
if ( !g_page_textures )
|
||||
return;
|
||||
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
|
||||
if ( g_page_textures != nullptr )
|
||||
GroupDialog_showPage( g_page_textures );
|
||||
}
|
||||
|
||||
void TextureBrowser_updateTitle(){
|
||||
|
||||
Reference in New Issue
Block a user