1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Move SMaterial std::hash impl to its header

This commit is contained in:
sfan5 2024-11-25 21:56:12 +01:00
parent a799a54894
commit 810f39767c
4 changed files with 35 additions and 56 deletions

View file

@ -469,14 +469,12 @@ void CSceneManager::drawAll()
if (!Driver)
return;
u32 i; // new ISO for scoping problem in some compilers
// reset all transforms
Driver->setMaterial(video::SMaterial());
Driver->setTransform(video::ETS_PROJECTION, core::IdentityMatrix);
Driver->setTransform(video::ETS_VIEW, core::IdentityMatrix);
Driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
for (i = video::ETS_COUNT - 1; i >= video::ETS_TEXTURE_0; --i)
for (u32 i = video::ETS_COUNT - 1; i >= video::ETS_TEXTURE_0; --i)
Driver->setTransform((video::E_TRANSFORMATION_STATE)i, core::IdentityMatrix);
// TODO: This should not use an attribute here but a real parameter when necessary (too slow!)
Driver->setAllowZWriteOnTransparent(Parameters->getAttributeAsBool(ALLOW_ZWRITE_ON_TRANSPARENT));

View file

@ -193,21 +193,21 @@ private:
}
DefaultNodeEntry(ISceneNode *n) :
Node(n), TextureValue(0)
Node(n)
{
if (n->getMaterialCount())
TextureValue = (n->getMaterial(0).getTexture(0));
Hash = std::hash<video::SMaterial>{}(n->getMaterial(0));
}
bool operator<(const DefaultNodeEntry &other) const
bool operator<(const DefaultNodeEntry &other) const noexcept
{
return (TextureValue < other.TextureValue);
return Hash < other.Hash;
}
ISceneNode *Node;
ISceneNode *Node = nullptr;
private:
void *TextureValue;
size_t Hash = 0;
};
//! sort on distance (center) to camera
@ -223,42 +223,15 @@ private:
Distance = Node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(camera);
}
bool operator<(const TransparentNodeEntry &other) const
bool operator<(const TransparentNodeEntry &other) const noexcept
{
return Distance > other.Distance;
}
ISceneNode *Node;
ISceneNode *Node = nullptr;
private:
f64 Distance;
};
//! sort on distance (sphere) to camera
struct DistanceNodeEntry
{
DistanceNodeEntry(ISceneNode *n, const core::vector3df &cameraPos) :
Node(n)
{
setNodeAndDistanceFromPosition(n, cameraPos);
}
bool operator<(const DistanceNodeEntry &other) const
{
return Distance < other.Distance;
}
void setNodeAndDistanceFromPosition(ISceneNode *n, const core::vector3df &fromPosition)
{
Node = n;
Distance = Node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(fromPosition);
Distance -= Node->getBoundingBox().getExtent().getLengthSQ() * 0.5;
}
ISceneNode *Node;
private:
f64 Distance;
f32 Distance = 0;
};
//! video driver