mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 13:44:56 +00:00
SIMD refactor
This commit is contained in:
@@ -73,9 +73,9 @@ void VISIBuilder::Node::buildChildren(int level, int divisions, const zeus::CAAB
|
||||
{
|
||||
// Heuristic split
|
||||
int splits[3];
|
||||
splits[0] = (curAabb.max.x - curAabb.min.x >= VISI_MIN_LENGTH) ? 2 : 1;
|
||||
splits[1] = (curAabb.max.y - curAabb.min.y >= VISI_MIN_LENGTH) ? 2 : 1;
|
||||
splits[2] = (curAabb.max.z - curAabb.min.z >= VISI_MIN_LENGTH) ? 2 : 1;
|
||||
splits[0] = (curAabb.max.x() - curAabb.min.x() >= VISI_MIN_LENGTH) ? 2 : 1;
|
||||
splits[1] = (curAabb.max.y() - curAabb.min.y() >= VISI_MIN_LENGTH) ? 2 : 1;
|
||||
splits[2] = (curAabb.max.z() - curAabb.min.z() >= VISI_MIN_LENGTH) ? 2 : 1;
|
||||
|
||||
if (splits[0] == 2)
|
||||
flags |= 0x1;
|
||||
@@ -168,33 +168,33 @@ void VISIBuilder::Node::buildChildren(int level, int divisions, const zeus::CAAB
|
||||
{
|
||||
// This is a child node
|
||||
zeus::CVector3f center = curAabb.center();
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x, curAabb.min.y, curAabb.min.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x, curAabb.min.y, curAabb.min.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x, curAabb.min.y, curAabb.min.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x, center.y, curAabb.min.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x, center.y, curAabb.min.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x, center.y, curAabb.min.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x, curAabb.max.y, curAabb.min.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x, curAabb.max.y, curAabb.min.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x, curAabb.max.y, curAabb.min.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x, curAabb.min.y, center.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x, curAabb.min.y, center.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x, curAabb.min.y, center.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x, center.y, center.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x, center.y, center.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x, center.y, center.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x, curAabb.max.y, center.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x, curAabb.max.y, center.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x, curAabb.max.y, center.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x, curAabb.min.y, curAabb.max.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x, curAabb.min.y, curAabb.max.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x, curAabb.min.y, curAabb.max.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x, center.y, curAabb.max.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x, center.y, curAabb.max.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x, center.y, curAabb.max.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x, curAabb.max.y, curAabb.max.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x, curAabb.max.y, curAabb.max.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x, curAabb.max.y, curAabb.max.z));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x(), curAabb.min.y(), curAabb.min.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x(), curAabb.min.y(), curAabb.min.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x(), curAabb.min.y(), curAabb.min.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x(), center.y(), curAabb.min.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x(), center.y(), curAabb.min.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x(), center.y(), curAabb.min.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x(), curAabb.max.y(), curAabb.min.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x(), curAabb.max.y(), curAabb.min.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x(), curAabb.max.y(), curAabb.min.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x(), curAabb.min.y(), center.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x(), curAabb.min.y(), center.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x(), curAabb.min.y(), center.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x(), center.y(), center.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x(), center.y(), center.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x(), center.y(), center.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x(), curAabb.max.y(), center.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x(), curAabb.max.y(), center.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x(), curAabb.max.y(), center.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x(), curAabb.min.y(), curAabb.max.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x(), curAabb.min.y(), curAabb.max.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x(), curAabb.min.y(), curAabb.max.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x(), center.y(), curAabb.max.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x(), center.y(), curAabb.max.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x(), center.y(), curAabb.max.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.min.x(), curAabb.max.y(), curAabb.max.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(center.x(), curAabb.max.y(), curAabb.max.z()));
|
||||
leaf |= rc.GetLeaf(zeus::CVector3f(curAabb.max.x(), curAabb.max.y(), curAabb.max.z()));
|
||||
|
||||
prog.report(divisions);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ template <> struct hash<zeus::CVector3f>
|
||||
{
|
||||
size_t operator()(const zeus::CVector3f& val) const noexcept
|
||||
{
|
||||
return XXH64(val.v, 12, 0);
|
||||
zeus::simd_floats f(val.mSimd);
|
||||
return XXH64(&f[0], 12, 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -126,13 +126,13 @@ std::vector<VISIRenderer::Model::Vert> VISIRenderer::AABBToVerts(const zeus::CAA
|
||||
verts[i].color = color;
|
||||
|
||||
verts[0].pos = aabb.min;
|
||||
verts[1].pos = {aabb.max.x, aabb.min.y, aabb.min.z};
|
||||
verts[2].pos = {aabb.min.x, aabb.min.y, aabb.max.z};
|
||||
verts[3].pos = {aabb.max.x, aabb.min.y, aabb.max.z};
|
||||
verts[4].pos = {aabb.min.x, aabb.max.y, aabb.max.z};
|
||||
verts[1].pos = {aabb.max.x(), aabb.min.y(), aabb.min.z()};
|
||||
verts[2].pos = {aabb.min.x(), aabb.min.y(), aabb.max.z()};
|
||||
verts[3].pos = {aabb.max.x(), aabb.min.y(), aabb.max.z()};
|
||||
verts[4].pos = {aabb.min.x(), aabb.max.y(), aabb.max.z()};
|
||||
verts[5].pos = aabb.max;
|
||||
verts[6].pos = {aabb.min.x, aabb.max.y, aabb.min.z};
|
||||
verts[7].pos = {aabb.max.x, aabb.max.y, aabb.min.z};
|
||||
verts[6].pos = {aabb.min.x(), aabb.max.y(), aabb.min.z()};
|
||||
verts[7].pos = {aabb.max.x(), aabb.max.y(), aabb.min.z()};
|
||||
|
||||
return verts;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user