mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 06:32:23 +01:00
Fix vertex count accounting in ClientMap
This commit is contained in:
parent
0f7ee126de
commit
c52a4369eb
@ -841,10 +841,8 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
|||||||
drawcall_count += draw_order.size();
|
drawcall_count += draw_order.size();
|
||||||
|
|
||||||
for (auto &descriptor : draw_order) {
|
for (auto &descriptor : draw_order) {
|
||||||
scene::IMeshBuffer *buf = descriptor.getBuffer();
|
|
||||||
|
|
||||||
if (!descriptor.m_reuse_material) {
|
if (!descriptor.m_reuse_material) {
|
||||||
auto &material = buf->getMaterial();
|
auto &material = descriptor.getMaterial();
|
||||||
|
|
||||||
// Apply filter settings
|
// Apply filter settings
|
||||||
material.forEachTexture([this] (auto &tex) {
|
material.forEachTexture([this] (auto &tex) {
|
||||||
@ -876,8 +874,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
|||||||
m.setTranslation(block_wpos - offset);
|
m.setTranslation(block_wpos - offset);
|
||||||
|
|
||||||
driver->setTransform(video::ETS_WORLD, m);
|
driver->setTransform(video::ETS_WORLD, m);
|
||||||
descriptor.draw(driver);
|
vertex_count += descriptor.draw(driver);
|
||||||
vertex_count += buf->getIndexCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_profiler->avg(prefix + "draw meshes [ms]", draw.stop(true));
|
g_profiler->avg(prefix + "draw meshes [ms]", draw.stop(true));
|
||||||
@ -1195,11 +1192,9 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver,
|
|||||||
drawcall_count += draw_order.size();
|
drawcall_count += draw_order.size();
|
||||||
|
|
||||||
for (auto &descriptor : draw_order) {
|
for (auto &descriptor : draw_order) {
|
||||||
scene::IMeshBuffer *buf = descriptor.getBuffer();
|
|
||||||
|
|
||||||
if (!descriptor.m_reuse_material) {
|
if (!descriptor.m_reuse_material) {
|
||||||
// override some material properties
|
// override some material properties
|
||||||
video::SMaterial local_material = buf->getMaterial();
|
video::SMaterial local_material = descriptor.getMaterial();
|
||||||
local_material.MaterialType = material.MaterialType;
|
local_material.MaterialType = material.MaterialType;
|
||||||
// do not override culling if the original material renders both back
|
// do not override culling if the original material renders both back
|
||||||
// and front faces in solid mode (e.g. plantlike)
|
// and front faces in solid mode (e.g. plantlike)
|
||||||
@ -1219,8 +1214,7 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver,
|
|||||||
m.setTranslation(block_wpos - offset);
|
m.setTranslation(block_wpos - offset);
|
||||||
|
|
||||||
driver->setTransform(video::ETS_WORLD, m);
|
driver->setTransform(video::ETS_WORLD, m);
|
||||||
descriptor.draw(driver);
|
vertex_count += descriptor.draw(driver);
|
||||||
vertex_count += buf->getIndexCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore the driver material state
|
// restore the driver material state
|
||||||
@ -1335,19 +1329,22 @@ void ClientMap::updateTransparentMeshBuffers()
|
|||||||
m_needs_update_transparent_meshes = false;
|
m_needs_update_transparent_meshes = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
scene::IMeshBuffer* ClientMap::DrawDescriptor::getBuffer()
|
video::SMaterial &ClientMap::DrawDescriptor::getMaterial()
|
||||||
{
|
{
|
||||||
return m_use_partial_buffer ? m_partial_buffer->getBuffer() : m_buffer;
|
return (m_use_partial_buffer ? m_partial_buffer->getBuffer() : m_buffer)->getMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientMap::DrawDescriptor::draw(video::IVideoDriver* driver)
|
u32 ClientMap::DrawDescriptor::draw(video::IVideoDriver* driver)
|
||||||
{
|
{
|
||||||
if (m_use_partial_buffer) {
|
if (m_use_partial_buffer) {
|
||||||
m_partial_buffer->beforeDraw();
|
m_partial_buffer->beforeDraw();
|
||||||
driver->drawMeshBuffer(m_partial_buffer->getBuffer());
|
driver->drawMeshBuffer(m_partial_buffer->getBuffer());
|
||||||
|
auto count = m_partial_buffer->getBuffer()->getVertexCount();
|
||||||
m_partial_buffer->afterDraw();
|
m_partial_buffer->afterDraw();
|
||||||
|
return count;
|
||||||
} else {
|
} else {
|
||||||
driver->drawMeshBuffer(m_buffer);
|
driver->drawMeshBuffer(m_buffer);
|
||||||
|
return m_buffer->getVertexCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,8 +162,9 @@ private:
|
|||||||
m_pos(pos), m_partial_buffer(buffer), m_reuse_material(false), m_use_partial_buffer(true)
|
m_pos(pos), m_partial_buffer(buffer), m_reuse_material(false), m_use_partial_buffer(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
scene::IMeshBuffer* getBuffer();
|
video::SMaterial &getMaterial();
|
||||||
void draw(video::IVideoDriver* driver);
|
/// @return index count
|
||||||
|
u32 draw(video::IVideoDriver* driver);
|
||||||
};
|
};
|
||||||
|
|
||||||
Client *m_client;
|
Client *m_client;
|
||||||
|
Loading…
Reference in New Issue
Block a user