2
0
Panagiotis Christopoulos Charitos 12 жил өмнө
parent
commit
96561f8cd0

+ 0 - 1
bench/Main.cpp

@@ -108,7 +108,6 @@ void initSubsystems()
 	initializer.get("is.sm.bilinearEnabled") = true;
 	initializer.get("is.groundLightEnabled") = true;
 	initializer.get("is.sm.enabled") = true;
-	initializer.get("is.sm.pcfEnabled") = false;
 	initializer.get("is.sm.resolution") = 512;
 	initializer.get("pps.enabled") = true;
 	initializer.get("pps.hdr.enabled") = true;

+ 3 - 25
include/anki/scene/Camera.h

@@ -41,27 +41,12 @@ public:
 		return type;
 	}
 
-	const Mat4& getInverseProjectionMatrix() const
-	{
-		return invProjectionMat;
-	}
-
 	/// Needed by the renderer
 	virtual F32 getNear() const = 0;
 	/// Needed by the renderer
 	virtual F32 getFar() const = 0;
 	/// @}
 
-	/// @name Frustumable virtuals
-	/// @{
-
-	/// Override Frustumable::getFrustumableOrigin()
-	const Vec3& getFrustumOrigin() const
-	{
-		return getWorldTransform().getOrigin();
-	}
-	/// @}
-
 	/// @name Spatial virtuals
 	/// @{
 
@@ -75,14 +60,6 @@ public:
 	void lookAtPoint(const Vec3& point);
 
 protected:
-	/// Used in deferred shading for the calculation of view vector (see
-	/// CalcViewVector). The reason we store this matrix here is that we
-	/// don't want it to be re-calculated all the time but only when the
-	/// projection params (fovX, fovY, zNear, zFar) change. Fortunately
-	/// the projection params change rarely. Note that the Camera as we all
-	/// know re-calculates the matrices only when the parameters change!!
-	Mat4 invProjectionMat = Mat4::getIdentity();
-
 	/// Calculate the @a viewMat. The view matrix is the inverse world 
 	/// transformation
 	void updateViewMatrix()
@@ -159,6 +136,8 @@ public:
 		updateViewMatrix();
 		updateViewProjectionMatrix();
 		frustum.setTransform(getWorldTransform());
+		FrustumComponent::setOrigin(getWorldTransform().getOrigin());
+		FrustumComponent::markForUpdate();
 
 		SpatialComponent::markForUpdate();
 	}
@@ -171,11 +150,10 @@ private:
 	void frustumUpdate()
 	{
 		projectionMat = frustum.calculateProjectionMatrix();
-		invProjectionMat = projectionMat.getInverse();
 		updateViewProjectionMatrix();
+		FrustumComponent::markForUpdate();
 
 		SpatialComponent::markForUpdate();
-		FrustumComponent::markForUpdate();
 	}
 };
 

+ 14 - 2
include/anki/scene/FrustumComponent.h

@@ -24,7 +24,7 @@ public:
 
 	/// Pass the frustum here so we can avoid the virtuals
 	FrustumComponent(Frustum* fr)
-		: SceneComponent(this), frustum(fr)
+		: SceneComponent(this), frustum(fr), origin(0.0)
 	{
 		ANKI_ASSERT(frustum);
 		markForUpdate();
@@ -54,7 +54,10 @@ public:
 	}
 
 	/// Get the origin for sorting and visibility tests
-	virtual const Vec3& getFrustumOrigin() const = 0;
+	const Vec3& getFrustumOrigin() const
+	{
+		return origin;
+	}
 
 	void setVisibilityTestResults(VisibilityTestResults* visible_)
 	{
@@ -107,11 +110,20 @@ protected:
 	Mat4 viewMat = Mat4::getIdentity();
 	Mat4 viewProjectionMat = Mat4::getIdentity();
 
+	/// You need to mark it for update after calling this
+	void setOrigin(const Vec3& ori)
+	{
+		origin = ori;
+	}
+
 private:
 	/// Visibility stuff. It's per frame so the pointer is invalid on the next 
 	/// frame and before any visibility tests are run
 	VisibilityTestResults* visible = nullptr;
 
+	/// A cached value
+	Vec3 origin;
+
 	Bool8 markedForUpdate;
 };
 /// @}

+ 2 - 10
include/anki/scene/Light.h

@@ -306,21 +306,13 @@ public:
 		frustum.setTransform(getWorldTransform());
 		viewMat = Mat4(getWorldTransform().getInverse());
 		viewProjectionMat = projectionMat * viewMat;
+		FrustumComponent::setOrigin(getWorldTransform().getOrigin());
+		FrustumComponent::markForUpdate();
 
 		SpatialComponent::markForUpdate();
 	}
 	/// @}
 
-	/// @name FrustumComponent virtuals
-	/// @{
-
-	/// Override FrustumComponent::getFrustumOrigin()
-	const Vec3& getFrustumOrigin() const
-	{
-		return getWorldTransform().getOrigin();
-	}
-	/// @}
-
 	void loadTexture(const char* filename)
 	{
 		tex.load(filename);