Fix some minor issues with materials previews in Editor
This commit is contained in:
@@ -47,6 +47,7 @@ namespace FlaxEditor.Content
|
||||
_preview = new CubeTexturePreview(false)
|
||||
{
|
||||
RenderOnlyWithWindow = false,
|
||||
UseAutomaticTaskManagement = false,
|
||||
AnchorPreset = AnchorPresets.StretchAll,
|
||||
Offsets = Margin.Zero,
|
||||
};
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace FlaxEditor.Content
|
||||
_preview = new MaterialPreview(false)
|
||||
{
|
||||
RenderOnlyWithWindow = false,
|
||||
UseAutomaticTaskManagement = false,
|
||||
AnchorPreset = AnchorPresets.StretchAll,
|
||||
Offsets = Margin.Zero,
|
||||
};
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace FlaxEditor.Content
|
||||
_preview = new MaterialPreview(false)
|
||||
{
|
||||
RenderOnlyWithWindow = false,
|
||||
UseAutomaticTaskManagement = false,
|
||||
AnchorPreset = AnchorPresets.StretchAll,
|
||||
Offsets = Margin.Zero,
|
||||
};
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace FlaxEditor.Content
|
||||
_preview = new ModelPreview(false)
|
||||
{
|
||||
RenderOnlyWithWindow = false,
|
||||
UseAutomaticTaskManagement = false,
|
||||
AnchorPreset = AnchorPresets.StretchAll,
|
||||
Offsets = Margin.Zero,
|
||||
};
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace FlaxEditor.Content
|
||||
_preview = new ParticleEmitterPreview(false)
|
||||
{
|
||||
RenderOnlyWithWindow = false,
|
||||
UseAutomaticTaskManagement = false,
|
||||
AnchorPreset = AnchorPresets.StretchAll,
|
||||
Offsets = Margin.Zero,
|
||||
};
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace FlaxEditor.Content
|
||||
_preview = new ParticleEmitterPreview(false)
|
||||
{
|
||||
RenderOnlyWithWindow = false,
|
||||
UseAutomaticTaskManagement = false,
|
||||
AnchorPreset = AnchorPresets.StretchAll,
|
||||
Offsets = Margin.Zero,
|
||||
};
|
||||
|
||||
@@ -97,6 +97,7 @@ namespace FlaxEditor.Content
|
||||
_preview = new PrefabPreview(false)
|
||||
{
|
||||
RenderOnlyWithWindow = false,
|
||||
UseAutomaticTaskManagement = false,
|
||||
AnchorPreset = AnchorPresets.StretchAll,
|
||||
Offsets = Margin.Zero,
|
||||
};
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace FlaxEditor.Content
|
||||
_preview = new AnimatedModelPreview(false)
|
||||
{
|
||||
RenderOnlyWithWindow = false,
|
||||
UseAutomaticTaskManagement = false,
|
||||
AnchorPreset = AnchorPresets.StretchAll,
|
||||
Offsets = Margin.Zero,
|
||||
};
|
||||
|
||||
@@ -306,6 +306,7 @@ namespace FlaxEditor.Viewport.Previews
|
||||
}
|
||||
if (_splineModel != null)
|
||||
{
|
||||
_particleEffect.IsActive = deformableMaterial != null;
|
||||
_splineModel.Model = _previewModel.Model;
|
||||
_splineModel.SetMaterial(0, deformableMaterial);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user