mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
VoxelManip cleanups (const ref, const move) + function removal (#6169)
* VoxelManip cleanups (const ref, const move) permitting to improve a little bit performance * VoxelArea: precalculate extent (performance enhancement) This permits to reduce extend high cost to zero and drop many v3s16 object creation/removal to calculate extent It rebalance the client thread update to updateFastFaceRow instead of MapBlockMesh generation This will also benefits to mapgen
This commit is contained in:
parent
0c99da4255
commit
9a17b65f26
13 changed files with 85 additions and 198 deletions
|
@ -202,7 +202,7 @@ u16 getFaceLight(MapNode n, MapNode n2, v3s16 face_dir, INodeDefManager *ndef)
|
|||
Calculate smooth lighting at the XYZ- corner of p.
|
||||
Both light banks
|
||||
*/
|
||||
static u16 getSmoothLightCombined(v3s16 p, MeshMakeData *data)
|
||||
static u16 getSmoothLightCombined(const v3s16 &p, MeshMakeData *data)
|
||||
{
|
||||
static const v3s16 dirs8[8] = {
|
||||
v3s16(0,0,0),
|
||||
|
@ -855,11 +855,10 @@ static void getTileInfo(
|
|||
*/
|
||||
static void updateFastFaceRow(
|
||||
MeshMakeData *data,
|
||||
v3s16 startpos,
|
||||
const v3s16 &&startpos,
|
||||
v3s16 translate_dir,
|
||||
v3f translate_dir_f,
|
||||
v3s16 face_dir,
|
||||
v3f face_dir_f,
|
||||
const v3f &&translate_dir_f,
|
||||
const v3s16 &&face_dir,
|
||||
std::vector<FastFace> &dest)
|
||||
{
|
||||
v3s16 p = startpos;
|
||||
|
@ -966,7 +965,6 @@ static void updateAllFastFaceRows(MeshMakeData *data,
|
|||
v3s16(1,0,0), //dir
|
||||
v3f (1,0,0),
|
||||
v3s16(0,1,0), //face dir
|
||||
v3f (0,1,0),
|
||||
dest);
|
||||
}
|
||||
}
|
||||
|
@ -981,7 +979,6 @@ static void updateAllFastFaceRows(MeshMakeData *data,
|
|||
v3s16(0,0,1), //dir
|
||||
v3f (0,0,1),
|
||||
v3s16(1,0,0), //face dir
|
||||
v3f (1,0,0),
|
||||
dest);
|
||||
}
|
||||
}
|
||||
|
@ -996,7 +993,6 @@ static void updateAllFastFaceRows(MeshMakeData *data,
|
|||
v3s16(1,0,0), //dir
|
||||
v3f (1,0,0),
|
||||
v3s16(0,0,1), //face dir
|
||||
v3f (0,0,1),
|
||||
dest);
|
||||
}
|
||||
}
|
||||
|
@ -1525,14 +1521,12 @@ void MeshCollector::applyTileColors()
|
|||
{
|
||||
if (m_use_tangent_vertices)
|
||||
for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
|
||||
std::vector<PreMeshBuffer> *p = &prebuffers[layer];
|
||||
for (std::vector<PreMeshBuffer>::iterator it = p->begin();
|
||||
it != p->end(); ++it) {
|
||||
video::SColor tc = it->layer.color;
|
||||
for (auto &pmb : prebuffers[layer]) {
|
||||
video::SColor tc = pmb.layer.color;
|
||||
if (tc == video::SColor(0xFFFFFFFF))
|
||||
continue;
|
||||
for (u32 index = 0; index < it->tangent_vertices.size(); index++) {
|
||||
video::SColor *c = &it->tangent_vertices[index].Color;
|
||||
for (auto &tangent_vertice : pmb.tangent_vertices) {
|
||||
video::SColor *c = &tangent_vertice.Color;
|
||||
c->set(c->getAlpha(), c->getRed() * tc.getRed() / 255,
|
||||
c->getGreen() * tc.getGreen() / 255,
|
||||
c->getBlue() * tc.getBlue() / 255);
|
||||
|
@ -1541,14 +1535,12 @@ void MeshCollector::applyTileColors()
|
|||
}
|
||||
else
|
||||
for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
|
||||
std::vector<PreMeshBuffer> *p = &prebuffers[layer];
|
||||
for (std::vector<PreMeshBuffer>::iterator it = p->begin();
|
||||
it != p->end(); ++it) {
|
||||
video::SColor tc = it->layer.color;
|
||||
for (auto &pmb : prebuffers[layer]) {
|
||||
video::SColor tc = pmb.layer.color;
|
||||
if (tc == video::SColor(0xFFFFFFFF))
|
||||
continue;
|
||||
for (u32 index = 0; index < it->vertices.size(); index++) {
|
||||
video::SColor *c = &it->vertices[index].Color;
|
||||
for (auto &vertice : pmb.vertices) {
|
||||
video::SColor *c = &vertice.Color;
|
||||
c->set(c->getAlpha(), c->getRed() * tc.getRed() / 255,
|
||||
c->getGreen() * tc.getGreen() / 255,
|
||||
c->getBlue() * tc.getBlue() / 255);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue