1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

TileLayer: use shared_ptr for FrameSpec vector (#6171)

* TileLayer: use shared_ptr for vector framespec
This reduce memory copy of TileLayer from (4 to 16) * FrameSpec where FrameSpec = (sizeof(int) + 3 * sizeof(ptr)) to int + sizeof(ptr)

Callgrind difference

Before: https://lut.im/RGkiJqQb8T/LeQIEXpAuRzfl7gd.png
After: https://lut.im/bcqmwee1xu/cTwtptY5tRuS9lp0.png

* Fix one push_back to use vector::emplace_back & optimize inclusions
This commit is contained in:
Loïc Blot 2017-07-26 20:12:48 +02:00 committed by GitHub
parent 9a17b65f26
commit 3e50850260
5 changed files with 14 additions and 14 deletions

View file

@ -593,7 +593,7 @@ void postProcessNodeMesh(scene::SMesh *mesh, const ContentFeatures &f,
material.MaterialType = *mattype;
}
if (layer->animation_frame_count > 1) {
FrameSpec animation_frame = layer->frames[0];
const FrameSpec &animation_frame = (*layer->frames)[0];
material.setTexture(0, animation_frame.texture);
} else {
material.setTexture(0, layer->texture);
@ -601,7 +601,7 @@ void postProcessNodeMesh(scene::SMesh *mesh, const ContentFeatures &f,
if (use_shaders) {
if (layer->normal_texture) {
if (layer->animation_frame_count > 1) {
FrameSpec animation_frame = layer->frames[0];
const FrameSpec &animation_frame = (*layer->frames)[0];
material.setTexture(1, animation_frame.normal_texture);
} else
material.setTexture(1, layer->normal_texture);