Skip to content

Commit 6ada8fb

Browse files
author
kevyuu
committed
Implement zero_fill to expand smaller matrix to larger matrix
1 parent cca4d42 commit 6ada8fb

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

include/nbl/builtin/hlsl/math/linalg/transform.hlsl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ matrix<T, 3, 3> rotation_mat(T angle, vector<T, 3> const& axis)
5050
return rotation;
5151
}
5252

53+
template <uint16_t NOut, uint16_t MOut, uint16_t NIn, uint16_t MIn, typename T>
54+
requires(NOut >= NIn && MOut >= MIn)
55+
matrix <T, NOut, MOut> zero_fill(const matrix<T, NIn, MIn> inMatrix)
56+
{
57+
matrix<T, NOut, MOut> retval;
58+
for (auto row_i = 0u; row_i < NIn; row_i++)
59+
{
60+
for (auto col_i = 0u; col_i < MIn; col_i++)
61+
{
62+
retval[row_i][col_i] = inMatrix[row_i][col_i];
63+
}
64+
}
65+
return retval;
66+
}
67+
5368
}
5469
}
5570
}

src/nbl/asset/utils/CGeometryCreator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ core::smart_refctd_ptr<ICPUGeometryCollection> CGeometryCreator::createArrow(
683683
});
684684
const auto coneTransform = hlsl::math::linalg::rotation_mat(hlsl::numbers::pi<hlsl::float32_t> * -0.5f, hlsl::float32_t3(1.f, 0.f, 0.f));
685685
geometries->push_back({
686-
.transform = hlsl::float32_t3x4(coneTransform),
686+
.transform = hlsl::math::linalg::zero_fill<3, 4>(coneTransform),
687687
.geometry = cone
688688
});
689689
return collection;

0 commit comments

Comments
 (0)