Skip to content

Commit f143d0b

Browse files
author
devsh
committed
add explicit constructors to hlsl::matrix which can cast between matrices using different scalar types
(should casting from narrower float to wider be implicit instead?)
1 parent 2798fba commit f143d0b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ struct matrix final : private glm::mat<N,M,T>
1515
using Base::Base;
1616
using Base::operator[];
1717

18-
// For assigning to same dimension use implicit ctor, and even then only allow for dimension truncation
19-
template<uint16_t X, uint16_t Y> requires ((X!=N || Y!=M) && X>=N && Y>=M)
20-
explicit matrix(matrix<T,X,Y> const& m) : Base(reinterpret_cast<glm::mat<X,Y,T> const&>(m)) {}
18+
// For assigning to same dimension and type use implicit ctor, and even then only allow for dimension truncation
19+
template<typename U, uint16_t X, uint16_t Y> requires ((!std::is_same_v<T,U> || X!=N || Y!=M) && X>=N && Y>=M)
20+
explicit matrix(matrix<U,X,Y> const& m) : Base(reinterpret_cast<glm::mat<X,Y,U> const&>(m)) {}
2121

2222
matrix(matrix const&) = default;
2323
explicit matrix(Base const& base) : Base(base) {}

0 commit comments

Comments
 (0)