swiss ok, needs more benchmark

This commit is contained in:
Youmu Liu
2026-03-06 18:22:30 +08:00
parent 83997f64d0
commit f6e897ed06
70 changed files with 1889 additions and 3371 deletions
+39 -13
View File
@@ -58,7 +58,11 @@ namespace StgSharp.Mathematics.Graphics
_projection = new Matrix44();
}
public Camera(Vec3 position, Vec3 target, Vec3 up)
public Camera(
Vec3 position,
Vec3 target,
Vec3 up
)
: this()
{
rotationAtt = Matrix44.Unit;
@@ -103,13 +107,16 @@ namespace StgSharp.Mathematics.Graphics
/// Shader program requires this camera.
/// </param>
/// <param _label="uniformName">
/// ContextName of all related uniforms. If you fallow form from <see
/// ContextName of all related uniforms. If you fallow form from <see ///
/// cref="IglConvertable.DisplayGLtypeDefinition" />
/// </param>
/// <exception cref="ArgumentException">
///
/// </exception>
public unsafe void GainAllUniforms(ShaderProgram source, params string[] uniformName)
public unsafe void GainAllUniforms(
ShaderProgram source,
params string[] uniformName
)
{
if (uniformName is null || uniformName.Length != 1) {
throw new ArgumentException(
@@ -118,19 +125,25 @@ namespace StgSharp.Mathematics.Graphics
convertedUniform = source.GetUniform<Matrix44>(uniformName[0]);
}
public void MoveNear(float distance)
public void MoveNear(
float distance
)
{
cameraAtt.column[3].Z -= distance;
_isLookAtAvailable = false;
}
public void MoveRight(float distance)
public void MoveRight(
float distance
)
{
cameraAtt.column[3].X -= distance;
_isLookAtAvailable = false;
}
public void MoveUp(float distance)
public void MoveUp(
float distance
)
{
cameraAtt.column[3].Y -= distance;
_isLookAtAvailable = false;
@@ -142,7 +155,11 @@ namespace StgSharp.Mathematics.Graphics
OpenGLFunction.CurrentGL.SetUniformValue(convertedUniform, Projection * View);
}
public void SetViewDirection(Vec3 position, Vec3 target, Vec3 up)
public void SetViewDirection(
Vec3 position,
Vec3 target,
Vec3 up
)
{
Vec3 direction = position - target;
if ((position.reg == cameraAtt.column[3].reg) &&
@@ -181,7 +198,8 @@ namespace StgSharp.Mathematics.Graphics
Radius fovRadius,
Vec2 size,
Vec2 offset,
(float front, float back) depthRange)
(float front, float back) depthRange
)
{
float
distance = _target.GetLength(),
@@ -189,7 +207,7 @@ namespace StgSharp.Mathematics.Graphics
far = distance + depthRange.back,
offsetX = offset.X,
offsetY = offset.Y,
width = Scalar.Abs(GeometryScaler.Tan(fovRadius / 2) * near * 2),
width = MathF.Abs(GeometryScaler.Tan(fovRadius / 2) * near * 2),
height = width * size.Y / size.X;
_projection.column[0].X = 2 * near / width;
@@ -201,7 +219,9 @@ namespace StgSharp.Mathematics.Graphics
_projection.column[3].Z = 2 * near * far / (near - far);
}
public void Test(params Vec4[] vec)
public void Test(
params Vec4[] vec
)
{
Console.WriteLine(View);
Console.WriteLine(Projection);
@@ -221,7 +241,9 @@ namespace StgSharp.Mathematics.Graphics
#region rotation
public void Yaw(Radius r)
public void Yaw(
Radius r
)
{
_yaw -= r;
@@ -230,7 +252,9 @@ namespace StgSharp.Mathematics.Graphics
InternalYaw();
}
public void Pitch(Radius r)
public void Pitch(
Radius r
)
{
_pitch -= r;
@@ -239,7 +263,9 @@ namespace StgSharp.Mathematics.Graphics
InternalPitch();
}
public void Row(Radius r)
public void Row(
Radius r
)
{
_row -= r;