mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
Put all pieces together and clean up leftover code
This commit is contained in:
parent
6b7fc1e9fe
commit
62131fe295
11 changed files with 105 additions and 169 deletions
|
@ -133,9 +133,10 @@ Hud::Hud(Client *client, LocalPlayer *player,
|
|||
rangelim(g_settings->getS16("selectionbox_width"), 1, 5);
|
||||
|
||||
// Prepare mesh for compass drawing
|
||||
auto &b = m_rotation_mesh_buffer;
|
||||
auto &vertices = b.Vertices->Data;
|
||||
auto &indices = b.Indices->Data;
|
||||
m_rotation_mesh_buffer.reset(new scene::SMeshBuffer());
|
||||
auto *b = m_rotation_mesh_buffer.get();
|
||||
auto &vertices = b->Vertices->Data;
|
||||
auto &indices = b->Indices->Data;
|
||||
vertices.resize(4);
|
||||
indices.resize(6);
|
||||
|
||||
|
@ -154,9 +155,9 @@ Hud::Hud(Client *client, LocalPlayer *player,
|
|||
indices[4] = 3;
|
||||
indices[5] = 0;
|
||||
|
||||
b.getMaterial().Lighting = false;
|
||||
b.getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
//b.setHardwareMappingHint(scene::EHM_STATIC); // FIXME: incorrectly stack allocated, not safe!
|
||||
b->getMaterial().Lighting = false;
|
||||
b->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
b->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
}
|
||||
|
||||
void Hud::readScalingSetting()
|
||||
|
@ -658,10 +659,10 @@ void Hud::drawCompassRotate(HudElement *e, video::ITexture *texture,
|
|||
driver->setTransform(video::ETS_VIEW, core::matrix4());
|
||||
driver->setTransform(video::ETS_WORLD, Matrix);
|
||||
|
||||
video::SMaterial &material = m_rotation_mesh_buffer.getMaterial();
|
||||
auto &material = m_rotation_mesh_buffer->getMaterial();
|
||||
material.TextureLayers[0].Texture = texture;
|
||||
driver->setMaterial(material);
|
||||
driver->drawMeshBuffer(&m_rotation_mesh_buffer);
|
||||
driver->drawMeshBuffer(m_rotation_mesh_buffer.get());
|
||||
|
||||
driver->setTransform(video::ETS_WORLD, core::matrix4());
|
||||
driver->setTransform(video::ETS_VIEW, oldViewMat);
|
||||
|
|
|
@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include <IGUIFont.h>
|
||||
#include <SMaterial.h>
|
||||
#include <SMeshBuffer.h>
|
||||
#include "irr_ptr.h"
|
||||
#include "irr_aabb3d.h"
|
||||
#include "../hud.h"
|
||||
|
||||
|
@ -152,7 +153,7 @@ private:
|
|||
video::SMaterial m_selection_material;
|
||||
video::SMaterial m_block_bounds_material;
|
||||
|
||||
scene::SMeshBuffer m_rotation_mesh_buffer;
|
||||
irr_ptr<scene::SMeshBuffer> m_rotation_mesh_buffer;
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -594,12 +594,9 @@ void MapBlockBspTree::traverse(s32 node, v3f viewpoint, std::vector<s32> &output
|
|||
|
||||
void PartialMeshBuffer::draw(video::IVideoDriver *driver) const
|
||||
{
|
||||
// Swap out the index buffer before drawing the mesh
|
||||
auto *old = m_buffer->Indices;
|
||||
m_buffer->Indices = m_indices.get();
|
||||
m_buffer->setDirty(scene::EBT_INDEX); // TODO remove
|
||||
driver->drawMeshBuffer(m_buffer);
|
||||
m_buffer->Indices = old;
|
||||
const auto pType = m_buffer->getPrimitiveType();
|
||||
driver->drawBuffers(m_buffer->getVertexBuffer(), m_indices.get(),
|
||||
m_indices->getPrimitiveCount(pType), pType);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -785,11 +782,6 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
|
|||
}
|
||||
}
|
||||
|
||||
// Transparent parts have changing indices
|
||||
// TODO: remove
|
||||
for (auto &it : m_transparent_triangles)
|
||||
it.buffer->setHardwareMappingHint(scene::EHM_STREAM, scene::EBT_INDEX);
|
||||
|
||||
m_bsp_tree.buildTree(&m_transparent_triangles, data->side_length);
|
||||
|
||||
// Check if animation is required for this mesh
|
||||
|
|
|
@ -145,19 +145,18 @@ private:
|
|||
*
|
||||
* Attach alternate `Indices` to an existing mesh buffer, to make it possible to use different
|
||||
* indices with the same vertex buffer.
|
||||
*
|
||||
*/
|
||||
class PartialMeshBuffer
|
||||
{
|
||||
public:
|
||||
PartialMeshBuffer(scene::SMeshBuffer *buffer, std::vector<u16> &&vertex_indices) :
|
||||
m_buffer(buffer)
|
||||
m_buffer(buffer), m_indices(make_irr<scene::SIndexBuffer>())
|
||||
{
|
||||
m_indices.reset(new scene::SIndexBuffer());
|
||||
m_indices->Data = std::move(vertex_indices);
|
||||
m_indices->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
}
|
||||
|
||||
scene::IMeshBuffer *getBuffer() const { return m_buffer; }
|
||||
auto *getBuffer() const { return m_buffer; }
|
||||
|
||||
void draw(video::IVideoDriver *driver) const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue