Start separating rendering | Update CMakeLists.txt, MapTile.cpp, and 14 more files...
This commit is contained in:
@@ -406,6 +406,11 @@ IF(APPLE)
|
||||
TARGET_LINK_LIBRARIES (noggit "-framework Cocoa" "-framework AppKit" "-framework Foundation")
|
||||
ENDIF()
|
||||
|
||||
if (UNIX)
|
||||
FIND_PACKAGE(BZip2)
|
||||
TARGET_LINK_LIBRARIES (noggit BZip2::BZip2)
|
||||
ENDIF()
|
||||
|
||||
IF(MYSQL_LIBRARY AND MYSQLCPPCONN_LIBRARY AND MYSQLCPPCONN_INCLUDE)
|
||||
TARGET_LINK_LIBRARIES(noggit ${MYSQL_LIBRARY} ${MYSQLCPPCONN_LIBRARY})
|
||||
TARGET_INCLUDE_DIRECTORIES(noggit SYSTEM PRIVATE ${MYSQLCPPCONN_INCLUDE})
|
||||
|
||||
@@ -812,7 +812,6 @@ void MapTile::drawMFBO (OpenGL::Scoped::use_program& mfbo_shader)
|
||||
}
|
||||
|
||||
void MapTile::drawWater ( math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const glm::vec3& camera
|
||||
, bool camera_moved
|
||||
, OpenGL::Scoped::use_program& water_shader
|
||||
@@ -829,7 +828,6 @@ void MapTile::drawWater ( math::frustum const& frustum
|
||||
|
||||
// process water bounds
|
||||
Water.draw ( frustum
|
||||
, cull_distance
|
||||
, camera
|
||||
, camera_moved
|
||||
, water_shader
|
||||
|
||||
@@ -99,7 +99,6 @@ public:
|
||||
|
||||
bool intersect (math::ray const&, selection_result*) const;
|
||||
void drawWater ( math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const glm::vec3& camera
|
||||
, bool camera_moved
|
||||
, OpenGL::Scoped::use_program& water_shader
|
||||
|
||||
@@ -225,10 +225,10 @@ void MapView::set_editing_mode (editing_mode mode)
|
||||
|
||||
if (context() && context()->isValid())
|
||||
{
|
||||
_world->getTerrainParamsUniformBlock()->draw_areaid_overlay = false;
|
||||
_world->getTerrainParamsUniformBlock()->draw_impass_overlay = false;
|
||||
_world->getTerrainParamsUniformBlock()->draw_paintability_overlay = false;
|
||||
_world->getTerrainParamsUniformBlock()->draw_selection_overlay = false;
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_areaid_overlay = false;
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_impass_overlay = false;
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = false;
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_selection_overlay = false;
|
||||
_minimap->use_selection(nullptr);
|
||||
|
||||
switch (mode)
|
||||
@@ -246,7 +246,7 @@ void MapView::set_editing_mode (editing_mode mode)
|
||||
}
|
||||
if (texturingTool->show_unpaintable_chunks())
|
||||
{
|
||||
_world->getTerrainParamsUniformBlock()->draw_paintability_overlay = true;
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = true;
|
||||
}
|
||||
break;
|
||||
case editing_mode::mccv:
|
||||
@@ -262,13 +262,13 @@ void MapView::set_editing_mode (editing_mode mode)
|
||||
}
|
||||
break;
|
||||
case editing_mode::areaid:
|
||||
_world->getTerrainParamsUniformBlock()->draw_areaid_overlay = true;
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_areaid_overlay = true;
|
||||
break;
|
||||
case editing_mode::flags:
|
||||
_world->getTerrainParamsUniformBlock()->draw_impass_overlay = true;
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_impass_overlay = true;
|
||||
break;
|
||||
case editing_mode::minimap:
|
||||
_world->getTerrainParamsUniformBlock()->draw_selection_overlay = true;
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_selection_overlay = true;
|
||||
_minimap->use_selection(minimapTool->getSelectedTiles());
|
||||
break;
|
||||
default:
|
||||
@@ -289,7 +289,7 @@ void MapView::set_editing_mode (editing_mode mode)
|
||||
_toolbar->check_tool (mode);
|
||||
this->activateWindow();
|
||||
|
||||
_world->markTerrainParamsUniformBlockDirty();
|
||||
_world->renderer()->markTerrainParamsUniformBlockDirty();
|
||||
}
|
||||
|
||||
void MapView::setToolPropertyWidgetVisibility(editing_mode mode)
|
||||
@@ -1802,22 +1802,22 @@ void MapView::setupViewMenu()
|
||||
ADD_TOGGLE_POST (view_menu, "Lines", Qt::Key_F7, _draw_lines,
|
||||
[=]
|
||||
{
|
||||
_world->getTerrainParamsUniformBlock()->draw_lines = _draw_lines.get();
|
||||
_world->markTerrainParamsUniformBlockDirty();
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_lines = _draw_lines.get();
|
||||
_world->renderer()->markTerrainParamsUniformBlockDirty();
|
||||
});
|
||||
|
||||
ADD_TOGGLE_POST (view_menu, "Contours", Qt::Key_F9, _draw_contour,
|
||||
[=]
|
||||
{
|
||||
_world->getTerrainParamsUniformBlock()->draw_terrain_height_contour = _draw_contour.get();
|
||||
_world->markTerrainParamsUniformBlockDirty();
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_terrain_height_contour = _draw_contour.get();
|
||||
_world->renderer()->markTerrainParamsUniformBlockDirty();
|
||||
});
|
||||
|
||||
ADD_TOGGLE_POST (view_menu, "Wireframe", Qt::Key_F10, _draw_wireframe,
|
||||
[=]
|
||||
{
|
||||
_world->getTerrainParamsUniformBlock()->draw_wireframe = _draw_wireframe.get();
|
||||
_world->markTerrainParamsUniformBlockDirty();
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_wireframe = _draw_wireframe.get();
|
||||
_world->renderer()->markTerrainParamsUniformBlockDirty();
|
||||
});
|
||||
|
||||
ADD_TOGGLE (view_menu, "Toggle Animation", Qt::Key_F11, _draw_model_animations);
|
||||
@@ -1827,8 +1827,8 @@ void MapView::setupViewMenu()
|
||||
ADD_TOGGLE_POST (view_menu, "Hole lines", "Shift+F7", _draw_hole_lines,
|
||||
[=]
|
||||
{
|
||||
_world->getTerrainParamsUniformBlock()->draw_hole_lines = _draw_hole_lines.get();
|
||||
_world->markTerrainParamsUniformBlockDirty();
|
||||
_world->renderer()->getTerrainParamsUniformBlock()->draw_hole_lines = _draw_hole_lines.get();
|
||||
_world->renderer()->markTerrainParamsUniformBlockDirty();
|
||||
});
|
||||
|
||||
ADD_TOGGLE_NS (view_menu, "Models with box", _draw_models_with_box);
|
||||
@@ -2333,8 +2333,6 @@ void MapView::setupHotkeys()
|
||||
, [this] { return terrainMode == editing_mode::paint && !NOGGIT_CUR_ACTION; }
|
||||
);
|
||||
|
||||
addHotkey (Qt::Key_Plus, MOD_shift, [this] { _world->fogdistance += 60.0f; });
|
||||
|
||||
addHotkey (Qt::Key_Minus, MOD_alt, [this] { terrainTool->changeRadius(-0.01f); }
|
||||
, [this] { return terrainMode == editing_mode::ground && !NOGGIT_CUR_ACTION; });
|
||||
|
||||
@@ -2350,8 +2348,6 @@ void MapView::setupHotkeys()
|
||||
, [this] { return terrainMode == editing_mode::paint && !NOGGIT_CUR_ACTION; }
|
||||
);
|
||||
|
||||
addHotkey (Qt::Key_Minus, MOD_shift, [this] { _world->fogdistance -= 60.0f; });
|
||||
|
||||
addHotkey (Qt::Key_1, MOD_shift, [this] { _camera.move_speed = 15.0f; });
|
||||
addHotkey (Qt::Key_2, MOD_shift, [this] { _camera.move_speed = 50.0f; });
|
||||
addHotkey (Qt::Key_3, MOD_shift, [this] { _camera.move_speed = 200.0f; });
|
||||
@@ -2750,7 +2746,7 @@ void MapView::initializeGL()
|
||||
|
||||
_last_opengl_context = context();
|
||||
|
||||
_world->initShaders();
|
||||
_world->renderer()->upload();
|
||||
onSettingsSave();
|
||||
|
||||
_buffers.upload();
|
||||
@@ -2780,7 +2776,7 @@ void MapView::saveMinimap(MinimapRenderSettings* settings)
|
||||
|
||||
if (_world->mapIndex.hasTile(tile))
|
||||
{
|
||||
mmap_render_success = _world->saveMinimap(tile, settings, _mmap_combined_image);
|
||||
mmap_render_success = _world->renderer()->saveMinimap(tile, settings, _mmap_combined_image);
|
||||
}
|
||||
|
||||
if (mmap_render_success)
|
||||
@@ -2841,7 +2837,7 @@ void MapView::saveMinimap(MinimapRenderSettings* settings)
|
||||
{
|
||||
OpenGL::context::scoped_setter const _(::gl, context());
|
||||
makeCurrent();
|
||||
mmap_render_success = _world->saveMinimap(tile, settings, _mmap_combined_image);
|
||||
mmap_render_success = _world->renderer()->saveMinimap(tile, settings, _mmap_combined_image);
|
||||
|
||||
_mmap_render_index++;
|
||||
emit updateProgress(_mmap_render_index);
|
||||
@@ -2947,7 +2943,7 @@ void MapView::saveMinimap(MinimapRenderSettings* settings)
|
||||
|
||||
if (_world->mapIndex.hasTile(tile))
|
||||
{
|
||||
mmap_render_success = _world->saveMinimap(tile, settings, _mmap_combined_image);
|
||||
mmap_render_success = _world->renderer()->saveMinimap(tile, settings, _mmap_combined_image);
|
||||
_mmap_render_index++;
|
||||
|
||||
emit updateProgress(_mmap_render_index);
|
||||
@@ -4223,7 +4219,8 @@ void MapView::draw_map()
|
||||
}
|
||||
|
||||
|
||||
_world->draw ( model_view()
|
||||
_world->renderer()->draw (
|
||||
model_view()
|
||||
, projection()
|
||||
, _cursor_pos
|
||||
, _cursorRotation
|
||||
@@ -5138,7 +5135,7 @@ void MapView::unloadOpenglData(bool from_manager)
|
||||
}
|
||||
}
|
||||
|
||||
_world->unload_shaders();
|
||||
_world->renderer()->unload();
|
||||
|
||||
if (!from_manager)
|
||||
Noggit::Ui::Tools::ViewportManager::ViewportManager::unloadOpenglData(this);
|
||||
@@ -5162,7 +5159,7 @@ QWidget* MapView::getActiveStampModeItem()
|
||||
|
||||
void MapView::onSettingsSave()
|
||||
{
|
||||
OpenGL::TerrainParamsUniformBlock* params = _world->getTerrainParamsUniformBlock();
|
||||
OpenGL::TerrainParamsUniformBlock* params = _world->renderer()->getTerrainParamsUniformBlock();
|
||||
params->wireframe_type = _settings->value("wireframe/type", 0).toInt();
|
||||
params->wireframe_radius = _settings->value("wireframe/radius", 1.5f).toFloat();
|
||||
params->wireframe_width = _settings->value ("wireframe/width", 1.f).toFloat();
|
||||
@@ -5171,5 +5168,5 @@ void MapView::onSettingsSave()
|
||||
glm::vec4 wireframe_color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||
params->wireframe_color = wireframe_color;
|
||||
|
||||
_world->markTerrainParamsUniformBlockDirty();
|
||||
_world->renderer()->markTerrainParamsUniformBlockDirty();
|
||||
}
|
||||
|
||||
@@ -777,7 +777,7 @@ void OutdoorLightStats::interpolate(OutdoorLightStats *a, OutdoorLightStats *b,
|
||||
nightIntensity = a->nightIntensity * ir + b->nightIntensity * progressDayAndNight;
|
||||
}
|
||||
|
||||
OutdoorLighting::OutdoorLighting(const std::string& fname)
|
||||
OutdoorLighting::OutdoorLighting()
|
||||
{
|
||||
|
||||
static constexpr std::array<int, 24> night_hours =
|
||||
|
||||
@@ -26,7 +26,7 @@ private:
|
||||
std::vector<OutdoorLightStats> lightStats;
|
||||
|
||||
public:
|
||||
explicit OutdoorLighting(const std::string& fname);
|
||||
OutdoorLighting();
|
||||
|
||||
OutdoorLightStats getLightStats(int time);
|
||||
};
|
||||
|
||||
@@ -42,7 +42,6 @@ void TileWater::readFromFile(BlizzardArchive::ClientFile &theFile, size_t basePo
|
||||
}
|
||||
|
||||
void TileWater::draw ( math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const glm::vec3& camera
|
||||
, bool camera_moved
|
||||
, OpenGL::Scoped::use_program& water_shader
|
||||
|
||||
@@ -44,7 +44,6 @@ public:
|
||||
void saveToFile(sExtendableArray& lADTFile, int& lMHDR_Position, int& lCurrentPosition);
|
||||
|
||||
void draw ( math::frustum const& frustum
|
||||
, const float& cull_distance
|
||||
, const glm::vec3& camera
|
||||
, bool camera_moved
|
||||
, OpenGL::Scoped::use_program& water_shader
|
||||
|
||||
1628
src/noggit/World.cpp
1628
src/noggit/World.cpp
File diff suppressed because it is too large
Load Diff
@@ -30,11 +30,17 @@
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <noggit/project/ApplicationProject.h>
|
||||
#include <noggit/rendering/WorldRender.hpp>
|
||||
|
||||
namespace Noggit
|
||||
{
|
||||
struct object_paste_params;
|
||||
struct VertexSelectionCache;
|
||||
|
||||
namespace Rendering
|
||||
{
|
||||
class WorldRender;
|
||||
}
|
||||
}
|
||||
|
||||
class Brush;
|
||||
@@ -42,16 +48,15 @@ class MapTile;
|
||||
class QPixmap;
|
||||
|
||||
static const float detail_size = 8.0f;
|
||||
static const float highresdistance = 384.0f;
|
||||
static const float modeldrawdistance = 384.0f;
|
||||
static const float doodaddrawdistance = 64.0f;
|
||||
|
||||
using StripType = uint16_t;
|
||||
|
||||
|
||||
class World
|
||||
{
|
||||
private:
|
||||
friend class Noggit::Rendering::WorldRender;
|
||||
|
||||
protected:
|
||||
std::vector<selection_type> _current_selection;
|
||||
std::unordered_map<std::string, std::vector<ModelInstance*>> _models_by_filename;
|
||||
Noggit::world_model_instances_storage _model_instance_storage;
|
||||
@@ -83,52 +88,13 @@ public:
|
||||
|
||||
std::unique_ptr<Skies> skies;
|
||||
|
||||
OutdoorLightStats outdoorLightStats;
|
||||
|
||||
explicit World(const std::string& name, int map_id, Noggit::NoggitRenderContext context, bool create_empty = false);
|
||||
|
||||
void setBasename(const std::string& name);
|
||||
|
||||
SceneObject* getObjectInstance(std::uint32_t uid);
|
||||
|
||||
void initDisplay();
|
||||
|
||||
void update_models_emitters(float dt);
|
||||
void draw (glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& cursor_pos
|
||||
, float cursorRotation
|
||||
, glm::vec4 const& cursor_color
|
||||
, CursorType cursor_type
|
||||
, float brush_radius
|
||||
, bool show_unpaintable_chunks
|
||||
, float inner_radius_ratio
|
||||
, glm::vec3 const& ref_pos
|
||||
, float angle
|
||||
, float orientation
|
||||
, bool use_ref_pos
|
||||
, bool angled_mode
|
||||
, bool draw_paintability_overlay
|
||||
, editing_mode terrainMode
|
||||
, glm::vec3 const& camera_pos
|
||||
, bool camera_moved
|
||||
, bool draw_mfbo
|
||||
, bool draw_terrain
|
||||
, bool draw_wmo
|
||||
, bool draw_water
|
||||
, bool draw_wmo_doodads
|
||||
, bool draw_models
|
||||
, bool draw_model_animations
|
||||
, bool draw_models_with_box
|
||||
, bool draw_hidden_models
|
||||
, MinimapRenderSettings* minimap_render_settings
|
||||
, bool draw_fog
|
||||
, eTerrainType ground_editing_brush
|
||||
, int water_layer
|
||||
, display_mode display
|
||||
, bool draw_occlusion_boxes = false
|
||||
, bool minimap_render = false
|
||||
);
|
||||
|
||||
unsigned int getAreaID (glm::vec3 const&);
|
||||
void setAreaID(glm::vec3 const& pos, int id, bool adt, float radius = -1.0f);
|
||||
@@ -147,13 +113,13 @@ public:
|
||||
|
||||
MapChunk* getChunkAt(glm::vec3 const& pos);
|
||||
|
||||
private:
|
||||
protected:
|
||||
// Information about the currently selected model / WMO / triangle.
|
||||
int _selected_model_count = 0;
|
||||
std::optional<glm::vec3> _multi_select_pivot;
|
||||
public:
|
||||
|
||||
void unload_shaders();
|
||||
Noggit::Rendering::WorldRender* renderer() { return &_renderer; }
|
||||
|
||||
void update_selection_pivot();
|
||||
std::optional<glm::vec3> const& multi_select_pivot() const { return _multi_select_pivot; }
|
||||
@@ -207,16 +173,16 @@ public:
|
||||
bool isUnderMap(glm::vec3 const& pos);
|
||||
|
||||
template<typename Fun>
|
||||
bool for_all_chunks_in_range ( glm::vec3 const& pos
|
||||
, float radius
|
||||
, Fun&& /* MapChunk* -> bool changed */
|
||||
);
|
||||
bool for_all_chunks_in_range ( glm::vec3 const& pos
|
||||
, float radius
|
||||
, Fun&& /* MapChunk* -> bool changed */
|
||||
);
|
||||
template<typename Fun, typename Post>
|
||||
bool for_all_chunks_in_range ( glm::vec3 const& pos
|
||||
, float radius
|
||||
, Fun&& /* MapChunk* -> bool changed */
|
||||
, Post&& /* MapChunk* -> void; called for all changed chunks */
|
||||
);
|
||||
bool for_all_chunks_in_range ( glm::vec3 const& pos
|
||||
, float radius
|
||||
, Fun&& /* MapChunk* -> bool changed */
|
||||
, Post&& /* MapChunk* -> void; called for all changed chunks */
|
||||
);
|
||||
|
||||
template<typename Fun>
|
||||
bool for_all_chunks_in_rect ( glm::vec3 const& pos
|
||||
@@ -331,14 +297,6 @@ public:
|
||||
void updateTilesModel(ModelInstance* m2, model_update type);
|
||||
void wait_for_all_tile_updates();
|
||||
|
||||
bool saveMinimap (TileIndex const& tile_idx, MinimapRenderSettings* settings, std::optional<QImage>& combined_image);
|
||||
void drawMinimap ( MapTile *tile
|
||||
, glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& camera_pos
|
||||
, MinimapRenderSettings* settings
|
||||
);
|
||||
|
||||
void deleteModelInstance(int uid);
|
||||
void deleteWMOInstance(int uid);
|
||||
void deleteInstance(int uid);
|
||||
@@ -395,8 +353,6 @@ public:
|
||||
|
||||
glm::vec3 const& vertexCenter();
|
||||
|
||||
void initShaders();
|
||||
|
||||
void recalc_norms (MapChunk*) const;
|
||||
|
||||
Noggit::VertexSelectionCache getVertexSelectionCache();
|
||||
@@ -404,31 +360,15 @@ public:
|
||||
|
||||
bool need_model_updates = false;
|
||||
|
||||
OpenGL::TerrainParamsUniformBlock* getTerrainParamsUniformBlock() { return &_terrain_params_ubo_data; };
|
||||
void updateTerrainParamsUniformBlock();
|
||||
void markTerrainParamsUniformBlockDirty() { _need_terrain_params_ubo_update = true; };
|
||||
|
||||
LiquidTextureManager* getLiquidTextureManager() { return &_liquid_texture_manager; };
|
||||
void loadAllTiles();
|
||||
unsigned getNumLoadedTiles() { return _n_loaded_tiles; };
|
||||
unsigned getNumRenderedTiles() { return _n_rendered_tiles; };
|
||||
|
||||
private:
|
||||
protected:
|
||||
void update_models_by_filename();
|
||||
|
||||
void updateMVPUniformBlock(const glm::mat4x4& model_view, const glm::mat4x4& projection);
|
||||
void updateLightingUniformBlock(bool draw_fog, glm::vec3 const& camera_pos);
|
||||
void updateLightingUniformBlockMinimap(MinimapRenderSettings* settings);
|
||||
|
||||
|
||||
std::unordered_set<MapChunk*>& vertexBorderChunks();
|
||||
|
||||
void setupChunkVAO(OpenGL::Scoped::use_program& mcnk_shader);
|
||||
void setupLiquidChunkVAO(OpenGL::Scoped::use_program& water_shader);
|
||||
void setupOccluderBuffers();
|
||||
void setupChunkBuffers();
|
||||
void setupLiquidChunkBuffers();
|
||||
|
||||
std::unordered_set<MapTile*> _vertex_tiles;
|
||||
std::unordered_set<MapChunk*> _vertex_chunks;
|
||||
std::unordered_set<MapChunk*> _vertex_border_chunks;
|
||||
@@ -437,57 +377,15 @@ private:
|
||||
bool _vertex_center_updated = false;
|
||||
bool _vertex_border_updated = false;
|
||||
|
||||
std::unique_ptr<Noggit::map_horizon::render> _horizon_render;
|
||||
|
||||
bool _display_initialized = false;
|
||||
bool _global_vbos_initialized = false;
|
||||
|
||||
QSettings* _settings;
|
||||
|
||||
float _view_distance;
|
||||
|
||||
std::unique_ptr<OpenGL::program> _mcnk_program;;
|
||||
std::unique_ptr<OpenGL::program> _mfbo_program;
|
||||
std::unique_ptr<OpenGL::program> _m2_program;
|
||||
std::unique_ptr<OpenGL::program> _m2_instanced_program;
|
||||
std::unique_ptr<OpenGL::program> _m2_particles_program;
|
||||
std::unique_ptr<OpenGL::program> _m2_ribbons_program;
|
||||
std::unique_ptr<OpenGL::program> _m2_box_program;
|
||||
std::unique_ptr<OpenGL::program> _wmo_program;
|
||||
std::unique_ptr<OpenGL::program> _liquid_program;
|
||||
std::unique_ptr<OpenGL::program> _occluder_program;
|
||||
|
||||
Noggit::CursorRender _cursor_render;
|
||||
OpenGL::primitives::sphere _sphere_render;
|
||||
OpenGL::primitives::square _square_render;
|
||||
|
||||
Noggit::NoggitRenderContext _context;
|
||||
|
||||
OpenGL::Scoped::deferred_upload_buffers<8> _buffers;
|
||||
GLuint const& _mvp_ubo = _buffers[0];
|
||||
GLuint const& _lighting_ubo = _buffers[1];
|
||||
GLuint const& _terrain_params_ubo = _buffers[2];
|
||||
|
||||
OpenGL::MVPUniformBlock _mvp_ubo_data;
|
||||
OpenGL::LightingUniformBlock _lighting_ubo_data;
|
||||
OpenGL::TerrainParamsUniformBlock _terrain_params_ubo_data;
|
||||
|
||||
GLuint const& _mapchunk_vertex = _buffers[3];
|
||||
GLuint const& _mapchunk_index = _buffers[4];
|
||||
GLuint const& _mapchunk_texcoord = _buffers[5];
|
||||
GLuint const& _liquid_chunk_vertex = _buffers[6];
|
||||
GLuint const& _occluder_index = _buffers[7];
|
||||
|
||||
OpenGL::Scoped::deferred_upload_vertex_arrays<3> _vertex_arrays;
|
||||
GLuint const& _mapchunk_vao = _vertex_arrays[0];
|
||||
GLuint const& _liquid_chunk_vao = _vertex_arrays[1];
|
||||
GLuint const& _occluder_vao = _vertex_arrays[2];
|
||||
|
||||
LiquidTextureManager _liquid_texture_manager;
|
||||
|
||||
std::array<std::pair<std::pair<int, int>, MapTile*>, 64 * 64 > _loaded_tiles_buffer;
|
||||
|
||||
bool _need_terrain_params_ubo_update = false;
|
||||
Noggit::Rendering::WorldRender _renderer;
|
||||
|
||||
// Debug metrics
|
||||
unsigned _n_loaded_tiles;
|
||||
|
||||
18
src/noggit/rendering/BaseRender.hpp
Normal file
18
src/noggit/rendering/BaseRender.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#ifndef NOGGIT_BASERENDER_HPP
|
||||
#define NOGGIT_BASERENDER_HPP
|
||||
|
||||
namespace Noggit::Rendering
|
||||
{
|
||||
class BaseRender
|
||||
{
|
||||
public:
|
||||
BaseRender() = default;
|
||||
|
||||
virtual void upload() = 0;
|
||||
virtual void unload() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //NOGGIT_BASERENDER_HPP
|
||||
1612
src/noggit/rendering/WorldRender.cpp
Normal file
1612
src/noggit/rendering/WorldRender.cpp
Normal file
File diff suppressed because it is too large
Load Diff
157
src/noggit/rendering/WorldRender.hpp
Normal file
157
src/noggit/rendering/WorldRender.hpp
Normal file
@@ -0,0 +1,157 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#ifndef NOGGIT_WORLDRENDER_HPP
|
||||
#define NOGGIT_WORLDRENDER_HPP
|
||||
|
||||
#include <noggit/rendering/BaseRender.hpp>
|
||||
|
||||
#include <external/glm/glm.hpp>
|
||||
#include <math/trig.hpp>
|
||||
|
||||
#include <noggit/tool_enums.hpp>
|
||||
#include <noggit/CursorRender.hpp>
|
||||
#include <noggit/LiquidTextureManager.hpp>
|
||||
#include <noggit/map_horizon.h>
|
||||
#include <noggit/Sky.h>
|
||||
|
||||
#include <opengl/shader.hpp>
|
||||
#include <opengl/primitives.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class World;
|
||||
struct MinimapRenderSettings;
|
||||
|
||||
namespace Noggit::Rendering
|
||||
{
|
||||
class WorldRender : public BaseRender
|
||||
{
|
||||
public:
|
||||
WorldRender(World* world);
|
||||
|
||||
void upload() override;
|
||||
void unload() override;
|
||||
|
||||
void draw (glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& cursor_pos
|
||||
, float cursorRotation
|
||||
, glm::vec4 const& cursor_color
|
||||
, CursorType cursor_type
|
||||
, float brush_radius
|
||||
, bool show_unpaintable_chunks
|
||||
, float inner_radius_ratio
|
||||
, glm::vec3 const& ref_pos
|
||||
, float angle
|
||||
, float orientation
|
||||
, bool use_ref_pos
|
||||
, bool angled_mode
|
||||
, bool draw_paintability_overlay
|
||||
, editing_mode terrainMode
|
||||
, glm::vec3 const& camera_pos
|
||||
, bool camera_moved
|
||||
, bool draw_mfbo
|
||||
, bool draw_terrain
|
||||
, bool draw_wmo
|
||||
, bool draw_water
|
||||
, bool draw_wmo_doodads
|
||||
, bool draw_models
|
||||
, bool draw_model_animations
|
||||
, bool draw_models_with_box
|
||||
, bool draw_hidden_models
|
||||
, MinimapRenderSettings* minimap_render_settings
|
||||
, bool draw_fog
|
||||
, eTerrainType ground_editing_brush
|
||||
, int water_layer
|
||||
, display_mode display
|
||||
, bool draw_occlusion_boxes = false
|
||||
, bool minimap_render = false
|
||||
);
|
||||
|
||||
bool saveMinimap (TileIndex const& tile_idx
|
||||
, MinimapRenderSettings* settings
|
||||
, std::optional<QImage>& combined_image);
|
||||
|
||||
[[nodiscard]]
|
||||
OpenGL::TerrainParamsUniformBlock* getTerrainParamsUniformBlock() { return &_terrain_params_ubo_data; };
|
||||
|
||||
void updateTerrainParamsUniformBlock();
|
||||
void markTerrainParamsUniformBlockDirty() { _need_terrain_params_ubo_update = true; };
|
||||
|
||||
[[nodiscard]]
|
||||
LiquidTextureManager* getLiquidTextureManager() { return &_liquid_texture_manager; };
|
||||
|
||||
private:
|
||||
|
||||
void drawMinimap ( MapTile *tile
|
||||
, glm::mat4x4 const& model_view
|
||||
, glm::mat4x4 const& projection
|
||||
, glm::vec3 const& camera_pos
|
||||
, MinimapRenderSettings* settings
|
||||
);
|
||||
|
||||
void updateMVPUniformBlock(const glm::mat4x4& model_view, const glm::mat4x4& projection);
|
||||
void updateLightingUniformBlock(bool draw_fog, glm::vec3 const& camera_pos);
|
||||
void updateLightingUniformBlockMinimap(MinimapRenderSettings* settings);
|
||||
|
||||
|
||||
void setupChunkVAO(OpenGL::Scoped::use_program& mcnk_shader);
|
||||
void setupLiquidChunkVAO(OpenGL::Scoped::use_program& water_shader);
|
||||
void setupOccluderBuffers();
|
||||
void setupChunkBuffers();
|
||||
void setupLiquidChunkBuffers();
|
||||
|
||||
World* _world;
|
||||
|
||||
// shaders
|
||||
std::unique_ptr<OpenGL::program> _mcnk_program;;
|
||||
std::unique_ptr<OpenGL::program> _mfbo_program;
|
||||
std::unique_ptr<OpenGL::program> _m2_program;
|
||||
std::unique_ptr<OpenGL::program> _m2_instanced_program;
|
||||
std::unique_ptr<OpenGL::program> _m2_particles_program;
|
||||
std::unique_ptr<OpenGL::program> _m2_ribbons_program;
|
||||
std::unique_ptr<OpenGL::program> _m2_box_program;
|
||||
std::unique_ptr<OpenGL::program> _wmo_program;
|
||||
std::unique_ptr<OpenGL::program> _liquid_program;
|
||||
std::unique_ptr<OpenGL::program> _occluder_program;
|
||||
|
||||
// horizon && skies && lighting
|
||||
std::unique_ptr<Noggit::map_horizon::render> _horizon_render;
|
||||
std::unique_ptr<OutdoorLighting> _outdoor_lighting;
|
||||
OutdoorLightStats _outdoor_light_stats;
|
||||
|
||||
// cursor
|
||||
Noggit::CursorRender _cursor_render;
|
||||
OpenGL::primitives::sphere _sphere_render;
|
||||
OpenGL::primitives::square _square_render;
|
||||
|
||||
// buffers
|
||||
OpenGL::Scoped::deferred_upload_buffers<8> _buffers;
|
||||
GLuint const& _mvp_ubo = _buffers[0];
|
||||
GLuint const& _lighting_ubo = _buffers[1];
|
||||
GLuint const& _terrain_params_ubo = _buffers[2];
|
||||
GLuint const& _mapchunk_vertex = _buffers[3];
|
||||
GLuint const& _mapchunk_index = _buffers[4];
|
||||
GLuint const& _mapchunk_texcoord = _buffers[5];
|
||||
GLuint const& _liquid_chunk_vertex = _buffers[6];
|
||||
GLuint const& _occluder_index = _buffers[7];
|
||||
|
||||
// uniform blocks
|
||||
OpenGL::MVPUniformBlock _mvp_ubo_data;
|
||||
OpenGL::LightingUniformBlock _lighting_ubo_data;
|
||||
OpenGL::TerrainParamsUniformBlock _terrain_params_ubo_data;
|
||||
|
||||
|
||||
// VAOs
|
||||
OpenGL::Scoped::deferred_upload_vertex_arrays<3> _vertex_arrays;
|
||||
GLuint const& _mapchunk_vao = _vertex_arrays[0];
|
||||
GLuint const& _liquid_chunk_vao = _vertex_arrays[1];
|
||||
GLuint const& _occluder_vao = _vertex_arrays[2];
|
||||
|
||||
LiquidTextureManager _liquid_texture_manager;
|
||||
|
||||
bool _need_terrain_params_ubo_update = false;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //NOGGIT_WORLDRENDER_HPP
|
||||
@@ -113,8 +113,8 @@ namespace Noggit
|
||||
|
||||
connect(_show_unpaintable_chunks_cb, &QCheckBox::toggled, [=](bool checked)
|
||||
{
|
||||
_map_view->getWorld()->getTerrainParamsUniformBlock()->draw_paintability_overlay = checked;
|
||||
_map_view->getWorld()->markTerrainParamsUniformBlockDirty();
|
||||
_map_view->getWorld()->renderer()->getTerrainParamsUniformBlock()->draw_paintability_overlay = checked;
|
||||
_map_view->getWorld()->renderer()->markTerrainParamsUniformBlockDirty();
|
||||
});
|
||||
|
||||
// spray
|
||||
|
||||
@@ -30,7 +30,7 @@ void ModelViewer::paintGL()
|
||||
|
||||
if (_world)
|
||||
{
|
||||
_world->draw(world_model_view()
|
||||
_world->renderer()->draw(world_model_view()
|
||||
, world_projection()
|
||||
, glm::vec3(0.f, 0.f, 0.f)
|
||||
, 0.f
|
||||
|
||||
@@ -55,8 +55,12 @@ ImageBrowser::ImageBrowser(QWidget* parent)
|
||||
setWindowFlag(Qt::WindowStaysOnTopHint);
|
||||
_ui.setupUi(this);
|
||||
_model = new ImageBrowserFilesystemModel(this);
|
||||
auto samples_path = QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() + "samples");
|
||||
_model->setRootPath(samples_path);
|
||||
auto samples_path = QDir(QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() + "samples"));
|
||||
|
||||
if (!samples_path.exists())
|
||||
samples_path.mkpath(".");
|
||||
|
||||
_model->setRootPath(samples_path.absolutePath());
|
||||
_model->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Files);
|
||||
|
||||
QStringList filters;
|
||||
@@ -73,26 +77,26 @@ ImageBrowser::ImageBrowser(QWidget* parent)
|
||||
_dir_proxy_model->setSourceModel(_model);
|
||||
|
||||
_ui.treeView->setModel(_dir_proxy_model);
|
||||
_ui.treeView->setRootIndex(_dir_proxy_model->mapFromSource(_model->index(samples_path)));
|
||||
_ui.treeView->setRootIndex(_dir_proxy_model->mapFromSource(_model->index(samples_path.absolutePath())));
|
||||
_ui.treeView->hideColumn(1);
|
||||
_ui.treeView->hideColumn(2);
|
||||
_ui.treeView->hideColumn(3);
|
||||
_ui.treeView->setIconSize(QSize(64, 64));
|
||||
_ui.treeView->expandRecursively(_dir_proxy_model->mapFromSource(_model->index(samples_path)));
|
||||
_ui.treeView->expandRecursively(_dir_proxy_model->mapFromSource(_model->index(samples_path.absolutePath())));
|
||||
|
||||
|
||||
connect(_ui.treeView, &QTreeView::clicked,
|
||||
[=](const QModelIndex &index)
|
||||
{
|
||||
auto path = _model->fileInfo(_dir_proxy_model->mapToSource(index)).absoluteFilePath();
|
||||
_ui.treeView->setRootIndex(_dir_proxy_model->mapFromSource(_model->index(samples_path)));
|
||||
_ui.treeView->setRootIndex(_dir_proxy_model->mapFromSource(_model->index(samples_path.absolutePath())));
|
||||
});
|
||||
|
||||
connect(_ui.searchButton, &QPushButton::clicked
|
||||
,[this, samples_path]()
|
||||
{
|
||||
_dir_proxy_model->setFilterFixedString(_ui.searchField->text());
|
||||
_ui.treeView->setRootIndex(_dir_proxy_model->mapFromSource(_model->index(samples_path)));
|
||||
_ui.treeView->setRootIndex(_dir_proxy_model->mapFromSource(_model->index(samples_path.absolutePath())));
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user