1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

VBO-related optimizations and improvements (#14395)

This commit is contained in:
sfan5 2024-02-19 19:04:20 +01:00
parent d85c842ce9
commit bb7f57b095
22 changed files with 439 additions and 322 deletions

View file

@ -19,10 +19,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once
#include "irrlichttypes_extrabloated.h"
#include <iostream>
#include "constants.h"
#include "irr_ptr.h"
#include "irrlichttypes_extrabloated.h"
#include "skyparams.h"
#include <iostream>
class IShaderSource;
// Menu clouds
class Clouds;
@ -34,7 +37,7 @@ extern scene::ISceneManager *g_menucloudsmgr;
class Clouds : public scene::ISceneNode
{
public:
Clouds(scene::ISceneManager* mgr,
Clouds(scene::ISceneManager* mgr, IShaderSource *ssrc,
s32 id,
u32 seed
);
@ -72,7 +75,7 @@ public:
void update(const v3f &camera_p, const video::SColorf &color);
void updateCameraOffset(const v3s16 &camera_offset)
void updateCameraOffset(v3s16 camera_offset)
{
m_camera_offset = camera_offset;
updateBox();
@ -82,24 +85,29 @@ public:
void setDensity(float density)
{
if (m_params.density == density)
return;
m_params.density = density;
// currently does not need bounding
invalidateMesh();
}
void setColorBright(const video::SColor &color_bright)
void setColorBright(video::SColor color_bright)
{
m_params.color_bright = color_bright;
}
void setColorAmbient(const video::SColor &color_ambient)
void setColorAmbient(video::SColor color_ambient)
{
m_params.color_ambient = color_ambient;
}
void setHeight(float height)
{
m_params.height = height; // add bounding when necessary
if (m_params.height == height)
return;
m_params.height = height;
updateBox();
invalidateMesh();
}
void setSpeed(v2f speed)
@ -109,8 +117,11 @@ public:
void setThickness(float thickness)
{
if (m_params.thickness == thickness)
return;
m_params.thickness = thickness;
updateBox();
invalidateMesh();
}
bool isCameraInsideCloud() const { return m_camera_inside_cloud; }
@ -126,18 +137,33 @@ private:
BS * 1000000.0f, height_bs + thickness_bs - BS * m_camera_offset.Y, BS * 1000000.0f);
}
void updateMesh();
void invalidateMesh()
{
m_mesh_valid = false;
}
bool gridFilled(int x, int y) const;
video::SMaterial m_material;
irr_ptr<scene::SMeshBuffer> m_meshbuffer;
// Value of m_origin at the time the mesh was last updated
v2f m_mesh_origin;
// Value of center_of_drawing_in_noise_i at the time the mesh was last updated
v2s16 m_last_noise_center;
// Was the mesh ever generated?
bool m_mesh_valid = false;
aabb3f m_box;
v2f m_origin;
u16 m_cloud_radius_i;
bool m_enable_3d;
u32 m_seed;
v3f m_camera_pos;
v2f m_origin;
v3s16 m_camera_offset;
video::SColorf m_color = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
CloudParams m_params;
bool m_camera_inside_cloud = false;
bool m_enable_shaders, m_enable_3d;
video::SColorf m_color = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
CloudParams m_params;
};