2
0
Panagiotis Christopoulos Charitos 1 жил өмнө
parent
commit
2c1bb66008

+ 2 - 2
AnKi/Math/Functions.h

@@ -113,14 +113,14 @@ inline constexpr T absolute(const T f) requires(std::is_integral<T>::value&& std
 
 
 /// The same as abs/fabs. For floats.
 /// The same as abs/fabs. For floats.
 template<typename T>
 template<typename T>
-inline constexpr T absolute(const T f) requires(std::is_floating_point<T>::value && std::is_same_v<T, double>)
+inline constexpr T absolute(const T f) requires(std::is_floating_point<T>::value&& std::is_same_v<T, double>)
 {
 {
 	return fabs(f);
 	return fabs(f);
 }
 }
 
 
 /// The same as abs/fabs. For floats.
 /// The same as abs/fabs. For floats.
 template<typename T>
 template<typename T>
-inline constexpr T absolute(const T f) requires(std::is_floating_point<T>::value && std::is_same_v<T, float>)
+inline constexpr T absolute(const T f) requires(std::is_floating_point<T>::value&& std::is_same_v<T, float>)
 {
 {
 	return fabsf(f);
 	return fabsf(f);
 }
 }

+ 9 - 8
AnKi/Math/Mat.h

@@ -132,7 +132,7 @@ public:
 		m(3, 3) = m33;
 		m(3, 3) = m33;
 	}
 	}
 
 
-	constexpr TMat(const TVec<T, 4>& translation, const TMat<T, 3, 3>& rotation, const T scale = T(1)) requires(kSize == 16)
+	constexpr TMat(const TVec<T, 3>& translation, const TMat<T, 3, 3>& rotation, const T scale = T(1)) requires(kSize == 16)
 	{
 	{
 		if(isZero<T>(scale - T(1)))
 		if(isZero<T>(scale - T(1)))
 		{
 		{
@@ -147,10 +147,11 @@ public:
 
 
 		auto& m = *this;
 		auto& m = *this;
 		m(3, 0) = m(3, 1) = m(3, 2) = T(0);
 		m(3, 0) = m(3, 1) = m(3, 2) = T(0);
+		m(3, 3) = T(1);
 	}
 	}
 
 
 	explicit constexpr TMat(const TTransform<T>& t) requires(kSize == 16)
 	explicit constexpr TMat(const TTransform<T>& t) requires(kSize == 16)
-		: TMat(t.getOrigin().xyz1(), t.getRotation().getRotationPart(), t.getScale())
+		: TMat(t.getOrigin().xyz(), t.getRotation().getRotationPart(), t.getScale())
 	{
 	{
 	}
 	}
 
 
@@ -886,13 +887,13 @@ public:
 		return m3;
 		return m3;
 	}
 	}
 
 
-	void setTranslationPart(const ColumnVec& v)
+	void setTranslationPart(const TVec<T, 3>& v)
 	{
 	{
-		if(kRowCount == 4)
-		{
-			ANKI_ASSERT(isZero<T>(v[3] - T(1)) && "w should be 1");
-		}
-		setColumn(3, v);
+		auto c = getColumn(3);
+		c.x() = v.x();
+		c.y() = v.y();
+		c.z() = v.z();
+		setColumn(3, c);
 	}
 	}
 
 
 	ColumnVec getTranslationPart() const
 	ColumnVec getTranslationPart() const

+ 1 - 1
AnKi/Renderer/Renderer.cpp

@@ -273,7 +273,7 @@ Error Renderer::populateRenderGraph(RenderingContext& ctx)
 	const Vec2 ndcPixelSize = 1.0f / Vec2(m_internalResolution);
 	const Vec2 ndcPixelSize = 1.0f / Vec2(m_internalResolution);
 	jitter *= ndcPixelSize;
 	jitter *= ndcPixelSize;
 	ctx.m_matrices.m_jitter = Mat4::getIdentity();
 	ctx.m_matrices.m_jitter = Mat4::getIdentity();
-	ctx.m_matrices.m_jitter.setTranslationPart(Vec4(jitter, 0.0f, 1.0f));
+	ctx.m_matrices.m_jitter.setTranslationPart(Vec3(jitter, 0.0f));
 	ctx.m_matrices.m_jitterOffsetNdc = jitter;
 	ctx.m_matrices.m_jitterOffsetNdc = jitter;
 
 
 	ctx.m_matrices.m_projectionJitter = ctx.m_matrices.m_jitter * ctx.m_matrices.m_projection;
 	ctx.m_matrices.m_projectionJitter = ctx.m_matrices.m_jitter * ctx.m_matrices.m_projection;

+ 1 - 1
AnKi/Scene/Components/LightComponent.cpp

@@ -311,7 +311,7 @@ void LightComponent::computeCascadeFrustums(const Frustum& primaryFrustum, Const
 
 
 				// Fix the projection matrix by applying an offset
 				// Fix the projection matrix by applying an offset
 				Mat4 correctionTranslationMat = Mat4::getIdentity();
 				Mat4 correctionTranslationMat = Mat4::getIdentity();
-				correctionTranslationMat.setTranslationPart(Vec4(dx, dy, 0, 1.0f));
+				correctionTranslationMat.setTranslationPart(Vec3(dx, dy, 0.0f));
 
 
 				cascadeProjMat = correctionTranslationMat * cascadeProjMat;
 				cascadeProjMat = correctionTranslationMat * cascadeProjMat;
 			}
 			}