mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Transitioned from VectorX to floatX
And some trying to update Rigidbody when transform changes
This commit is contained in:
@@ -188,9 +188,9 @@ namespace GlitchyEngine.Renderer.Animation
|
||||
|
||||
class JointAnimation// : IDisposable
|
||||
{
|
||||
public JointAnimationChannel<Vector3> TranslationChannel ~ delete _;
|
||||
public JointAnimationChannel<float3> TranslationChannel ~ delete _;
|
||||
public JointAnimationChannel<Quaternion> RotationChannel ~ delete _;
|
||||
public JointAnimationChannel<Vector3> ScaleChannel ~ delete _;
|
||||
public JointAnimationChannel<float3> ScaleChannel ~ delete _;
|
||||
|
||||
public float Duration
|
||||
{
|
||||
@@ -221,7 +221,7 @@ namespace GlitchyEngine.Renderer.Animation
|
||||
case .Step:
|
||||
result.Translation = previous;
|
||||
case .Linear:
|
||||
result.Translation = Vector3.Lerp(previous, next, interpolationValue);
|
||||
result.Translation = lerp(previous, next, interpolationValue);
|
||||
default:
|
||||
result.Rotation = ?;
|
||||
Runtime.NotImplemented();
|
||||
@@ -262,7 +262,7 @@ namespace GlitchyEngine.Renderer.Animation
|
||||
case .Step:
|
||||
result.Scale = previous;
|
||||
case .Linear:
|
||||
result.Scale = Vector3.Lerp(previous, next, interpolationValue);
|
||||
result.Scale = lerp(previous, next, interpolationValue);
|
||||
default:
|
||||
result.Rotation = ?;
|
||||
Runtime.NotImplemented();
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace GlitchyEngine.Renderer.Animation
|
||||
public struct JointPose
|
||||
{
|
||||
public Quaternion Rotation;
|
||||
public Vector3 Translation;
|
||||
public Vector3 Scale;
|
||||
public float3 Translation;
|
||||
public float3 Scale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
case typeof(float):
|
||||
EnsureTypeMatch(1, 1, .Float);
|
||||
case typeof(Vector2):
|
||||
case typeof(float2):
|
||||
EnsureTypeMatch(1, 2, .Float);
|
||||
case typeof(Vector3):
|
||||
case typeof(float3):
|
||||
EnsureTypeMatch(1, 3, .Float);
|
||||
case typeof(Vector4):
|
||||
case typeof(float4):
|
||||
EnsureTypeMatch(1, 4, .Float);
|
||||
|
||||
case typeof(int32):
|
||||
@@ -132,9 +132,9 @@ namespace GlitchyEngine.Renderer
|
||||
public void SetData(bool value) => SetData<bool>(value);
|
||||
|
||||
public void SetData(float value) => SetData<float>(value);
|
||||
public void SetData(Vector2 value) => SetData<Vector2>(value);
|
||||
public void SetData(Vector3 value) => SetData<Vector3>(value);
|
||||
public void SetData(Vector4 value) => SetData<Vector4>(value);
|
||||
public void SetData(float2 value) => SetData<float2>(value);
|
||||
public void SetData(float3 value) => SetData<float3>(value);
|
||||
public void SetData(float4 value) => SetData<float4>(value);
|
||||
|
||||
public void SetData(int32 value) => SetData<int32>(value);
|
||||
public void SetData(Int2 value) => SetData<Int2>(value);
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace GlitchyEngine.Renderer
|
||||
protected float _nearPlane;
|
||||
protected float _farPlane;
|
||||
|
||||
protected Vector3 _position;
|
||||
protected Vector3 _rotation;
|
||||
protected float3 _position;
|
||||
protected float3 _rotation;
|
||||
|
||||
/// If true the transform matrix is outdated and needs to be recalculated.
|
||||
protected bool _transformOutdated = true;
|
||||
@@ -76,12 +76,12 @@ namespace GlitchyEngine.Renderer
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Position
|
||||
public float3 Position
|
||||
{
|
||||
get => _position;
|
||||
set
|
||||
{
|
||||
if(_position == value)
|
||||
if(all(_position == value))
|
||||
return;
|
||||
|
||||
_position = value;
|
||||
@@ -89,12 +89,12 @@ namespace GlitchyEngine.Renderer
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Rotation
|
||||
public float3 Rotation
|
||||
{
|
||||
get => _rotation;
|
||||
set
|
||||
{
|
||||
if(_rotation == value)
|
||||
if(all(_rotation == value))
|
||||
return;
|
||||
|
||||
_rotation = value;
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
if(length != 0.0f)
|
||||
{
|
||||
transform.Columns[0]..Normalize() *= length;
|
||||
transform.Columns[1]..Normalize() *= length;
|
||||
transform.Columns[2]..Normalize() *= length;
|
||||
transform.Columns[0] = normalize(transform.Columns[0]) * length;
|
||||
transform.Columns[1] = normalize(transform.Columns[1]) * length;
|
||||
transform.Columns[2] = normalize(transform.Columns[2]) * length;
|
||||
}
|
||||
|
||||
Renderer.DrawLine(.Zero, .Right, .Red, transform);
|
||||
@@ -66,7 +66,7 @@ namespace GlitchyEngine.Renderer
|
||||
_frustumGeometry = new GeometryBinding();
|
||||
_frustumGeometry.SetPrimitiveTopology(.LineList);
|
||||
|
||||
_frustumVertices = new VertexBuffer(typeof(Vector4), 8, .Dynamic, .Write);
|
||||
_frustumVertices = new VertexBuffer(typeof(float4), 8, .Dynamic, .Write);
|
||||
_frustumGeometry.SetVertexBufferSlot(_frustumVertices, 0);
|
||||
|
||||
using (IndexBuffer indexBuffer = new IndexBuffer(24, .Immutable))
|
||||
@@ -109,7 +109,7 @@ namespace GlitchyEngine.Renderer
|
||||
2, 6,
|
||||
3, 7);
|
||||
|
||||
Vector4[8] corners;
|
||||
float4[8] corners;
|
||||
// Perspective
|
||||
if(projection._43 != 0.0f)
|
||||
{
|
||||
@@ -121,7 +121,7 @@ namespace GlitchyEngine.Renderer
|
||||
float gOverS = projection._11;
|
||||
float g = projection._22;
|
||||
|
||||
//var corners = //(Vector4*)&_vbFrustum.Data;
|
||||
//var corners = //(float4*)&_vbFrustum.Data;
|
||||
|
||||
if(Math.Abs(d1) >= 10000)
|
||||
{
|
||||
@@ -167,7 +167,7 @@ namespace GlitchyEngine.Renderer
|
||||
float n = -projection._34 / projection._33;
|
||||
float f = (1 - projection._34) / projection._33;
|
||||
|
||||
//var corners = (Vector4*)&_vbFrustum.Data;
|
||||
//var corners = (float4*)&_vbFrustum.Data;
|
||||
corners[0] = .(r, t, n, 1.0f);
|
||||
corners[1] = .(r, b, n, 1.0f);
|
||||
corners[2] = .(l, b, n, 1.0f);
|
||||
|
||||
@@ -602,11 +602,11 @@ public class Effect : Asset
|
||||
}
|
||||
|
||||
if (numComponents == 2)
|
||||
return Variant.Create(*(Vector2*)floats.Ptr);
|
||||
return Variant.Create(*(float2*)floats.Ptr);
|
||||
else if (numComponents == 3)
|
||||
return Variant.Create(*(Vector3*)floats.Ptr);
|
||||
return Variant.Create(*(float3*)floats.Ptr);
|
||||
else if (numComponents == 4)
|
||||
return Variant.Create(*(Vector4*)floats.Ptr);
|
||||
return Variant.Create(*(float4*)floats.Ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace GlitchyEngine.Renderer
|
||||
s_fullscreenQuadGeometry = new GeometryBinding();
|
||||
s_fullscreenQuadGeometry.SetPrimitiveTopology(.TriangleList);
|
||||
|
||||
using(var quadVertices = new VertexBuffer(typeof(Vector4), 3, .Immutable))
|
||||
using(var quadVertices = new VertexBuffer(typeof(float4), 3, .Immutable))
|
||||
{
|
||||
Vector4[4] vertices = .(
|
||||
float4[4] vertices = .(
|
||||
.(-1, 1, 0, 0),
|
||||
.( 3, 1, 2, 0),
|
||||
.(-1,-3, 0, 2),
|
||||
|
||||
@@ -119,9 +119,9 @@ public class Material : Asset
|
||||
}
|
||||
|
||||
public void SetVariable(String name, float value) => SetVariable<float>(name, value);
|
||||
public void SetVariable(String name, Vector2 value) => SetVariable<Vector2>(name, value);
|
||||
public void SetVariable(String name, Vector3 value) => SetVariable<Vector3>(name, value);
|
||||
public void SetVariable(String name, Vector4 value) => SetVariable<Vector4>(name, value);
|
||||
public void SetVariable(String name, float2 value) => SetVariable<float2>(name, value);
|
||||
public void SetVariable(String name, float3 value) => SetVariable<float3>(name, value);
|
||||
public void SetVariable(String name, float4 value) => SetVariable<float4>(name, value);
|
||||
|
||||
public void SetVariable(String name, int32 value) => SetVariable<int32>(name, value);
|
||||
public void SetVariable(String name, Int2 value) => SetVariable<Int2>(name, value);
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace GlitchyEngine.Renderer
|
||||
struct SceneConstants
|
||||
{
|
||||
public Matrix ViewProjection;
|
||||
public Vector3 CameraPosition;
|
||||
public float3 CameraPosition;
|
||||
public RenderTargetGroup CameraTarget;
|
||||
public RenderTargetGroup CompositionTarget;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace GlitchyEngine.Renderer
|
||||
public Matrix4x3 Transform_InvT;
|
||||
|
||||
public uint32 EntityId;
|
||||
private Vector3 _padding;
|
||||
private float3 _padding;
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
@@ -138,9 +138,9 @@ namespace GlitchyEngine.Renderer
|
||||
LineGeometry = new GeometryBinding();
|
||||
LineGeometry.SetPrimitiveTopology(.LineList);
|
||||
|
||||
Vector4[2] vertices = .(.Zero, .Zero);
|
||||
LineVertices = new VertexBuffer(sizeof(Vector4), 2, .Dynamic, .Write);
|
||||
LineVertices.SetData<Vector4>(vertices, 0, .WriteDiscard);
|
||||
float4[2] vertices = .(.Zero, .Zero);
|
||||
LineVertices = new VertexBuffer(sizeof(float4), 2, .Dynamic, .Write);
|
||||
LineVertices.SetData<float4>(vertices, 0, .WriteDiscard);
|
||||
LineGeometry.SetVertexBufferSlot(LineVertices, 0);
|
||||
|
||||
uint16[2] indices = .(0, 1);
|
||||
@@ -254,8 +254,8 @@ namespace GlitchyEngine.Renderer
|
||||
// Material and Mesh equal: sort by distance
|
||||
if (cmp == 0)
|
||||
{
|
||||
float distLeftSq = Vector3.DistanceSquared(_sceneConstants.CameraPosition, left.Transform.Translation);
|
||||
float distRightSq = Vector3.DistanceSquared(_sceneConstants.CameraPosition, right.Transform.Translation);
|
||||
float distLeftSq = distanceSq(_sceneConstants.CameraPosition, left.Transform.Translation);
|
||||
float distRightSq = distanceSq(_sceneConstants.CameraPosition, right.Transform.Translation);
|
||||
|
||||
// Whether or not the values are squared doesn't affect the order (because square(root) is a monotonic function)
|
||||
cmp = distLeftSq <=> distRightSq;
|
||||
@@ -335,13 +335,13 @@ namespace GlitchyEngine.Renderer
|
||||
RenderCommand.SetDepthStencilState(_fullscreenDepthState);
|
||||
|
||||
// Scaling to make sure that only the part of the gbuffer that we actually used gets rendered into the viewport.
|
||||
Vector2 scaling = Vector2(_sceneConstants.CameraTarget.Width, _sceneConstants.CameraTarget.Height) / (Vector2)_gBuffer.Size;
|
||||
float2 scaling = float2(_sceneConstants.CameraTarget.Width, _sceneConstants.CameraTarget.Height) / (float2)_gBuffer.Size;
|
||||
|
||||
for (SubmittedLight light in _lights)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererScope!("Draw Light");
|
||||
|
||||
Vector3 lightDir = -light.Transform.Forward;
|
||||
float3 lightDir = -light.Transform.Forward;
|
||||
|
||||
Effect fsEffect = TestFullscreenEffect.Get();
|
||||
fsEffect.SetTexture("GBuffer_Albedo", _gBuffer.Target, 0);
|
||||
@@ -487,10 +487,10 @@ namespace GlitchyEngine.Renderer
|
||||
* @param end The end point of the line.
|
||||
* @param color The color of the line.
|
||||
*/
|
||||
public static void DrawLine(Vector3 start, Vector3 end, ColorRGBA color)
|
||||
public static void DrawLine(float3 start, float3 end, ColorRGBA color)
|
||||
{
|
||||
Renderer2D.DrawLine(start, end, color);
|
||||
//DrawLine(Vector4(start, 1.0f), Vector4(end, 1.0f), (ColorRGBA)color, .Identity);
|
||||
//DrawLine(float4(start, 1.0f), float4(end, 1.0f), (ColorRGBA)color, .Identity);
|
||||
}
|
||||
|
||||
/** @brief Draws a line.
|
||||
@@ -499,9 +499,9 @@ namespace GlitchyEngine.Renderer
|
||||
* @param color The color of the line.
|
||||
* @param transform A transform matrix transforming the line.
|
||||
*/
|
||||
public static void DrawLine(Vector3 start, Vector3 end, ColorRGBA color, Matrix transform)
|
||||
public static void DrawLine(float3 start, float3 end, ColorRGBA color, Matrix transform)
|
||||
{
|
||||
Renderer2D.DrawLine(transform * Vector4(start, 1.0f), transform * Vector4(end, 1.0f), color);
|
||||
Renderer2D.DrawLine(transform * float4(start, 1.0f), transform * float4(end, 1.0f), color);
|
||||
}
|
||||
|
||||
/** @brief Draws a ray.
|
||||
@@ -509,7 +509,7 @@ namespace GlitchyEngine.Renderer
|
||||
* @param direction The direction of the ray.
|
||||
* @param color The color of the ray.
|
||||
*/
|
||||
public static void DrawRay(Vector3 start, Vector3 direction, ColorRGBA color)
|
||||
public static void DrawRay(float3 start, float3 direction, ColorRGBA color)
|
||||
{
|
||||
Renderer2D.DrawRay(start, direction, color);
|
||||
}
|
||||
@@ -520,9 +520,9 @@ namespace GlitchyEngine.Renderer
|
||||
* @param color The color of the ray.
|
||||
* @param transform A transform matrix transforming the ray.
|
||||
*/
|
||||
public static void DrawRay(Vector3 start, Vector3 direction, ColorRGBA color, Matrix transform)
|
||||
public static void DrawRay(float3 start, float3 direction, ColorRGBA color, Matrix transform)
|
||||
{
|
||||
Renderer2D.DrawLine(transform * Vector4(start, 1.0f), transform * Vector4(direction, 0.0f), color);
|
||||
Renderer2D.DrawLine(transform * float4(start, 1.0f), transform * float4(direction, 0.0f), color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace GlitchyEngine.Renderer
|
||||
[CRepr]
|
||||
struct QuadVertex : IVertexData
|
||||
{
|
||||
public Vector2 Position;
|
||||
public Vector2 Texcoord;
|
||||
public float2 Position;
|
||||
public float2 Texcoord;
|
||||
|
||||
public this(Vector2 position, Vector2 texcoord)
|
||||
public this(float2 position, float2 texcoord)
|
||||
{
|
||||
Position = position;
|
||||
Texcoord = texcoord;
|
||||
@@ -46,12 +46,12 @@ namespace GlitchyEngine.Renderer
|
||||
[CRepr]
|
||||
struct LineBatchVertex
|
||||
{
|
||||
public Vector4 Position;
|
||||
public float4 Position;
|
||||
public ColorRGBA Color;
|
||||
|
||||
public uint32 EntityId;
|
||||
|
||||
public this(Vector4 position, ColorRGBA color, uint32 entityId)
|
||||
public this(float4 position, ColorRGBA color, uint32 entityId)
|
||||
{
|
||||
Position = position;
|
||||
Color = color;
|
||||
@@ -64,11 +64,11 @@ namespace GlitchyEngine.Renderer
|
||||
{
|
||||
public Matrix Transform;
|
||||
public ColorRGBA Color;
|
||||
public Vector4 UVTransform;
|
||||
public float4 UVTransform;
|
||||
|
||||
public uint32 EntityId;
|
||||
|
||||
public this(Matrix transform, ColorRGBA color, Vector4 uvTransform, uint32 entityId)
|
||||
public this(Matrix transform, ColorRGBA color, float4 uvTransform, uint32 entityId)
|
||||
{
|
||||
Transform = transform;
|
||||
Color = color;
|
||||
@@ -82,7 +82,7 @@ namespace GlitchyEngine.Renderer
|
||||
{
|
||||
public float InnerRadius;
|
||||
|
||||
public this(Matrix transform, ColorRGBA color, Vector4 uvTransform, float innerRadius, uint32 entityId)
|
||||
public this(Matrix transform, ColorRGBA color, float4 uvTransform, float innerRadius, uint32 entityId)
|
||||
: base(transform, color, uvTransform, entityId)
|
||||
{
|
||||
InnerRadius = innerRadius;
|
||||
@@ -110,15 +110,15 @@ namespace GlitchyEngine.Renderer
|
||||
FrontToBack
|
||||
}
|
||||
|
||||
struct QueueLine: this(Vector4 Start, Vector4 End, ColorRGBA Color, float Depth, uint32 entityId = uint32.MaxValue) { }
|
||||
struct QueueLine: this(float4 Start, float4 End, ColorRGBA Color, float Depth, uint32 entityId = uint32.MaxValue) { }
|
||||
|
||||
struct QueueQuad: this(Matrix Transform, ColorRGBA Color, Texture Texture, float Depth, Vector4 uvTransform, uint32 entityId = uint32.MaxValue) { }
|
||||
struct QueueQuad: this(Matrix Transform, ColorRGBA Color, Texture Texture, float Depth, float4 uvTransform, uint32 entityId = uint32.MaxValue) { }
|
||||
|
||||
struct QueueCircle : QueueQuad
|
||||
{
|
||||
public float InnerRadius;
|
||||
|
||||
public this(Matrix Transform, ColorRGBA Color, Texture Texture, float Depth, Vector4 uvTransform, float innerRadius, uint32 entityId = uint32.MaxValue)
|
||||
public this(Matrix Transform, ColorRGBA Color, Texture Texture, float Depth, float4 uvTransform, float innerRadius, uint32 entityId = uint32.MaxValue)
|
||||
: base(Transform, Color, Texture, Depth, uvTransform, entityId)
|
||||
{
|
||||
InnerRadius = innerRadius;
|
||||
@@ -632,7 +632,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
/// Adds a quad instance to the instance queue.
|
||||
[Inline]
|
||||
private static void QueueQuadInstance(Matrix transform, ColorRGBA color, Texture texture, float depth, Vector4 uvTransform, uint32 id = uint32.MaxValue)
|
||||
private static void QueueQuadInstance(Matrix transform, ColorRGBA color, Texture texture, float depth, float4 uvTransform, uint32 id = uint32.MaxValue)
|
||||
{
|
||||
s_QuadinstanceQueue.Add(QueueQuad(transform, color, texture ?? s_whiteTexture, depth, uvTransform, id));
|
||||
s_statistics.QuadCount++;
|
||||
@@ -640,7 +640,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
/// Adds a circle instance to the instance queue.
|
||||
[Inline]
|
||||
private static void QueueCircleInstance(Matrix transform, ColorRGBA color, Texture2D texture, float depth, Vector4 uvTransform, float innerRadius, uint32 id = uint32.MaxValue)
|
||||
private static void QueueCircleInstance(Matrix transform, ColorRGBA color, Texture2D texture, float depth, float4 uvTransform, float innerRadius, uint32 id = uint32.MaxValue)
|
||||
{
|
||||
s_circleInstanceQueue.Add(QueueCircle(transform, color, texture ?? s_whiteTexture, depth, uvTransform, innerRadius, id));
|
||||
s_statistics.CircleCount++;
|
||||
@@ -648,7 +648,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
/// Adds a line instance to the instance queue.
|
||||
[Inline]
|
||||
private static void QueueLineInstance(Vector4 start, Vector4 end, ColorRGBA color, uint32 id = uint32.MaxValue)
|
||||
private static void QueueLineInstance(float4 start, float4 end, ColorRGBA color, uint32 id = uint32.MaxValue)
|
||||
{
|
||||
s_lineInstanceQueue.Add(QueueLine(start, end, color, id));
|
||||
s_statistics.LineCount++;
|
||||
@@ -908,7 +908,7 @@ namespace GlitchyEngine.Renderer
|
||||
}
|
||||
|
||||
/// A specialized function that calculates the 2D transform matrix
|
||||
private static Matrix Calculate2DTransform(Vector3 translation, Vector2 scale, float rotation)
|
||||
private static Matrix Calculate2DTransform(float3 translation, float2 scale, float rotation)
|
||||
{
|
||||
float sin = 0.0f;
|
||||
float cos = 1.0f;
|
||||
@@ -933,9 +933,9 @@ namespace GlitchyEngine.Renderer
|
||||
* @param color The color of the line.
|
||||
* @param entityId The optional ID of the entity that belongs to this line (for picking).
|
||||
*/
|
||||
public static void DrawLine(Vector3 start, Vector3 end, ColorRGBA color = .White, uint32 entityId = uint32.MaxValue)
|
||||
public static void DrawLine(float3 start, float3 end, ColorRGBA color = .White, uint32 entityId = uint32.MaxValue)
|
||||
{
|
||||
DrawLine(Vector4(start, 1.0f), Vector4(end, 1.0f), color, entityId);
|
||||
DrawLine(float4(start, 1.0f), float4(end, 1.0f), color, entityId);
|
||||
}
|
||||
|
||||
/** @brief Draws a ray.
|
||||
@@ -944,9 +944,9 @@ namespace GlitchyEngine.Renderer
|
||||
* @param color The color of the ray.
|
||||
* @param entityId The optional ID of the entity that belongs to this ray (for picking).
|
||||
*/
|
||||
public static void DrawRay(Vector3 start, Vector3 direction, ColorRGBA color = .White, uint32 entityId = uint32.MaxValue)
|
||||
public static void DrawRay(float3 start, float3 direction, ColorRGBA color = .White, uint32 entityId = uint32.MaxValue)
|
||||
{
|
||||
DrawLine(Vector4(start, 1.0f), Vector4(direction, 0.0f), color, entityId);
|
||||
DrawLine(float4(start, 1.0f), float4(direction, 0.0f), color, entityId);
|
||||
}
|
||||
|
||||
/** @brief Draws a rectangle.
|
||||
@@ -955,14 +955,14 @@ namespace GlitchyEngine.Renderer
|
||||
* @param color The color of the rectangle.
|
||||
* @param entityId The optional ID of the entity that belongs to this rectangle (for picking).
|
||||
*/
|
||||
public static void DrawRect(Vector2 position, Vector2 size, ColorRGBA color = .White, uint32 entityId = uint32.MaxValue)
|
||||
public static void DrawRect(float2 position, float2 size, ColorRGBA color = .White, uint32 entityId = uint32.MaxValue)
|
||||
{
|
||||
Vector2 halfSize = size / 2;
|
||||
float2 halfSize = size / 2;
|
||||
|
||||
Vector4 p0 = Vector4(position + Vector2(-halfSize.X, -halfSize.Y), 0.0f, 1.0f);
|
||||
Vector4 p1 = Vector4(position + Vector2(halfSize.X, -halfSize.Y), 0.0f, 1.0f);
|
||||
Vector4 p2 = Vector4(position + Vector2(halfSize.X, halfSize.Y), 0.0f, 1.0f);
|
||||
Vector4 p3 = Vector4(position + Vector2(-halfSize.X, halfSize.Y), 0.0f, 1.0f);
|
||||
float4 p0 = float4(position + float2(-halfSize.X, -halfSize.Y), 0.0f, 1.0f);
|
||||
float4 p1 = float4(position + float2(halfSize.X, -halfSize.Y), 0.0f, 1.0f);
|
||||
float4 p2 = float4(position + float2(halfSize.X, halfSize.Y), 0.0f, 1.0f);
|
||||
float4 p3 = float4(position + float2(-halfSize.X, halfSize.Y), 0.0f, 1.0f);
|
||||
|
||||
DrawLine(p0, p1, color, entityId);
|
||||
DrawLine(p1, p2, color, entityId);
|
||||
@@ -977,12 +977,12 @@ namespace GlitchyEngine.Renderer
|
||||
*/
|
||||
public static void DrawRect(Matrix transform, ColorRGBA color = .White, uint32 entityId = uint32.MaxValue)
|
||||
{
|
||||
Vector2 halfSize = Vector2.One / 2.0f;
|
||||
float2 halfSize = float2.One / 2.0f;
|
||||
|
||||
Vector4 p0 = transform * Vector4(-halfSize.X, -halfSize.Y, 0.0f, 1.0f);
|
||||
Vector4 p1 = transform * Vector4(halfSize.X, -halfSize.Y, 0.0f, 1.0f);
|
||||
Vector4 p2 = transform * Vector4(halfSize.X, halfSize.Y, 0.0f, 1.0f);
|
||||
Vector4 p3 = transform * Vector4(-halfSize.X, halfSize.Y, 0.0f, 1.0f);
|
||||
float4 p0 = transform * float4(-halfSize.X, -halfSize.Y, 0.0f, 1.0f);
|
||||
float4 p1 = transform * float4(halfSize.X, -halfSize.Y, 0.0f, 1.0f);
|
||||
float4 p2 = transform * float4(halfSize.X, halfSize.Y, 0.0f, 1.0f);
|
||||
float4 p3 = transform * float4(-halfSize.X, halfSize.Y, 0.0f, 1.0f);
|
||||
|
||||
DrawLine(p0, p1, color, entityId);
|
||||
DrawLine(p1, p2, color, entityId);
|
||||
@@ -990,7 +990,7 @@ namespace GlitchyEngine.Renderer
|
||||
DrawLine(p3, p0, color, entityId);
|
||||
}
|
||||
|
||||
public static void DrawLine(Vector4 start, Vector4 end, ColorRGBA color = .White, uint32 entityId = uint32.MaxValue)
|
||||
public static void DrawLine(float4 start, float4 end, ColorRGBA color = .White, uint32 entityId = uint32.MaxValue)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
@@ -1008,23 +1008,23 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
// Colored Quad
|
||||
|
||||
public static void DrawQuad(Vector2 position, Vector2 size, float rotation, ColorRGBA color)
|
||||
public static void DrawQuad(float2 position, float2 size, float rotation, ColorRGBA color)
|
||||
{
|
||||
DrawQuad(Vector3(position, 0.0f), size, rotation, s_whiteTexture, color);
|
||||
DrawQuad(float3(position, 0.0f), size, rotation, s_whiteTexture, color);
|
||||
}
|
||||
|
||||
/// Like DrawQuad but the pivot point is the top left corner
|
||||
public static void DrawQuadPivotCorner(Vector2 position, Vector2 size, float rotation, ColorRGBA color)
|
||||
public static void DrawQuadPivotCorner(float2 position, float2 size, float rotation, ColorRGBA color)
|
||||
{
|
||||
DrawQuadPivotCorner(Vector3(position, 0.0f), size, rotation, s_whiteTexture, color);
|
||||
DrawQuadPivotCorner(float3(position, 0.0f), size, rotation, s_whiteTexture, color);
|
||||
}
|
||||
|
||||
public static void DrawQuad(Vector3 position, Vector2 size, float rotation, ColorRGBA color)
|
||||
public static void DrawQuad(float3 position, float2 size, float rotation, ColorRGBA color)
|
||||
{
|
||||
DrawQuad(position, size, rotation, s_whiteTexture, color);
|
||||
}
|
||||
|
||||
public static void DrawQuadPivotCorner(Vector3 position, Vector2 size, float rotation, ColorRGBA color)
|
||||
public static void DrawQuadPivotCorner(float3 position, float2 size, float rotation, ColorRGBA color)
|
||||
{
|
||||
DrawQuadPivotCorner(position, size, rotation, s_whiteTexture, color);
|
||||
}
|
||||
@@ -1037,9 +1037,9 @@ namespace GlitchyEngine.Renderer
|
||||
// Quad Subtexture
|
||||
|
||||
[Inline]
|
||||
private static Vector4 CalculateSubTexcoords(Vector4 texCoords, Vector4 innerTexcoords)
|
||||
private static float4 CalculateSubTexcoords(float4 texCoords, float4 innerTexcoords)
|
||||
{
|
||||
Vector4 uv = texCoords;
|
||||
float4 uv = texCoords;
|
||||
uv.XY += innerTexcoords.XY * uv.ZW;
|
||||
uv.ZW *= innerTexcoords.ZW;
|
||||
|
||||
@@ -1048,12 +1048,12 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
// Subtex only
|
||||
|
||||
public static void DrawQuad(Vector2 position, Vector2 size, float rotation, SubTexture2D texture, ColorRGBA color = .White)
|
||||
public static void DrawQuad(float2 position, float2 size, float rotation, SubTexture2D texture, ColorRGBA color = .White)
|
||||
{
|
||||
DrawQuad(Vector3(position, 0.0f), size, rotation, texture.Texture, .White, texture.TexCoords);
|
||||
DrawQuad(float3(position, 0.0f), size, rotation, texture.Texture, .White, texture.TexCoords);
|
||||
}
|
||||
|
||||
public static void DrawQuad(Vector3 position, Vector2 size, float rotation, SubTexture2D texture, ColorRGBA color = .White)
|
||||
public static void DrawQuad(float3 position, float2 size, float rotation, SubTexture2D texture, ColorRGBA color = .White)
|
||||
{
|
||||
DrawQuad(position, size, rotation, texture.Texture, .White, texture.TexCoords);
|
||||
}
|
||||
@@ -1065,42 +1065,42 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
// Subtex + Texcoords
|
||||
|
||||
public static void DrawQuad(Vector2 position, Vector2 size, float rotation, SubTexture2D subtexture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||
public static void DrawQuad(float2 position, float2 size, float rotation, SubTexture2D subtexture, ColorRGBA color = .White, float4 uvTransform = .(0, 0, 1, 1))
|
||||
{
|
||||
Vector4 uv = CalculateSubTexcoords(subtexture.TexCoords, uvTransform);
|
||||
float4 uv = CalculateSubTexcoords(subtexture.TexCoords, uvTransform);
|
||||
|
||||
DrawQuad(Vector3(position, 0.0f), size, rotation, subtexture.Texture, .White, uv);
|
||||
DrawQuad(float3(position, 0.0f), size, rotation, subtexture.Texture, .White, uv);
|
||||
}
|
||||
|
||||
public static void DrawQuad(Vector3 position, Vector2 size, float rotation, SubTexture2D subtexture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||
public static void DrawQuad(float3 position, float2 size, float rotation, SubTexture2D subtexture, ColorRGBA color = .White, float4 uvTransform = .(0, 0, 1, 1))
|
||||
{
|
||||
Vector4 uv = CalculateSubTexcoords(subtexture.TexCoords, uvTransform);
|
||||
float4 uv = CalculateSubTexcoords(subtexture.TexCoords, uvTransform);
|
||||
|
||||
DrawQuad(position, size, rotation, subtexture.Texture, .White, uv);
|
||||
}
|
||||
|
||||
public static void DrawQuad(Matrix transform, SubTexture2D subtexture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1), uint32 entityId = uint32.MaxValue)
|
||||
public static void DrawQuad(Matrix transform, SubTexture2D subtexture, ColorRGBA color = .White, float4 uvTransform = .(0, 0, 1, 1), uint32 entityId = uint32.MaxValue)
|
||||
{
|
||||
Vector4 uv = CalculateSubTexcoords(subtexture.TexCoords, uvTransform);
|
||||
float4 uv = CalculateSubTexcoords(subtexture.TexCoords, uvTransform);
|
||||
|
||||
DrawQuad(transform, subtexture.Texture, color, uv, entityId);
|
||||
}
|
||||
|
||||
// Textured Quad
|
||||
|
||||
public static void DrawQuad(Vector2 position, Vector2 size, float rotation, Texture texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||
public static void DrawQuad(float2 position, float2 size, float rotation, Texture texture, ColorRGBA color = .White, float4 uvTransform = .(0, 0, 1, 1))
|
||||
{
|
||||
DrawQuad(Vector3(position, 0.0f), size, rotation, texture, color, uvTransform);
|
||||
DrawQuad(float3(position, 0.0f), size, rotation, texture, color, uvTransform);
|
||||
}
|
||||
|
||||
public static void DrawQuad(Vector3 position, Vector2 size, float rotation, Texture texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||
public static void DrawQuad(float3 position, float2 size, float rotation, Texture texture, ColorRGBA color = .White, float4 uvTransform = .(0, 0, 1, 1))
|
||||
{
|
||||
Matrix transform = Calculate2DTransform(position, size, rotation);
|
||||
|
||||
DrawQuad(transform, texture, color, uvTransform);
|
||||
}
|
||||
|
||||
public static void DrawQuad(Matrix transform, Texture texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1), uint32 entityId = uint32.MaxValue)
|
||||
public static void DrawQuad(Matrix transform, Texture texture, ColorRGBA color = .White, float4 uvTransform = .(0, 0, 1, 1), uint32 entityId = uint32.MaxValue)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
@@ -1128,41 +1128,41 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
// Textured quad pivot
|
||||
|
||||
public static void DrawQuadPivotCorner(Vector2 position, Vector2 size, float rotation, Texture2D texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||
public static void DrawQuadPivotCorner(float2 position, float2 size, float rotation, Texture2D texture, ColorRGBA color = .White, float4 uvTransform = .(0, 0, 1, 1))
|
||||
{
|
||||
DrawQuadPivotCorner(Vector3(position, 0.0f), size, rotation, texture, color, uvTransform);
|
||||
DrawQuadPivotCorner(float3(position, 0.0f), size, rotation, texture, color, uvTransform);
|
||||
}
|
||||
|
||||
public static void DrawQuadPivotCorner(Vector3 position, Vector2 size, float rotation, Texture2D texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||
public static void DrawQuadPivotCorner(float3 position, float2 size, float rotation, Texture2D texture, ColorRGBA color = .White, float4 uvTransform = .(0, 0, 1, 1))
|
||||
{
|
||||
DrawQuad(position + Vector3(size.X / 2, size.Y / -2, 0), size, rotation, texture, color, uvTransform);
|
||||
DrawQuad(position + float3(size.X / 2, size.Y / -2, 0), size, rotation, texture, color, uvTransform);
|
||||
}
|
||||
|
||||
// Circle
|
||||
|
||||
public static void DrawCircle(Vector2 position, Vector2 size, ColorRGBA color, float innerRadius = 1.0f)
|
||||
public static void DrawCircle(float2 position, float2 size, ColorRGBA color, float innerRadius = 1.0f)
|
||||
{
|
||||
DrawCircle(Vector3(position, 0.0f), size, 0, s_whiteTexture, color, innerRadius);
|
||||
DrawCircle(float3(position, 0.0f), size, 0, s_whiteTexture, color, innerRadius);
|
||||
}
|
||||
|
||||
public static void DrawCircle(Vector3 position, Vector2 size, ColorRGBA color, float innerRadius = 1.0f)
|
||||
public static void DrawCircle(float3 position, float2 size, ColorRGBA color, float innerRadius = 1.0f)
|
||||
{
|
||||
DrawCircle(position, size, 0, s_whiteTexture, color, innerRadius);
|
||||
}
|
||||
|
||||
public static void DrawCircle(Vector2 position, Vector2 size, float rotation, Texture2D texture, ColorRGBA color = .White, float innerRadius = 1.0f, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||
public static void DrawCircle(float2 position, float2 size, float rotation, Texture2D texture, ColorRGBA color = .White, float innerRadius = 1.0f, float4 uvTransform = .(0, 0, 1, 1))
|
||||
{
|
||||
DrawCircle(Vector3(position, 0.0f), size, rotation, texture, color, innerRadius, uvTransform);
|
||||
DrawCircle(float3(position, 0.0f), size, rotation, texture, color, innerRadius, uvTransform);
|
||||
}
|
||||
|
||||
public static void DrawCircle(Vector3 position, Vector2 size, float rotation, Texture2D texture, ColorRGBA color = .White, float innerRadius = 1.0f, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||
public static void DrawCircle(float3 position, float2 size, float rotation, Texture2D texture, ColorRGBA color = .White, float innerRadius = 1.0f, float4 uvTransform = .(0, 0, 1, 1))
|
||||
{
|
||||
Matrix transform = Calculate2DTransform(position, size, rotation);
|
||||
|
||||
DrawCircle(transform, texture, color, innerRadius, uvTransform);
|
||||
}
|
||||
|
||||
public static void DrawCircle(Matrix transform, Texture2D texture, ColorRGBA color = .White, float innerRadius = 1.0f, Vector4 uvTransform = .(0, 0, 1, 1), uint32 entityId = uint32.MaxValue)
|
||||
public static void DrawCircle(Matrix transform, Texture2D texture, ColorRGBA color = .White, float innerRadius = 1.0f, float4 uvTransform = .(0, 0, 1, 1), uint32 entityId = uint32.MaxValue)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
|
||||
@@ -6,34 +6,34 @@ namespace GlitchyEngine.Renderer
|
||||
class SubTexture2D : RefCounter
|
||||
{
|
||||
protected Texture2D _texture ~ _.ReleaseRef();
|
||||
protected Vector4 _texCoords;
|
||||
protected float4 _texCoords;
|
||||
|
||||
public Texture2D Texture => _texture;
|
||||
public Vector4 TexCoords => _texCoords;
|
||||
public float4 TexCoords => _texCoords;
|
||||
|
||||
public this(Texture2D texture) : this(_texture, .(0, 0, 1, 1)) { }
|
||||
|
||||
public this(Texture2D texture, Int2 topLeft, Int2 size) :
|
||||
this(texture,
|
||||
{
|
||||
Vector2 texSize = Vector2(texture.Width, texture.Height);
|
||||
Vector4 texCoords = Vector4((Vector2)topLeft, (Vector2)size) / texSize.XYXY;
|
||||
float2 texSize = float2(texture.Width, texture.Height);
|
||||
float4 texCoords = float4((float2)topLeft, (float2)size) / texSize.XYXY;
|
||||
texCoords
|
||||
}) { }
|
||||
|
||||
public this(Texture2D texture, Vector2 topLeft, Vector2 size) : this(texture, Vector4(topLeft, size)) { }
|
||||
public this(Texture2D texture, float2 topLeft, float2 size) : this(texture, float4(topLeft, size)) { }
|
||||
|
||||
public this(Texture2D texture, Vector4 texCoords)
|
||||
public this(Texture2D texture, float4 texCoords)
|
||||
{
|
||||
_texture = texture..AddRef();
|
||||
_texCoords = texCoords;
|
||||
}
|
||||
|
||||
public static SubTexture2D CreateFromGrid(Texture2D texture, Vector2 coords, Vector2 gridSize, Vector2 spriteSize = .One)
|
||||
public static SubTexture2D CreateFromGrid(Texture2D texture, float2 coords, float2 gridSize, float2 spriteSize = .One)
|
||||
{
|
||||
Vector2 textureSize = .(texture.Width, texture.Height);
|
||||
float2 textureSize = .(texture.Width, texture.Height);
|
||||
|
||||
Vector4 uv = .(coords * gridSize, gridSize * spriteSize) / textureSize.XYXY;
|
||||
float4 uv = .(coords * gridSize, gridSize * spriteSize) / textureSize.XYXY;
|
||||
|
||||
return new SubTexture2D(texture, uv);
|
||||
}
|
||||
|
||||
@@ -103,12 +103,12 @@ namespace GlitchyEngine.Renderer.Text
|
||||
{
|
||||
public Font Font;
|
||||
public uint32 GlyphId;
|
||||
public Vector2 Position;
|
||||
public float2 Position;
|
||||
public float Scale;
|
||||
//public float AdvanceX;
|
||||
//public float AdvanceY;
|
||||
|
||||
public this(Font font, uint32 glyphId, Vector2 position, float scale)//, float advanceX, float advanceY)
|
||||
public this(Font font, uint32 glyphId, float2 position, float scale)//, float advanceX, float advanceY)
|
||||
{
|
||||
Font = font;
|
||||
GlyphId = glyphId;
|
||||
@@ -341,7 +341,7 @@ namespace GlitchyEngine.Renderer.Text
|
||||
_msdfEffect.Variables["ViewProjection"].SetData(viewProjection);
|
||||
|
||||
// TODO: this doesn't really work with fallback fonts
|
||||
Vector2 unitRange = Vector2((float)text.Font._range) / Vector2(text.Font._atlas.Width, text.Font._atlas.Height);
|
||||
float2 unitRange = ((float)text.Font._range) / float2(text.Font._atlas.Width, text.Font._atlas.Height);
|
||||
_msdfEffect.Variables["UnitRange"].SetData(unitRange);
|
||||
|
||||
List<Texture2D> atlasses = scope .();
|
||||
@@ -366,7 +366,7 @@ namespace GlitchyEngine.Renderer.Text
|
||||
atlasses.Add(atlas..AddRef());
|
||||
}
|
||||
|
||||
Vector2 atlasSize = .(atlas.Width, atlas.Height);
|
||||
float2 atlasSize = .(atlas.Width, atlas.Height);
|
||||
|
||||
float adjustToPenX = glyphDesc.AdjustToPen;
|
||||
//adjustToPenX *= glyphFontScale;
|
||||
@@ -377,7 +377,7 @@ namespace GlitchyEngine.Renderer.Text
|
||||
adjustToBaseline *= glyph.Scale;
|
||||
|
||||
// Rectangle on the screen
|
||||
Vector4 viewportRect = .(
|
||||
float4 viewportRect = .(
|
||||
// TODO: merge adjustToPenX and adjustToBaseline into Position
|
||||
glyph.Position.X + adjustToPenX,
|
||||
glyph.Position.Y + adjustToBaseline,
|
||||
@@ -385,24 +385,24 @@ namespace GlitchyEngine.Renderer.Text
|
||||
glyphDesc.Height * glyph.Scale);
|
||||
|
||||
// Rectangle on the font atlas
|
||||
Vector4 texRect = .(glyphDesc.MapCoord.X, glyphDesc.MapCoord.Y, glyphDesc.Width, glyphDesc.Height);
|
||||
float4 texRect = .(glyphDesc.MapCoord.X, glyphDesc.MapCoord.Y, glyphDesc.Width, glyphDesc.Height);
|
||||
|
||||
Color glyphColor = fontColor;//Color.White;// TODO: glyphDesc.IsBitmap ? bitmapColor : fontColor;
|
||||
|
||||
texRect /= Vector4(atlasSize, atlasSize);
|
||||
texRect /= float4(atlasSize, atlasSize);
|
||||
|
||||
// Show quads
|
||||
// Renderer2D.DrawQuad(Vector3(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2, 1), .(viewportRect.Z, viewportRect.W), 0, .Red);
|
||||
// Renderer2D.DrawQuad(float3(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2, 1), .(viewportRect.Z, viewportRect.W), 0, .Red);
|
||||
|
||||
Vector3 position = .(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2, 0);
|
||||
float3 position = .(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2, 0);
|
||||
|
||||
Matrix glyphTransform = transform * Matrix.Translation(position) * Matrix.Scaling(viewportRect.Z, viewportRect.W, 1.0f);
|
||||
|
||||
Renderer2D.DrawQuad(glyphTransform, atlas, (ColorRGBA)glyphColor, texRect);
|
||||
//Renderer2D.DrawQuad(Vector2(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2), .(viewportRect.Z, viewportRect.W), 0, atlas, glyphColor, texRect);
|
||||
//Renderer2D.DrawQuad(float2(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2), .(viewportRect.Z, viewportRect.W), 0, atlas, glyphColor, texRect);
|
||||
|
||||
// Show pen positions
|
||||
// Renderer2D.DrawQuad(Vector3(Vector2(x, y) + glyph.Position, -1), .(1), 0, .Green);
|
||||
// Renderer2D.DrawQuad(float3(float2(x, y) + glyph.Position, -1), .(1), 0, .Green);
|
||||
}
|
||||
|
||||
Renderer2D.Flush();
|
||||
@@ -451,7 +451,7 @@ namespace GlitchyEngine.Renderer.Text
|
||||
_msdfEffect.Variables["screenPixelRange"].SetData(scale * 4.0f);
|
||||
|
||||
// TODO: this doesn't really work with fallback fonts
|
||||
Vector2 unitRange = Vector2((float)font._range) / Vector2(font._atlas.Width, font._atlas.Height);
|
||||
float2 unitRange = ((float)font._range) / float2(font._atlas.Width, font._atlas.Height);
|
||||
_msdfEffect.Variables["UnitRange"].SetData(unitRange);
|
||||
|
||||
// Space between two baselines
|
||||
@@ -550,7 +550,7 @@ namespace GlitchyEngine.Renderer.Text
|
||||
atlasses.Add(atlas..AddRef());
|
||||
}
|
||||
|
||||
Vector2 atlasSize = .(atlas.Width, atlas.Height);
|
||||
float2 atlasSize = .(atlas.Width, atlas.Height);
|
||||
|
||||
float adjustToPenX = glyphDesc.AdjustToPen;
|
||||
adjustToPenX *= glyphFontScale;
|
||||
@@ -559,26 +559,26 @@ namespace GlitchyEngine.Renderer.Text
|
||||
adjustToBaseline *= glyphFontScale;
|
||||
|
||||
// Rectangle on the screen
|
||||
Vector4 viewportRect = .(
|
||||
float4 viewportRect = .(
|
||||
penPosition + adjustToPenX,
|
||||
baseline + adjustToBaseline,
|
||||
glyphDesc.Width * glyphFontScale,
|
||||
glyphDesc.Height * glyphFontScale);
|
||||
|
||||
// Rectangle on the font atlas
|
||||
Vector4 texRect = .(glyphDesc.MapCoord.X, glyphDesc.MapCoord.Y, glyphDesc.Width, glyphDesc.Height);
|
||||
float4 texRect = .(glyphDesc.MapCoord.X, glyphDesc.MapCoord.Y, glyphDesc.Width, glyphDesc.Height);
|
||||
|
||||
Color glyphColor = glyphDesc.IsBitmap ? bitmapColor : fontColor;
|
||||
|
||||
texRect /= Vector4(atlasSize, atlasSize);
|
||||
texRect /= float4(atlasSize, atlasSize);
|
||||
|
||||
// Show quads
|
||||
// Renderer2D.DrawQuad(Vector3(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2, 1), .(viewportRect.Z, viewportRect.W), 0, .Red);
|
||||
// Renderer2D.DrawQuad(float3(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2, 1), .(viewportRect.Z, viewportRect.W), 0, .Red);
|
||||
|
||||
Renderer2D.DrawQuad(Vector2(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2), .(viewportRect.Z, viewportRect.W), 0, atlas, glyphColor, texRect);
|
||||
Renderer2D.DrawQuad(float2(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2), .(viewportRect.Z, viewportRect.W), 0, atlas, glyphColor, texRect);
|
||||
|
||||
// Show pen positions
|
||||
// Renderer2D.DrawQuad(Vector3(penPosition, baseline, -1), .(1), 0, .Green);
|
||||
// Renderer2D.DrawQuad(float3(penPosition, baseline, -1), .(1), 0, .Green);
|
||||
|
||||
penPosition += (x_advance / 64) * glyphFontScale;
|
||||
baseline += (y_advance / 64) * glyphFontScale;
|
||||
@@ -627,7 +627,7 @@ namespace GlitchyEngine.Renderer.Text
|
||||
atlasses.Add(atlas..AddRef());
|
||||
}
|
||||
|
||||
Vector2 atlasSize = .(atlas.Width, atlas.Height);
|
||||
float2 atlasSize = .(atlas.Width, atlas.Height);
|
||||
|
||||
float adjustToPenX = glyphDesc.AdjustToPen;
|
||||
adjustToPenX *= glyphFontScale;
|
||||
@@ -636,20 +636,20 @@ namespace GlitchyEngine.Renderer.Text
|
||||
adjustToBaseline *= glyphFontScale;
|
||||
|
||||
// Rectangle on the screen
|
||||
Vector4 viewportRect = .(
|
||||
float4 viewportRect = .(
|
||||
penPosition + adjustToPenX,
|
||||
baseline + adjustToBaseline,
|
||||
glyphDesc.Width * glyphFontScale,
|
||||
glyphDesc.Height * glyphFontScale);
|
||||
|
||||
// Rectangle on the font atlas
|
||||
Vector4 texRect = .(glyphDesc.MapCoord.X, glyphDesc.MapCoord.Y, glyphDesc.Width, glyphDesc.Height);
|
||||
float4 texRect = .(glyphDesc.MapCoord.X, glyphDesc.MapCoord.Y, glyphDesc.Width, glyphDesc.Height);
|
||||
|
||||
Color glyphColor = glyphDesc.IsBitmap ? bitmapColor : fontColor;
|
||||
|
||||
texRect /= Vector4(atlasSize, atlasSize);
|
||||
texRect /= float4(atlasSize, atlasSize);
|
||||
|
||||
Renderer2D.DrawQuad(Vector2(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2), .(viewportRect.Z, viewportRect.W), 0, atlas, (ColorRGBA)glyphColor, texRect);
|
||||
Renderer2D.DrawQuad(float2(viewportRect.X + viewportRect.Z / 2, viewportRect.Y + viewportRect.W / 2), .(viewportRect.Z, viewportRect.W), 0, atlas, (ColorRGBA)glyphColor, texRect);
|
||||
|
||||
//renderer.Draw(atlas, viewportRect.X, viewportRect.Y, viewportRect.Z, viewportRect.W, glyphColor, *(float*)(&depthInt), texRect);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user