Merge remote-tracking branch 'origin/master' into 1.12
# Conflicts: # Flax.flaxproj
This commit is contained in:
@@ -41,6 +41,35 @@ bool Material::IsMaterialInstance() const
|
||||
return false;
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
void Material::GetReferences(Array<Guid>& assets, Array<String>& files) const
|
||||
{
|
||||
ShaderAssetTypeBase<MaterialBase>::GetReferences(assets, files);
|
||||
|
||||
// Collect references from material graph (needs to load it)
|
||||
if (!WaitForLoaded() && HasChunk(SHADER_FILE_CHUNK_VISJECT_SURFACE))
|
||||
{
|
||||
ScopeLock lock(Locker);
|
||||
if (!LoadChunks(GET_CHUNK_FLAG(SHADER_FILE_CHUNK_VISJECT_SURFACE)))
|
||||
{
|
||||
const auto surfaceChunk = GetChunk(SHADER_FILE_CHUNK_VISJECT_SURFACE);
|
||||
if (surfaceChunk)
|
||||
{
|
||||
MemoryReadStream stream(surfaceChunk->Get(), surfaceChunk->Size());
|
||||
MaterialGraph graph;
|
||||
if (!graph.Load(&stream, false))
|
||||
{
|
||||
graph.GetReferences(assets);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
const MaterialInfo& Material::GetInfo() const
|
||||
{
|
||||
if (_materialShader)
|
||||
|
||||
@@ -38,6 +38,9 @@ public:
|
||||
public:
|
||||
// [MaterialBase]
|
||||
bool IsMaterialInstance() const override;
|
||||
#if USE_EDITOR
|
||||
void GetReferences(Array<Guid>& assets, Array<String>& files) const override;
|
||||
#endif
|
||||
|
||||
// [IMaterial]
|
||||
const MaterialInfo& GetInfo() const override;
|
||||
|
||||
@@ -490,6 +490,18 @@ FORCE_INLINE DebugTriangle* AppendTriangles(int32 count, float duration, bool de
|
||||
return list->Get() + startIndex;
|
||||
}
|
||||
|
||||
FORCE_INLINE DebugTriangle* AppendWireTriangles(int32 count, float duration, bool depthTest)
|
||||
{
|
||||
Array<DebugTriangle>* list;
|
||||
if (depthTest)
|
||||
list = duration > 0 ? &Context->DebugDrawDepthTest.DefaultWireTriangles : &Context->DebugDrawDepthTest.OneFrameWireTriangles;
|
||||
else
|
||||
list = duration > 0 ? &Context->DebugDrawDefault.DefaultWireTriangles : &Context->DebugDrawDefault.OneFrameWireTriangles;
|
||||
const int32 startIndex = list->Count();
|
||||
list->AddUninitialized(count);
|
||||
return list->Get() + startIndex;
|
||||
}
|
||||
|
||||
inline void DrawText3D(const DebugText3D& t, const RenderContext& renderContext, const Float3& viewUp, const Matrix& f, const Matrix& vp, const Viewport& viewport, GPUContext* context, GPUTextureView* target, GPUTextureView* depthBuffer)
|
||||
{
|
||||
Matrix w, fw, m;
|
||||
@@ -1714,7 +1726,7 @@ void DebugDraw::DrawWireTriangles(const Span<Float3>& vertices, const Color& col
|
||||
DebugTriangle t;
|
||||
t.Color = Color32(color);
|
||||
t.TimeLeft = duration;
|
||||
auto dst = AppendTriangles(vertices.Length() / 3, duration, depthTest);
|
||||
auto dst = AppendWireTriangles(vertices.Length() / 3, duration, depthTest);
|
||||
const Float3 origin = Context->Origin;
|
||||
for (int32 i = 0; i < vertices.Length();)
|
||||
{
|
||||
@@ -1736,7 +1748,7 @@ void DebugDraw::DrawWireTriangles(const Span<Float3>& vertices, const Span<int32
|
||||
DebugTriangle t;
|
||||
t.Color = Color32(color);
|
||||
t.TimeLeft = duration;
|
||||
auto dst = AppendTriangles(indices.Length() / 3, duration, depthTest);
|
||||
auto dst = AppendWireTriangles(indices.Length() / 3, duration, depthTest);
|
||||
const Float3 origin = Context->Origin;
|
||||
for (int32 i = 0; i < indices.Length();)
|
||||
{
|
||||
@@ -1758,7 +1770,7 @@ void DebugDraw::DrawWireTriangles(const Span<Double3>& vertices, const Color& co
|
||||
DebugTriangle t;
|
||||
t.Color = Color32(color);
|
||||
t.TimeLeft = duration;
|
||||
auto dst = AppendTriangles(vertices.Length() / 3, duration, depthTest);
|
||||
auto dst = AppendWireTriangles(vertices.Length() / 3, duration, depthTest);
|
||||
const Double3 origin = Context->Origin;
|
||||
for (int32 i = 0; i < vertices.Length();)
|
||||
{
|
||||
@@ -1780,7 +1792,7 @@ void DebugDraw::DrawWireTriangles(const Span<Double3>& vertices, const Span<int3
|
||||
DebugTriangle t;
|
||||
t.Color = Color32(color);
|
||||
t.TimeLeft = duration;
|
||||
auto dst = AppendTriangles(indices.Length() / 3, duration, depthTest);
|
||||
auto dst = AppendWireTriangles(indices.Length() / 3, duration, depthTest);
|
||||
const Double3 origin = Context->Origin;
|
||||
for (int32 i = 0; i < indices.Length();)
|
||||
{
|
||||
|
||||
@@ -1075,20 +1075,25 @@ API_ENUM(Attributes="Flags") enum class ViewFlags : uint64
|
||||
/// </summary>
|
||||
LightsDebug = 1 << 27,
|
||||
|
||||
/// <summary>
|
||||
/// Shows/hides particle effects.
|
||||
/// </summary>
|
||||
Particles = 1 << 28,
|
||||
|
||||
/// <summary>
|
||||
/// Default flags for Game.
|
||||
/// </summary>
|
||||
DefaultGame = Reflections | DepthOfField | Fog | Decals | MotionBlur | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | GlobalSDF | Sky,
|
||||
DefaultGame = Reflections | DepthOfField | Fog | Decals | MotionBlur | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | GlobalSDF | Sky | Particles,
|
||||
|
||||
/// <summary>
|
||||
/// Default flags for Editor.
|
||||
/// </summary>
|
||||
DefaultEditor = Reflections | Fog | Decals | DebugDraw | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | EditorSprites | ContactShadows | GlobalSDF | Sky,
|
||||
DefaultEditor = Reflections | Fog | Decals | DebugDraw | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | EditorSprites | ContactShadows | GlobalSDF | Sky | Particles,
|
||||
|
||||
/// <summary>
|
||||
/// Default flags for materials/models previews generating.
|
||||
/// </summary>
|
||||
DefaultAssetPreview = Reflections | Decals | DirectionalLights | PointLights | SpotLights | SkyLights | SpecularLight | AntiAliasing | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | Sky,
|
||||
DefaultAssetPreview = Reflections | Decals | DirectionalLights | PointLights | SpotLights | SkyLights | SpecularLight | AntiAliasing | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | Sky | Particles,
|
||||
};
|
||||
|
||||
DECLARE_ENUM_OPERATORS(ViewFlags);
|
||||
|
||||
@@ -80,6 +80,8 @@ Delegate<const Float2&, MouseButton> Input::MouseDoubleClick;
|
||||
Delegate<const Float2&, float> Input::MouseWheel;
|
||||
Delegate<const Float2&> Input::MouseMove;
|
||||
Action Input::MouseLeave;
|
||||
Delegate<InputGamepadIndex, GamepadButton> Input::GamepadButtonDown;
|
||||
Delegate<InputGamepadIndex, GamepadButton> Input::GamepadButtonUp;
|
||||
Delegate<const Float2&, int32> Input::TouchDown;
|
||||
Delegate<const Float2&, int32> Input::TouchMove;
|
||||
Delegate<const Float2&, int32> Input::TouchUp;
|
||||
@@ -1027,6 +1029,19 @@ void InputService::Update()
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO: route gamepad button events into global InputEvents queue to improve processing
|
||||
for (int32 i = 0; i < Input::Gamepads.Count(); i++)
|
||||
{
|
||||
auto gamepad = Input::Gamepads[i];
|
||||
for (int32 buttonIdx = 1; buttonIdx < (int32)GamepadButton::MAX; buttonIdx++)
|
||||
{
|
||||
GamepadButton button = (GamepadButton)buttonIdx;
|
||||
if (gamepad->GetButtonDown(button))
|
||||
Input::GamepadButtonDown((InputGamepadIndex)i, button);
|
||||
else if (gamepad->GetButtonUp(button))
|
||||
Input::GamepadButtonUp((InputGamepadIndex)i, button);
|
||||
}
|
||||
}
|
||||
|
||||
// Update all actions
|
||||
for (int32 i = 0; i < Input::ActionMappings.Count(); i++)
|
||||
|
||||
@@ -113,6 +113,16 @@ public:
|
||||
/// </summary>
|
||||
API_EVENT() static Action MouseLeave;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when gamepad button goes down.
|
||||
/// </summary>
|
||||
API_EVENT() static Delegate<InputGamepadIndex, GamepadButton> GamepadButtonDown;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when gamepad button goes up.
|
||||
/// </summary>
|
||||
API_EVENT() static Delegate<InputGamepadIndex, GamepadButton> GamepadButtonUp;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when touch action begins.
|
||||
/// </summary>
|
||||
|
||||
@@ -601,7 +601,9 @@ bool ParticleEffect::HasContentLoaded() const
|
||||
|
||||
void ParticleEffect::Draw(RenderContext& renderContext)
|
||||
{
|
||||
if (renderContext.View.Pass == DrawPass::GlobalSDF || renderContext.View.Pass == DrawPass::GlobalSurfaceAtlas)
|
||||
if (renderContext.View.Pass == DrawPass::GlobalSDF ||
|
||||
renderContext.View.Pass == DrawPass::GlobalSurfaceAtlas ||
|
||||
EnumHasNoneFlags(renderContext.View.Flags, ViewFlags::Particles))
|
||||
return;
|
||||
_lastMinDstSqr = Math::Min(_lastMinDstSqr, Vector3::DistanceSquared(GetPosition(), renderContext.View.WorldPosition));
|
||||
RenderContextBatch renderContextBatch(renderContext);
|
||||
@@ -610,10 +612,12 @@ void ParticleEffect::Draw(RenderContext& renderContext)
|
||||
|
||||
void ParticleEffect::Draw(RenderContextBatch& renderContextBatch)
|
||||
{
|
||||
const RenderView& mainView = renderContextBatch.GetMainContext().View;
|
||||
if (EnumHasNoneFlags(mainView.Flags, ViewFlags::Particles))
|
||||
return;
|
||||
Particles::DrawParticles(renderContextBatch, this);
|
||||
|
||||
// Cull again against the main context (if using multiple ones) to skip caching draw distance from shadow projections
|
||||
const RenderView& mainView = renderContextBatch.GetMainContext().View;
|
||||
const BoundingSphere bounds(_sphere.Center - mainView.Origin, _sphere.Radius);
|
||||
if (renderContextBatch.Contexts.Count() > 1 && !mainView.CullingFrustum.Intersects(bounds))
|
||||
return;
|
||||
|
||||
@@ -23,15 +23,15 @@ void BoxCollider::SetSize(const Float3& value)
|
||||
void BoxCollider::AutoResize(bool globalOrientation = true)
|
||||
{
|
||||
Actor* parent = GetParent();
|
||||
if (Cast<Scene>(parent))
|
||||
if (parent == nullptr || Cast<Scene>(parent))
|
||||
return;
|
||||
|
||||
// Get bounds of all siblings (excluding itself)
|
||||
const Vector3 parentScale = parent->GetScale();
|
||||
if (parentScale.IsAnyZero())
|
||||
return; // Avoid division by zero
|
||||
return;
|
||||
|
||||
// Hacky way to get unrotated bounded box of parent.
|
||||
// Hacky way to get unrotated bounded box of parent
|
||||
const Quaternion parentOrientation = parent->GetOrientation();
|
||||
parent->SetOrientation(Quaternion::Identity);
|
||||
BoundingBox parentBox = parent->GetBox();
|
||||
|
||||
@@ -137,8 +137,8 @@ namespace FlaxEngine
|
||||
{
|
||||
Debug.LogError($"Unhandled Exception: {exception.Message}");
|
||||
Debug.LogException(exception);
|
||||
if (e.IsTerminating && !System.Diagnostics.Debugger.IsAttached)
|
||||
Platform.Fatal($"Unhandled Exception: {exception}");
|
||||
//if (e.IsTerminating && !System.Diagnostics.Debugger.IsAttached)
|
||||
// Platform.Fatal($"Unhandled Exception: {exception}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ namespace FlaxEngine.GUI
|
||||
[ActorToolbox("GUI")]
|
||||
public class DropPanel : ContainerControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Size of the drop down icon.
|
||||
/// </summary>
|
||||
public const float DropDownIconSize = 14.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The header height.
|
||||
/// </summary>
|
||||
@@ -368,7 +373,7 @@ namespace FlaxEngine.GUI
|
||||
var style = Style.Current;
|
||||
var enabled = EnabledInHierarchy;
|
||||
|
||||
// Paint Background
|
||||
// Draw Background
|
||||
var backgroundColor = BackgroundColor;
|
||||
if (backgroundColor.A > 0.0f)
|
||||
{
|
||||
@@ -386,7 +391,7 @@ namespace FlaxEngine.GUI
|
||||
float textLeft = 0;
|
||||
if (EnableDropDownIcon)
|
||||
{
|
||||
textLeft += 14;
|
||||
textLeft += DropDownIconSize;
|
||||
var dropDownRect = new Rectangle(2, (HeaderHeight - 12) / 2, 12, 12);
|
||||
var arrowColor = _mouseOverHeader ? style.Foreground : style.ForegroundGrey;
|
||||
if (_isClosed)
|
||||
@@ -395,7 +400,7 @@ namespace FlaxEngine.GUI
|
||||
ArrowImageOpened?.Draw(dropDownRect, arrowColor);
|
||||
}
|
||||
|
||||
// Text
|
||||
// Header text
|
||||
var textRect = new Rectangle(textLeft, 0, Width - textLeft, HeaderHeight);
|
||||
_headerTextMargin.ShrinkRectangle(ref textRect);
|
||||
var textColor = HeaderTextColor;
|
||||
@@ -404,7 +409,9 @@ namespace FlaxEngine.GUI
|
||||
textColor *= 0.6f;
|
||||
}
|
||||
|
||||
Render2D.PushClip(textRect);
|
||||
Render2D.DrawText(HeaderTextFont.GetFont(), HeaderTextMaterial, HeaderText, textRect, textColor, TextAlignment.Near, TextAlignment.Center);
|
||||
Render2D.PopClip();
|
||||
|
||||
if (!_isClosed && EnableContainmentLines)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user