From b071cdb843463c1f50b6484c7d50b31ba455a61d Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 16:01:56 +0100 Subject: [PATCH] Expose various engine features to scripting --- Source/Engine/Core/Math/Viewport.cs | 21 +++++---------------- Source/Engine/Graphics/Enums.h | 2 +- Source/Engine/Graphics/GPUDevice.h | 2 +- Source/Engine/Graphics/RenderView.cpp | 8 ++++++++ Source/Engine/Graphics/RenderView.h | 8 +------- Source/Engine/Renderer/Renderer.h | 3 +-- 6 files changed, 17 insertions(+), 27 deletions(-) diff --git a/Source/Engine/Core/Math/Viewport.cs b/Source/Engine/Core/Math/Viewport.cs index cf100dc9c..b375e416c 100644 --- a/Source/Engine/Core/Math/Viewport.cs +++ b/Source/Engine/Core/Math/Viewport.cs @@ -161,6 +161,11 @@ namespace FlaxEngine } } + /// + /// Gets the aspect ratio used by the viewport. + /// + public float AspectRatio => !Mathf.IsZero(Height) ? Width / Height : 0f; + /// /// Determines whether the specified is equal to this instance. /// @@ -326,21 +331,5 @@ namespace FlaxEngine vector /= w; } } - - /// - /// Gets the aspect ratio used by the viewport. - /// - /// The aspect ratio. - public float AspectRatio - { - get - { - if (!Mathf.IsZero(Height)) - { - return Width / Height; - } - return 0f; - } - } } } diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index 55657f507..74c859352 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -514,7 +514,7 @@ public: API_FIELD(ReadOnly) static BlendingMode Additive; /// - /// Gets the alpha blending. + /// Gets the alpha blending. Source alpha controls the output color (0 - use destination color, 1 - use source color). /// API_FIELD(ReadOnly) static BlendingMode AlphaBlend; diff --git a/Source/Engine/Graphics/GPUDevice.h b/Source/Engine/Graphics/GPUDevice.h index 37fc8cb87..4dbcf6d06 100644 --- a/Source/Engine/Graphics/GPUDevice.h +++ b/Source/Engine/Graphics/GPUDevice.h @@ -134,7 +134,7 @@ public: /// /// Quad rendering shader /// - GPUShader* QuadShader; + API_FIELD(ReadOnly) GPUShader* QuadShader; /// /// The current task being executed. diff --git a/Source/Engine/Graphics/RenderView.cpp b/Source/Engine/Graphics/RenderView.cpp index 736609e0c..baa5d5058 100644 --- a/Source/Engine/Graphics/RenderView.cpp +++ b/Source/Engine/Graphics/RenderView.cpp @@ -84,6 +84,14 @@ void RenderView::PrepareCache(const RenderContext& renderContext, float width, f MainScreenSize = mainView->ScreenSize; } +void RenderView::SetUp(const Matrix& viewProjection) +{ + // Copy data + Matrix::Invert(viewProjection, IVP); + Frustum.SetMatrix(viewProjection); + CullingFrustum = Frustum; +} + void RenderView::SetUp(const Matrix& view, const Matrix& projection) { // Copy data diff --git a/Source/Engine/Graphics/RenderView.h b/Source/Engine/Graphics/RenderView.h index d64e05d4b..52e317a51 100644 --- a/Source/Engine/Graphics/RenderView.h +++ b/Source/Engine/Graphics/RenderView.h @@ -255,13 +255,7 @@ public: public: // Set up view with custom params // @param viewProjection View * Projection matrix - void SetUp(const Matrix& viewProjection) - { - // Copy data - Matrix::Invert(viewProjection, IVP); - Frustum.SetMatrix(viewProjection); - CullingFrustum = Frustum; - } + void SetUp(const Matrix& viewProjection); // Set up view with custom params // @param view View matrix diff --git a/Source/Engine/Renderer/Renderer.h b/Source/Engine/Renderer/Renderer.h index 794a6dcc4..885b8ca43 100644 --- a/Source/Engine/Renderer/Renderer.h +++ b/Source/Engine/Renderer/Renderer.h @@ -29,9 +29,8 @@ public: /// Performs rendering for the input task. /// /// The scene rendering task. - static void Render(SceneRenderTask* task); + API_FUNCTION() static void Render(SceneRenderTask* task); -public: /// /// Draws scene objects depth (to the output Z buffer). The output must be depth texture to write hardware depth to it. ///