Transitioned from VectorX to floatX

And some trying to update Rigidbody when transform changes
This commit is contained in:
Simon Lübeß
2023-06-25 02:47:33 +02:00
parent 5f5da2ed35
commit 9e1f648aa0
49 changed files with 1281 additions and 871 deletions
+13 -13
View File
@@ -17,20 +17,20 @@ namespace Sandbox
[Ordered]
struct VertexColorTexture : IVertexData
{
public Vector3 Position;
public float3 Position;
public Color Color;
public Vector2 TexCoord;
public float2 TexCoord;
public this() => this = default;
public this(Vector3 pos, Color color)
public this(float3 pos, Color color)
{
Position = pos;
Color = color;
TexCoord = .();
}
public this(Vector3 pos, Color color, Vector2 texCoord)
public this(float3 pos, Color color, float2 texCoord)
{
Position = pos;
Color = color;
@@ -73,7 +73,7 @@ namespace Sandbox
PerspectiveCameraController _cameraController ~ delete _;
private Vector3 CircleCoord(float angle)
private float3 CircleCoord(float angle)
{
return .(Math.Cos(angle), Math.Sin(angle), 0);
}
@@ -144,10 +144,10 @@ namespace Sandbox
_quadGeometryBinding.SetVertexLayout(vertexLayout);
VertexColorTexture[?] vertices = .(
VertexColorTexture(Vector3(-0.75f, 0.75f, 0), Color.White, .(0, 0)),
VertexColorTexture(Vector3(-0.75f, -0.75f, 0), Color.White, .(0, 1)),
VertexColorTexture(Vector3(0.75f, -0.75f, 0), Color.White, .(1, 1)),
VertexColorTexture(Vector3(0.75f, 0.75f, 0), Color.White, .(1, 0)),
VertexColorTexture(float3(-0.75f, 0.75f, 0), Color.White, .(0, 0)),
VertexColorTexture(float3(-0.75f, -0.75f, 0), Color.White, .(0, 1)),
VertexColorTexture(float3(0.75f, -0.75f, 0), Color.White, .(1, 1)),
VertexColorTexture(float3(0.75f, 0.75f, 0), Color.White, .(1, 0)),
);
let qvb = new VertexBuffer(typeof(VertexColorTexture), (.)vertices.Count, .Immutable);
@@ -234,7 +234,7 @@ namespace Sandbox
materialTestMaterial.SetVariable("InvTransSkinningMatrices", matrices2);
materialTestMaterial.SetVariable("BaseColor", Color.White);
materialTestMaterial.SetVariable("LightDir", Vector3(1, 1, -0.5f).Normalized());
materialTestMaterial.SetVariable("LightDir", float3(1, 1, -0.5f).Normalized());
ModelLoader.LoadModel("content\\Models\\RiggedFigure\\RiggedFigure.glb", materialTestMaterial, _world, Clips);
@@ -434,7 +434,7 @@ namespace Sandbox
if(parentId != uint8.MaxValue)
{
Vector3 start = mat.Translation;
float3 start = mat.Translation;
Joint parent = meshRenderer.Skeleton.Joints[parentId];
@@ -442,7 +442,7 @@ namespace Sandbox
Matrix parentMatrix = pose.SkinningMatricies[parentId] * parentBindPose;
Vector3 end = parentMatrix.Translation;
float3 end = parentMatrix.Translation;
Renderer.DrawLine(start, end, .Black, transform.WorldTransform);
}
@@ -457,7 +457,7 @@ namespace Sandbox
// non engine
material.SetVariable("BaseColor", Color.White);
material.SetVariable("LightDir", Vector3(1, 1, -0.5f).Normalized());
material.SetVariable("LightDir", float3(1, 1, -0.5f).Normalized());
Renderer.Submit(mesh.Mesh, material, transform.WorldTransform);
}
+15 -15
View File
@@ -129,12 +129,12 @@ namespace Sandbox
_spriteSheet = Content.LoadAsset<Texture2D>("content/Rpg/textures/spritesheet.png");//new Texture2D("content/Rpg/textures/spritesheet.png");
_spriteSheet.SamplerState = SamplerStateManager.PointClamp;
_treeSprite = SubTexture2D.CreateFromGrid(_spriteSheet, Vector2(5, 10), Vector2(128), .(1, 2));
_barrelSprite = SubTexture2D.CreateFromGrid(_spriteSheet, Vector2(9, 11), Vector2(128));
_treeSprite = SubTexture2D.CreateFromGrid(_spriteSheet, float2(5, 10), float2(128), .(1, 2));
_barrelSprite = SubTexture2D.CreateFromGrid(_spriteSheet, float2(9, 11), float2(128));
_grassSprite = SubTexture2D.CreateFromGrid(_spriteSheet, Vector2(1, 1), Vector2(128));
_dirtSprite = SubTexture2D.CreateFromGrid(_spriteSheet, Vector2(6, 1), Vector2(128));
_waterSprite = SubTexture2D.CreateFromGrid(_spriteSheet, Vector2(11, 1), Vector2(128));
_grassSprite = SubTexture2D.CreateFromGrid(_spriteSheet, float2(1, 1), float2(128));
_dirtSprite = SubTexture2D.CreateFromGrid(_spriteSheet, float2(6, 1), float2(128));
_waterSprite = SubTexture2D.CreateFromGrid(_spriteSheet, float2(11, 1), float2(128));
_mapMap = new Dictionary<char8, SubTexture2D>();
_mapMap['W'] = _waterSprite..AddRef();
@@ -166,13 +166,13 @@ namespace Sandbox
float rotation = (float)gameTime.TotalTime.TotalSeconds;
Renderer2D.DrawQuad(Vector3(0, 0, 1), Vector2(20), 0, _checkerTexture, .White, .(0, 0, 10, 10));
Renderer2D.DrawQuad(float3(0, 0, 1), float2(20), 0, _checkerTexture, .White, .(0, 0, 10, 10));
Renderer2D.DrawCircle(Vector3(0, 0, 0f), Vector2(5), rotation, _checkerTexture, .LightBlue, innerRadius, .(0, 0, 1, 1));
Renderer2D.DrawCircle(float3(0, 0, 0f), float2(5), rotation, _checkerTexture, .LightBlue, innerRadius, .(0, 0, 1, 1));
Renderer2D.DrawQuad(Vector3(0, -7, 1), Vector2(2), -rotation, _checkerTexture, .White, .(0, 0, 10, 10));
Renderer2D.DrawQuad(float3(0, -7, 1), float2(2), -rotation, _checkerTexture, .White, .(0, 0, 10, 10));
Renderer2D.DrawCircle(Vector3(-2, -2, -2f), Vector2(1), .GreenYellow);
Renderer2D.DrawCircle(float3(-2, -2, -2f), float2(1), .GreenYellow);
Renderer2D.EndScene();
Renderer2D.BeginScene(cameraController.Camera, .BackToFront);
@@ -181,7 +181,7 @@ namespace Sandbox
for(float y = -5.0f; y < 5.0f; y += 0.1f)
{
ColorRGBA color = .((x + 5.0f) / 10.0f, 0.4f, (y + 5.0f) / 10.0f, 0.6f);
Renderer2D.DrawQuad(Vector3(x, y, 0.75f), Vector2(0.098f), 0, color);
Renderer2D.DrawQuad(float3(x, y, 0.75f), float2(0.098f), 0, color);
}
for(int x < 10)
@@ -189,7 +189,7 @@ namespace Sandbox
{
int i = (x + y) % 2;
Renderer2D.DrawQuad(Vector3(2 * x, 2 * y, 0.5f), Vector2(1.5f, 1), MathHelper.PiOverFour, (i == 0) ? _squareColor0 : _squareColor1);
Renderer2D.DrawQuad(float3(2 * x, 2 * y, 0.5f), float2(1.5f, 1), MathHelper.PiOverFour, (i == 0) ? _squareColor0 : _squareColor1);
}
//var prepared = FontRenderer.PrepareText(fonty, text, 64, .White, .White);
@@ -201,10 +201,10 @@ namespace Sandbox
Renderer2D.BeginScene(cameraController.Camera, .BackToFront);
Renderer2D.DrawQuad(Vector3(0, 0, 1), Vector2(1, 2), 0, _treeSprite);
Renderer2D.DrawQuad(Vector3(1, 0, 1), Vector2(1, 1), 0, _grassSprite);
Renderer2D.DrawQuad(float3(0, 0, 1), float2(1, 2), 0, _treeSprite);
Renderer2D.DrawQuad(float3(1, 0, 1), float2(1, 1), 0, _grassSprite);
Vector2 position = Vector2.Zero;
float2 position = float2.Zero;
for(char8 c in s_MapTiles.RawChars)
{
@@ -217,7 +217,7 @@ namespace Sandbox
SubTexture2D tile = _mapMap[c];
Renderer2D.DrawQuad(Vector3(position, -5), Vector2.One, 0, tile);
Renderer2D.DrawQuad(float3(position, -5), float2.One, 0, tile);
position.X += 1.0f;
}
+12 -12
View File
@@ -111,30 +111,30 @@ namespace Sandbox
RenderCommand.SetBlendState(_alphaBlendState);
RenderCommand.SetDepthStencilState(_depthStencilState);
//Renderer2D.DrawQuad(Vector3(0, 0, 1), Vector2(8), 0, _checkerTexture, .White, .(0, 0, 1, 1));
//Renderer2D.DrawQuad(Vector3(0, 0, 0), Vector2(_smallLines.Width, _smallLines.Height), 0, _smallLines, .White, .(0, 0, 1, 1));
//Renderer2D.DrawQuad(float3(0, 0, 1), float2(8), 0, _checkerTexture, .White, .(0, 0, 1, 1));
//Renderer2D.DrawQuad(float3(0, 0, 0), float2(_smallLines.Width, _smallLines.Height), 0, _smallLines, .White, .(0, 0, 1, 1));
Renderer2D.DrawQuad(Vector3(_smallLines.Width / 2, _smallLines.Height / 2, 0), Vector2(_smallLines.Width, _smallLines.Height), 0, _smallLines, .White, .(0, 0, 1, 1));
Renderer2D.DrawQuad(float3(_smallLines.Width / 2, _smallLines.Height / 2, 0), float2(_smallLines.Width, _smallLines.Height), 0, _smallLines, .White, .(0, 0, 1, 1));
FontRenderer.DrawText(_smallLinesInfo, 0, _smallLines.Height);
float f = _smallLines.Height / 2;
Renderer2D.DrawQuad(Vector3(_smallLines.Width * 2, f / 2, 0), Vector2(f, f), 0, .(0.5f, 0.5f, 0.5f));
Renderer2D.DrawQuad(Vector3(_smallLines.Width * 2, 3 * f / 2 + 1, 0), Vector2(f, f), 0, _zeroPointFive);
//Renderer2D.DrawQuad(Vector3(_smallLines.Width + f / 2, 3 * f / 2, 0), Vector2(f, f), 0, .(0.25f, 0.25f, 0.25f));
Renderer2D.DrawQuad(float3(_smallLines.Width * 2, f / 2, 0), float2(f, f), 0, .(0.5f, 0.5f, 0.5f));
Renderer2D.DrawQuad(float3(_smallLines.Width * 2, 3 * f / 2 + 1, 0), float2(f, f), 0, _zeroPointFive);
//Renderer2D.DrawQuad(float3(_smallLines.Width + f / 2, 3 * f / 2, 0), float2(f, f), 0, .(0.25f, 0.25f, 0.25f));
//FontRenderer.DrawText(_halfQuadInfo, _smallLines.Width + f, f / 2);
//Renderer2D.DrawQuad(Vector3(_gammaCorrectionBrightness.Width / 2, _smallLines.Height * 1.5f, 0), Vector2(_gammaCorrectionBrightness.Width, _gammaCorrectionBrightness.Height), 0, _gammaCorrectionBrightness, .White, .(0, 0, 1, 1));
//Renderer2D.DrawQuad(float3(_gammaCorrectionBrightness.Width / 2, _smallLines.Height * 1.5f, 0), float2(_gammaCorrectionBrightness.Width, _gammaCorrectionBrightness.Height), 0, _gammaCorrectionBrightness, .White, .(0, 0, 1, 1));
//Renderer2D.DrawQuad(Vector3(_smallLines.Width + f / 2, 500, 0), Vector2(f, f), 0, .(0.1f, 0.1f, 0.1f));
//Renderer2D.DrawQuad(Vector3(_gammaCorrectionBrightness.Width / 2, 0, 0), Vector2(_gammaCorrectionBrightness.Width, _gammaCorrectionBrightness.Height), 0, _gammaCorrectionBrightness, .White, .(0, 0, 1, 1));
//Renderer2D.DrawQuad(float3(_smallLines.Width + f / 2, 500, 0), float2(f, f), 0, .(0.1f, 0.1f, 0.1f));
//Renderer2D.DrawQuad(float3(_gammaCorrectionBrightness.Width / 2, 0, 0), float2(_gammaCorrectionBrightness.Width, _gammaCorrectionBrightness.Height), 0, _gammaCorrectionBrightness, .White, .(0, 0, 1, 1));
//Renderer2D.DrawQuad(Vector3(0, -200, 0), Vector2(100, 100), 0, .(0.5f, 0.5f, 0.5f));
//Renderer2D.DrawQuad(Vector3(0, -300, 0), Vector2(100, 100), 0, .(0.25f, 0.25f, 0.25f));
//Renderer2D.DrawQuad(float3(0, -200, 0), float2(100, 100), 0, .(0.5f, 0.5f, 0.5f));
//Renderer2D.DrawQuad(float3(0, -300, 0), float2(100, 100), 0, .(0.25f, 0.25f, 0.25f));
//Renderer2D.DrawQuad(Vector3(0, _gammaCorrectionBrightness.Height, 0), Vector2(_gammaCorrectionBrightness.Width, _gammaCorrectionBrightness.Height), 0, _gammaCorrectionBrightness, .(2, 2, 2), .(0, 0, 1, 1));
//Renderer2D.DrawQuad(float3(0, _gammaCorrectionBrightness.Height, 0), float2(_gammaCorrectionBrightness.Width, _gammaCorrectionBrightness.Height), 0, _gammaCorrectionBrightness, .(2, 2, 2), .(0, 0, 1, 1));
Renderer2D.EndScene();
}
+10 -10
View File
@@ -63,7 +63,7 @@ namespace Sandbox
_samplerPoint = SamplerStateManager.GetSampler(desc);
}
Vector2 _position;
float2 _position;
bool _moving;
@@ -123,7 +123,7 @@ namespace Sandbox
{
var windowPos = ImGui.GetWindowPos();
var mousePos = ImGui.GetIO().MousePos;
Vector2 mouseInWindow = .(mousePos.x - windowPos.x, mousePos.y - windowPos.y);
float2 mouseInWindow = .(mousePos.x - windowPos.x, mousePos.y - windowPos.y);
bool windowHovered = ImGui.IsWindowHovered();
@@ -180,10 +180,10 @@ namespace Sandbox
_context.SetDepthStencilTarget(_depth);
_context.BindRenderTargets();
Vector2 textureSize = Vector2(viewedTexture.Width, viewedTexture.Height);
Vector2 zoomedTextureSize = textureSize * _zoom;
float2 textureSize = float2(viewedTexture.Width, viewedTexture.Height);
float2 zoomedTextureSize = textureSize * _zoom;
Vector2 targetSize = Vector2(_target.Width, _target.Height);
float2 targetSize = float2(_target.Width, _target.Height);
_effect.Variables["ColorOffset"].SetData(_colorOffset);
_effect.Variables["ColorScale"].SetData(_colorScale);
@@ -203,19 +203,19 @@ namespace Sandbox
switch(_backgroundMode)
{
case .Black:
Renderer2D.DrawQuadPivotCorner(Vector3(0, 0, 1), targetSize, 0, .Black);
Renderer2D.DrawQuadPivotCorner(float3(0, 0, 1), targetSize, 0, .Black);
case .White:
Renderer2D.DrawQuadPivotCorner(Vector3(0, 0, 1), targetSize, 0, .White);
Renderer2D.DrawQuadPivotCorner(float3(0, 0, 1), targetSize, 0, .White);
case .Checkerboard:
float quadSize = 50.0f;
Vector2 numQuads = (targetSize / 500f) * 10f;
float2 numQuads = (targetSize / 500f) * 10f;
for(float x = 0; x < numQuads.X; x++)
{
for(float y = 0; y < numQuads.Y; y++)
{
Renderer2D.DrawQuadPivotCorner(Vector3(x * quadSize, -y * quadSize, 1), quadSize.XX, 0, ((x + y) % 2 == 0) ? .White : .Gray);
Renderer2D.DrawQuadPivotCorner(float3(x * quadSize, -y * quadSize, 1), quadSize.XX, 0, ((x + y) % 2 == 0) ? .White : .Gray);
}
}
break;
@@ -235,7 +235,7 @@ namespace Sandbox
Renderer2D.BeginScene(_camera, .SortByTexture, _effect);
Renderer2D.DrawQuadPivotCorner(Vector3(_position * .(1, -1), 0), zoomedTextureSize, 0, viewedTexture);
Renderer2D.DrawQuadPivotCorner(float3(_position * .(1, -1), 0), zoomedTextureSize, 0, viewedTexture);
Renderer2D.EndScene();