Add support for moving shadow-casting lights
This commit is contained in:
parent
a5d4b8f28d
commit
3623f4ccc4
|
|
@ -86,6 +86,7 @@ namespace Nz
|
|||
UInt32 renderMask;
|
||||
|
||||
NazaraSlot(Light, OnLightDataInvalided, onLightInvalidated);
|
||||
NazaraSlot(Light, OnLightTransformInvalided, onLightTransformInvalidated);
|
||||
NazaraSlot(Light, OnLightShadowCastingChanged, onLightShadowCastingChanged);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ namespace Nz
|
|||
NazaraSignal(OnLightDataInvalided, Light* /*emitter*/);
|
||||
NazaraSignal(OnLightShadowCastingChanged, Light* /*light*/, bool /*isShadowCasting*/);
|
||||
NazaraSignal(OnLightShadowMapSettingChange, Light* /*light*/, PixelFormat /*newPixelFormat*/, UInt32 /*newSize*/);
|
||||
NazaraSignal(OnLightTransformInvalided, Light* /*emitter*/);
|
||||
|
||||
protected:
|
||||
inline void UpdateBoundingVolume(const BoundingVolumef& boundingVolume);
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ namespace Nz
|
|||
|
||||
UpdateBoundingVolume();
|
||||
UpdateViewProjMatrix();
|
||||
OnLightTransformInvalided(this);
|
||||
}
|
||||
|
||||
inline void SpotLight::UpdateRadius(float radius)
|
||||
|
|
@ -133,6 +134,7 @@ namespace Nz
|
|||
|
||||
UpdateBoundingVolume();
|
||||
UpdateViewProjMatrix();
|
||||
OnLightTransformInvalided(this);
|
||||
}
|
||||
|
||||
inline void SpotLight::UpdateBoundingVolume()
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@ namespace Nz
|
|||
const Matrix4f& viewProjMatrix = lightData->camera->GetViewerInstance().GetViewProjMatrix();
|
||||
|
||||
Frustumf frustum = Frustumf::Extract(viewProjMatrix);
|
||||
GetDebugDrawer().DrawFrustum(frustum, Nz::Color::Blue);
|
||||
|
||||
std::size_t visibilityHash = 5U;
|
||||
|
||||
|
|
@ -599,6 +600,12 @@ namespace Nz
|
|||
lightData->camera->UpdateZFar(spotLight.GetRadius());
|
||||
lightData->camera->UpdateViewport(Recti(0, 0, SafeCast<int>(shadowMapSize), SafeCast<int>(shadowMapSize)));
|
||||
|
||||
lightData->onLightTransformInvalidated.Connect(lightData->light->OnLightTransformInvalided, [lightData](Light* light)
|
||||
{
|
||||
SpotLight& spotLight = SafeCast<SpotLight&>(*light);
|
||||
ViewerInstance& viewerInstance = lightData->camera->GetViewerInstance();
|
||||
viewerInstance.UpdateViewMatrix(Nz::Matrix4f::TransformInverse(spotLight.GetPosition(), spotLight.GetRotation()));
|
||||
});
|
||||
viewerInstance.UpdateViewMatrix(Nz::Matrix4f::TransformInverse(spotLight.GetPosition(), spotLight.GetRotation()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Nz
|
|||
|
||||
void SpotLight::UpdateTransform(const Vector3f& position, const Quaternionf& rotation, const Vector3f& /*scale*/)
|
||||
{
|
||||
UpdatePosition(position);
|
||||
m_position = position; //< don't call UpdatePosition to prevent double update
|
||||
UpdateRotation(rotation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue