Fix Editor crash when dragging material over CSG brush Surface

#640
This commit is contained in:
Wojtek Figat
2021-10-05 21:34:45 +02:00
parent 3e04a15fe5
commit 1b88f8ce3f

View File

@@ -92,8 +92,12 @@ namespace FlaxEditor
/// <param name="renderContext">The rendering context.</param> /// <param name="renderContext">The rendering context.</param>
public virtual void OnDraw(ref RenderContext renderContext) public virtual void OnDraw(ref RenderContext renderContext)
{ {
if (_highlightMaterial == null) if (_highlightMaterial == null
|| (_highlights.Count == 0 && _highlightTriangles.Count == 0)
|| renderContext.View.Pass == DrawPass.Depth
)
return; return;
Profiler.BeginEvent("ViewportDebugDrawData.OnDraw");
Matrix world; Matrix world;
for (var i = 0; i < _highlights.Count; i++) for (var i = 0; i < _highlights.Count; i++)
@@ -104,10 +108,8 @@ namespace FlaxEditor
var model = staticModel.Model; var model = staticModel.Model;
if (model == null) if (model == null)
continue; continue;
staticModel.Transform.GetWorld(out world); staticModel.Transform.GetWorld(out world);
var bounds = BoundingSphere.FromBox(staticModel.Box);
BoundingSphere bounds = BoundingSphere.FromBox(staticModel.Box);
// Pick a proper LOD // Pick a proper LOD
int lodIndex = RenderTools.ComputeModelLOD(model, ref bounds.Center, bounds.Radius, ref renderContext); int lodIndex = RenderTools.ComputeModelLOD(model, ref bounds.Center, bounds.Radius, ref renderContext);
@@ -142,6 +144,8 @@ namespace FlaxEditor
world = Matrix.Identity; world = Matrix.Identity;
mesh.Draw(ref renderContext, _highlightMaterial, ref world); mesh.Draw(ref renderContext, _highlightMaterial, ref world);
} }
Profiler.EndEvent();
} }
/// <summary> /// <summary>