mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-15 14:52:35 +02:00
Guess we're doing render trees for lights and occluders aswell.
This commit is contained in:
@@ -84,26 +84,29 @@ namespace Robust.Client.Graphics.Clyde
|
||||
var worldBounds = Box2.CenteredAround(eye.Position.Position,
|
||||
_framebufferSize / (float) EyeManager.PixelsPerMeter * eye.Zoom);
|
||||
|
||||
using (DebugGroup("Lights"))
|
||||
if (_eyeManager.CurrentMap != MapId.Nullspace)
|
||||
{
|
||||
DrawLightsAndFov(worldBounds, eye);
|
||||
}
|
||||
using (DebugGroup("Lights"))
|
||||
{
|
||||
DrawLightsAndFov(worldBounds, eye);
|
||||
}
|
||||
|
||||
using (DebugGroup("Grids"))
|
||||
{
|
||||
_drawGrids(worldBounds);
|
||||
}
|
||||
using (DebugGroup("Grids"))
|
||||
{
|
||||
_drawGrids(worldBounds);
|
||||
}
|
||||
|
||||
using (DebugGroup("Entities"))
|
||||
{
|
||||
DrawEntities(worldBounds);
|
||||
}
|
||||
using (DebugGroup("Entities"))
|
||||
{
|
||||
DrawEntities(worldBounds);
|
||||
}
|
||||
|
||||
RenderOverlays(OverlaySpace.WorldSpace);
|
||||
RenderOverlays(OverlaySpace.WorldSpace);
|
||||
|
||||
if (_lightManager.Enabled && eye.DrawFov)
|
||||
{
|
||||
ApplyFovToBuffer(eye);
|
||||
if (_lightManager.Enabled && eye.DrawFov)
|
||||
{
|
||||
ApplyFovToBuffer(eye);
|
||||
}
|
||||
}
|
||||
|
||||
_lightingReady = false;
|
||||
@@ -217,9 +220,9 @@ namespace Robust.Client.Graphics.Clyde
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void ProcessSpriteEntities(MapId map, Box2 worldBounds, RefList<(SpriteComponent sprite, Matrix3 matrix, Angle worldRot, float yWorldPos)> list)
|
||||
{
|
||||
var spriteSystem = _entitySystemManager.GetEntitySystem<SpriteSystem>();
|
||||
var spriteSystem = _entitySystemManager.GetEntitySystem<RenderingTreeSystem>();
|
||||
|
||||
var tree = spriteSystem.GetTreeForMap(map);
|
||||
var tree = spriteSystem.GetSpriteTreeForMap(map);
|
||||
|
||||
var sprites = tree.Query(worldBounds, true);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using OpenToolkit.Graphics.OpenGL4;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.GameObjects.EntitySystems;
|
||||
using Robust.Client.Graphics.ClientEye;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.Interfaces.Graphics.ClientEye;
|
||||
@@ -464,31 +465,27 @@ namespace Robust.Client.Graphics.Clyde
|
||||
// (if the occluder is in the current lights at all, it's still not between the light and the world bounds).
|
||||
var expandedBounds = worldBounds;
|
||||
|
||||
foreach (var component in _componentManager.GetAllComponents<PointLightComponent>())
|
||||
var renderingTreeSystem = _entitySystemManager.GetEntitySystem<RenderingTreeSystem>();
|
||||
var lightTree = renderingTreeSystem.GetLightTreeForMap(map);
|
||||
|
||||
foreach (var component in lightTree.Query(worldBounds))
|
||||
{
|
||||
var transform = component.Owner.Transform;
|
||||
|
||||
if (!component.Enabled || transform.MapID != map)
|
||||
if (!component.Enabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var lightPos = transform.WorldMatrix.Transform(component.Offset);
|
||||
|
||||
var lightBounds = Box2.CenteredAround(lightPos, Vector2.One * component.Radius * 2);
|
||||
|
||||
if (!lightBounds.Intersects(worldBounds))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
lights.Add((component, lightPos));
|
||||
|
||||
expandedBounds = expandedBounds.ExtendToContain(lightPos);
|
||||
|
||||
if (lights.Count == MaxLightsPerScene)
|
||||
{
|
||||
// TODO: Allow more than 64 lights.
|
||||
// TODO: Allow more than MaxLightsPerScene lights.
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -634,10 +631,6 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
using var _ = DebugGroup(nameof(UpdateOcclusionGeometry));
|
||||
|
||||
// TODO: More accurate bounds check.
|
||||
// Yeah just enlarge it a wee bit to accomodate for large occluders maybe. Oh well.
|
||||
expandedBounds.Enlarged(2);
|
||||
|
||||
var arrayBuffer = ArrayPool<Vector3>.Shared.Rent(maxOccluders * 8);
|
||||
var indexBuffer = ArrayPool<ushort>.Shared.Rent(maxOccluders * 20);
|
||||
|
||||
@@ -646,15 +639,18 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
try
|
||||
{
|
||||
var renderingTreeSystem = _entitySystemManager.GetEntitySystem<RenderingTreeSystem>();
|
||||
var occluderTree = renderingTreeSystem.GetOccluderTreeForMap(map);
|
||||
|
||||
var ai = 0;
|
||||
var ami = 0;
|
||||
var ii = 0;
|
||||
var imi = 0;
|
||||
|
||||
foreach (var occluder in _componentManager.GetAllComponents<ClientOccluderComponent>())
|
||||
foreach (var occluder in occluderTree.Query(expandedBounds))
|
||||
{
|
||||
var transform = occluder.Owner.Transform;
|
||||
if (!occluder.Enabled || transform.MapID != map)
|
||||
if (!occluder.Enabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -662,13 +658,6 @@ namespace Robust.Client.Graphics.Clyde
|
||||
var worldTransform = transform.WorldMatrix;
|
||||
var box = occluder.BoundingBox;
|
||||
|
||||
var centerPos = (worldTransform.R0C2, worldTransform.R1C2);
|
||||
|
||||
if (!expandedBounds.Contains(centerPos))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// So uh, angle 0 = east... Apparently...
|
||||
// We account for that here so I don't go insane.
|
||||
var (tlX, tlY) = worldTransform.Transform(box.BottomLeft);
|
||||
|
||||
Reference in New Issue
Block a user