Merge remote-tracking branch 'origin/1.1' into linux-editor

# Conflicts:
#	Source/Engine/Core/Math/BoundingSphere.cs
#	Source/Engine/Debug/DebugDraw.cpp
#	Source/Engine/Platform/Win32/Win32Platform.cpp
#	Source/Engine/Platform/Win32/Win32Platform.h
This commit is contained in:
Wojtek Figat
2021-02-23 22:32:17 +01:00
129 changed files with 6085 additions and 1891 deletions

View File

@@ -245,7 +245,7 @@ bool ParticleEmitterGraphCPUExecutor::ComputeBounds(ParticleEmitter* emitter, Pa
_emitter = emitter;
_effect = effect;
_deltaTime = 0.0f;
_viewTask = PARTICLE_EMITTER_GET_VIEW_TASK(effect);
_viewTask = effect->GetRenderTask();
_callStack.Clear();
// Find the maximum radius of the particle light
@@ -351,7 +351,7 @@ void ParticleEmitterGraphCPUExecutor::Draw(ParticleEmitter* emitter, ParticleEff
_emitter = emitter;
_effect = effect;
_deltaTime = 0.0f;
_viewTask = PARTICLE_EMITTER_GET_VIEW_TASK(effect);
_viewTask = effect->GetRenderTask();
_callStack.Clear();
// Draw lights
@@ -411,7 +411,7 @@ void ParticleEmitterGraphCPUExecutor::Update(ParticleEmitter* emitter, ParticleE
_effect = effect;
_particleIndex = 0;
_deltaTime = dt;
_viewTask = PARTICLE_EMITTER_GET_VIEW_TASK(effect);
_viewTask = effect->GetRenderTask();
_callStack.Clear();
auto& cpu = data.Buffer->CPU;
@@ -557,7 +557,7 @@ int32 ParticleEmitterGraphCPUExecutor::UpdateSpawn(ParticleEmitter* emitter, Par
_effect = effect;
_particleIndex = 0;
_deltaTime = dt;
_viewTask = PARTICLE_EMITTER_GET_VIEW_TASK(effect);
_viewTask = effect->GetRenderTask();
_callStack.Clear();
// Spawn particles

View File

@@ -27,11 +27,6 @@ class ParticleEmitterGraphCPUExecutor;
#define PARTICLE_EMITTER_MAX_CALL_STACK 100
// Gets the render task for the given effect update
#define PARTICLE_EMITTER_GET_VIEW_TASK(effect) \
(SceneRenderTask*)((effect)->CustomViewRenderTask && (effect)->CustomViewRenderTask->LastUsedFrame != 0 ? (effect)->CustomViewRenderTask.Get() : \
(MainRenderTask::Instance && MainRenderTask::Instance->LastUsedFrame != 0 ? MainRenderTask::Instance : nullptr))
class ParticleEmitterGraphCPUBox : public VisjectGraphBox
{
public:

View File

@@ -144,7 +144,7 @@ void GPUParticles::Execute(GPUContext* context, ParticleEmitter* emitter, Partic
}
// Skip if can
SceneRenderTask* viewTask = PARTICLE_EMITTER_GET_VIEW_TASK(effect);
SceneRenderTask* viewTask = effect->GetRenderTask();
const int32 threads = data.Buffer->GPU.ParticlesCountMax + data.GPU.SpawnCount;
if (data.GPU.DeltaTime <= 0.0f || threads == 0 || !_mainCS)
return;

View File

@@ -339,6 +339,39 @@ void ParticleEffect::Sync()
}
}
SceneRenderTask* ParticleEffect::GetRenderTask() const
{
const uint64 minFrame = Engine::FrameCount - 2;
// Custom task
const auto customViewRenderTask = CustomViewRenderTask.Get();
if (customViewRenderTask && customViewRenderTask->Enabled && customViewRenderTask->LastUsedFrame >= minFrame)
return customViewRenderTask;
// Main task
const auto mainRenderTask = MainRenderTask::Instance;
if (mainRenderTask && mainRenderTask->Enabled && mainRenderTask->LastUsedFrame >= minFrame)
return mainRenderTask;
// Editor viewport
#if USE_EDITOR
for (auto task : RenderTask::Tasks)
{
if (task->LastUsedFrame >= minFrame && task->Enabled)
{
if (const auto sceneRenderTask = Cast<SceneRenderTask>(task))
{
if (sceneRenderTask->ActorsSource == ActorsSources::Scenes)
{
return sceneRenderTask;
}
}
}
}
#endif
return nullptr;
}
#if USE_EDITOR
Array<ParticleEffect::ParameterOverride> ParticleEffect::GetParametersOverrides()
@@ -373,6 +406,18 @@ void ParticleEffect::Update()
UpdateSimulation();
}
#if USE_EDITOR
#include "Editor/Editor.h"
void ParticleEffect::UpdateExecuteInEditor()
{
if (!Editor::IsPlayMode)
Update();
}
#endif
void ParticleEffect::CacheModifiedParameters()
{
if (_parameters.IsEmpty())
@@ -649,6 +694,7 @@ void ParticleEffect::OnEnable()
GetSceneRendering()->AddGeometry(this);
#if USE_EDITOR
GetSceneRendering()->AddViewportIcon(this);
GetScene()->Ticking.Update.AddTickExecuteInEditor<ParticleEffect, &ParticleEffect::UpdateExecuteInEditor>(this);
#endif
// Base
@@ -658,6 +704,7 @@ void ParticleEffect::OnEnable()
void ParticleEffect::OnDisable()
{
#if USE_EDITOR
GetScene()->Ticking.Update.RemoveTickExecuteInEditor(this);
GetSceneRendering()->RemoveViewportIcon(this);
#endif
GetSceneRendering()->RemoveGeometry(this);

View File

@@ -356,6 +356,11 @@ public:
/// </summary>
void Sync();
/// <summary>
/// Gets the render task to use for particles simulation (eg. depth buffer collisions or view information).
/// </summary>
SceneRenderTask* GetRenderTask() const;
#if USE_EDITOR
protected:
// Exposed parameters overrides for Editor Undo.
@@ -366,6 +371,9 @@ protected:
private:
void Update();
#if USE_EDITOR
void UpdateExecuteInEditor();
#endif
void CacheModifiedParameters();
void ApplyModifiedParameters();
void OnParticleSystemModified();

View File

@@ -17,6 +17,9 @@
#include "Engine/Profiler/ProfilerGPU.h"
#include "Engine/Renderer/Utils/BitonicSort.h"
#endif
#if USE_EDITOR
#include "Editor/Editor.h"
#endif
struct SpriteParticleVertex
{
@@ -1155,6 +1158,13 @@ void ParticleManagerService::Update()
// Simulation delta time can be based on a time since last update or the current delta time
float dt = effect->UseTimeScale ? deltaTime : deltaTimeUnscaled;
float t = effect->UseTimeScale ? time : timeUnscaled;
#if USE_EDITOR
if (!Editor::IsPlayMode)
{
dt = deltaTimeUnscaled;
t = timeUnscaled;
}
#endif
const float lastUpdateTime = instance.LastUpdateTime;
if (lastUpdateTime > 0 && t > lastUpdateTime)
{