Fix some minor issues with materials previews in Editor

This commit is contained in:
Wojtek Figat
2021-02-25 16:38:05 +01:00
parent 26607c1d09
commit 4d73b271b8
12 changed files with 40 additions and 11 deletions

View File

@@ -47,6 +47,7 @@ namespace FlaxEditor.Content
_preview = new CubeTexturePreview(false)
{
RenderOnlyWithWindow = false,
UseAutomaticTaskManagement = false,
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
};

View File

@@ -54,6 +54,7 @@ namespace FlaxEditor.Content
_preview = new MaterialPreview(false)
{
RenderOnlyWithWindow = false,
UseAutomaticTaskManagement = false,
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
};

View File

@@ -100,6 +100,7 @@ namespace FlaxEditor.Content
_preview = new MaterialPreview(false)
{
RenderOnlyWithWindow = false,
UseAutomaticTaskManagement = false,
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
};

View File

@@ -61,6 +61,7 @@ namespace FlaxEditor.Content
_preview = new ModelPreview(false)
{
RenderOnlyWithWindow = false,
UseAutomaticTaskManagement = false,
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
};

View File

@@ -55,6 +55,7 @@ namespace FlaxEditor.Content
_preview = new ParticleEmitterPreview(false)
{
RenderOnlyWithWindow = false,
UseAutomaticTaskManagement = false,
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
};

View File

@@ -55,6 +55,7 @@ namespace FlaxEditor.Content
_preview = new ParticleEmitterPreview(false)
{
RenderOnlyWithWindow = false,
UseAutomaticTaskManagement = false,
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
};

View File

@@ -97,6 +97,7 @@ namespace FlaxEditor.Content
_preview = new PrefabPreview(false)
{
RenderOnlyWithWindow = false,
UseAutomaticTaskManagement = false,
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
};

View File

@@ -47,6 +47,7 @@ namespace FlaxEditor.Content
_preview = new AnimatedModelPreview(false)
{
RenderOnlyWithWindow = false,
UseAutomaticTaskManagement = false,
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
};

View File

@@ -306,6 +306,7 @@ namespace FlaxEditor.Viewport.Previews
}
if (_splineModel != null)
{
_particleEffect.IsActive = deformableMaterial != null;
_splineModel.Model = _previewModel.Model;
_splineModel.SetMaterial(0, deformableMaterial);
}

View File

@@ -227,6 +227,21 @@ void SceneRenderTask::CameraCut()
IsCameraCut = true;
}
void SceneRenderTask::AddCustomActor(Actor* actor)
{
CustomActors.Add(actor);
}
void SceneRenderTask::RemoveCustomActor(Actor* actor)
{
CustomActors.Remove(actor);
}
void SceneRenderTask::ClearCustomActors()
{
CustomActors.Clear();
}
void SceneRenderTask::CollectPostFxVolumes(RenderContext& renderContext)
{
if ((ActorsSource & ActorsSources::Scenes) != 0)

View File

@@ -272,19 +272,18 @@ public:
/// Adds the custom actor to the rendering.
/// </summary>
/// <param name="actor">The actor.</param>
API_FUNCTION() void AddCustomActor(Actor* actor)
{
CustomActors.Add(actor);
}
API_FUNCTION() void AddCustomActor(Actor* actor);
/// <summary>
/// Removes the custom actor from the rendering.
/// </summary>
/// <param name="actor">The actor.</param>
API_FUNCTION() void RemoveCustomActor(Actor* actor)
{
CustomActors.Remove(actor);
}
API_FUNCTION() void RemoveCustomActor(Actor* actor);
/// <summary>
/// Removes all the custom actors from the rendering.
/// </summary>
API_FUNCTION() void ClearCustomActors();
/// <summary>
/// The custom post fx to render (managed).

View File

@@ -42,10 +42,15 @@ namespace FlaxEngine.GUI
public SceneRenderTask Task => _task;
/// <summary>
/// Gets a value indicating whether render to that output only if parent window exists, otherwise false.
/// Gets or sets a value indicating whether render to that output only if parent window exists, otherwise false.
/// </summary>
public bool RenderOnlyWithWindow { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether use automatic task rendering skipping if output is too small or window is missing. Disable it to manually control <see cref="RenderTask.Enabled"/>.
/// </summary>
public bool UseAutomaticTaskManagement { get; set; } = true;
/// <summary>
/// Gets a value indicating whether keep aspect ratio of the backbuffer image, otherwise false.
/// </summary>
@@ -153,7 +158,7 @@ namespace FlaxEngine.GUI
private void OnUpdate()
{
if (_task == null)
if (_task == null || !UseAutomaticTaskManagement)
return;
var deltaTime = Time.UnscaledDeltaTime;
@@ -168,7 +173,7 @@ namespace FlaxEngine.GUI
// Check if skip rendering
var wasEnabled = _task.Enabled;
_task.Enabled = !CanSkipRendering();
if (wasEnabled != _task.Enabled)
if (!wasEnabled && _task.Enabled)
{
SyncBackbufferSize();
}
@@ -263,6 +268,7 @@ namespace FlaxEngine.GUI
if (_task != null)
{
_task.Enabled = false;
_task.ClearCustomActors();
//_task.CustomPostFx.Clear();
}
Object.Destroy(ref _backBuffer);