Skip to content

Commit

Permalink
remove netstand support, add math ex
Browse files Browse the repository at this point in the history
  • Loading branch information
2A5F committed Jan 2, 2025
1 parent 08a9046 commit 7308e64
Show file tree
Hide file tree
Showing 155 changed files with 50,677 additions and 87,666 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0</Version>
<Description>hlsl-style linear algebra library sdf part</Description>
<PackageProjectUrl>https://github.com/2A5F/Coplt.Shader</PackageProjectUrl>
<RepositoryUrl>https://github.com/2A5F/Coplt.Shader</RepositoryUrl>
<Description>HLSL-style linear algebra math library with full simd support</Description>
<PackageProjectUrl>https://github.com/coplt/Coplt.Mathematics</PackageProjectUrl>
<RepositoryUrl>https://github.com/coplt/Coplt.Mathematics</RepositoryUrl>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
</PropertyGroup>
Expand Down
6 changes: 6 additions & 0 deletions Coplt.Mathematics.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Coplt.Mathematics.SignedDistances", "Coplt.Mathematics.SignedDistances\Coplt.Mathematics.SignedDistances.csproj", "{A8E41063-557E-4421-88A4-4DE59E49295B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceGenerator", "SourceGenerator\SourceGenerator.csproj", "{D7F6B482-EFD3-46E0-964E-4E2CC53CCE0B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -24,5 +26,9 @@ Global
{A8E41063-557E-4421-88A4-4DE59E49295B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8E41063-557E-4421-88A4-4DE59E49295B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8E41063-557E-4421-88A4-4DE59E49295B}.Release|Any CPU.Build.0 = Release|Any CPU
{D7F6B482-EFD3-46E0-964E-4E2CC53CCE0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7F6B482-EFD3-46E0-964E-4E2CC53CCE0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7F6B482-EFD3-46E0-964E-4E2CC53CCE0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7F6B482-EFD3-46E0-964E-4E2CC53CCE0B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
12 changes: 8 additions & 4 deletions Coplt.Mathematics/Coplt.Mathematics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<RunPostBuildEvent>Always</RunPostBuildEvent>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.8.0</Version>
<Description>hlsl-style linear algebra library</Description>
<PackageProjectUrl>https://github.com/2A5F/Coplt.Shader</PackageProjectUrl>
<RepositoryUrl>https://github.com/2A5F/Coplt.Shader</RepositoryUrl>
<Version>0.9.0</Version>
<Description>HLSL-style linear algebra math library with full simd support</Description>
<PackageProjectUrl>https://github.com/coplt/Coplt.Mathematics</PackageProjectUrl>
<RepositoryUrl>https://github.com/coplt/Coplt.Mathematics</RepositoryUrl>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -34,6 +34,10 @@
<TextTemplate Include="**\*.tt"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SourceGenerator\SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
</ItemGroup>

<!-- Inputs="@(TextTemplate)" Outputs="@(TextTemplate->'%(RelativeDir)%(Filename).cs')"-->
<Target Name="TextTemplateTransform" BeforeTargets="PrepareForBuild" Inputs="@(TextTemplate)" Outputs="@(TextTemplate->'%(RelativeDir)%(Filename).cs')">
<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet tool run t4 -v %(TextTemplate.Identity) -o %(TextTemplate.RelativeDir)%(TextTemplate.Filename).cs -I=%(TextTemplate.RelativeDir)" EnvironmentVariables="ProjectDir=$(ProjectDir)"/>
Expand Down
19 changes: 10 additions & 9 deletions Coplt.Mathematics/Geometries/plane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct plane
public float3 normal
{
[MethodImpl(256 | 512)]
get => normal_and_distance.xyz;
readonly get => normal_and_distance.xyz;
[MethodImpl(256 | 512)]
set => normal_and_distance.xyz = value;
}
Expand All @@ -44,15 +44,15 @@ public float3 normal
public float distance
{
[MethodImpl(256 | 512)]
get => normal_and_distance.w;
readonly get => normal_and_distance.w;
[MethodImpl(256 | 512)]
set => normal_and_distance.w = value;
}

/// <summary>
/// Flips the plane so the normal points in the opposite direction.
/// </summary>
public plane flipped
public readonly plane flipped
{
[MethodImpl(256 | 512)]
get => new() { normal_and_distance = -normal_and_distance };
Expand Down Expand Up @@ -184,7 +184,7 @@ public static float4 normalize(float4 planeCoefficients)
/// <param name="point">Point to find the signed distance with.</param>
/// <returns>Signed distance of the point from the plane.</returns>
[MethodImpl(256 | 512)]
public float distance_to_point(float3 point) => normal_and_distance.dot(new float4(point, 1.0f));
public readonly float distance_to_point(float3 point) => normal_and_distance.dot(new float4(point, 1.0f));

/// <summary>
/// Projects the given point onto the plane.
Expand All @@ -196,7 +196,7 @@ public static float4 normalize(float4 planeCoefficients)
/// <param name="point">Point to project onto the plane.</param>
/// <returns>Projected point that's inside the plane.</returns>
[MethodImpl(256 | 512)]
public float3 projection(float3 point) => point - normal * distance_to_point(point);
public readonly float3 projection(float3 point) => point - normal * distance_to_point(point);

/// <summary>
/// Ray cast to the plane
Expand All @@ -205,7 +205,7 @@ public static float4 normalize(float4 planeCoefficients)
/// <param name="distance">Intersection distance</param>
/// <returns>Is intersect</returns>
[MethodImpl(256 | 512)]
public bool ray_cast(ray ray, out float distance)
public readonly bool ray_cast(ray ray, out float distance)
{
var normal = this.normal;
var de_nom = normal.dot(ray.direction);
Expand All @@ -221,7 +221,7 @@ public bool ray_cast(ray ray, out float distance)
/// <param name="point">Intersection</param>
/// <returns>Is intersect</returns>
[MethodImpl(256 | 512)]
public bool ray_cast(ray ray, out float distance, out float3 point)
public readonly bool ray_cast(ray ray, out float distance, out float3 point)
{
var normal = this.normal;
var de_nom = normal.dot(ray.direction);
Expand All @@ -237,7 +237,7 @@ public bool ray_cast(ray ray, out float distance, out float3 point)
/// <param name="point">The point to project onto the plane.</param>
/// <returns>A point on the plane that is closest to point.</returns>
[MethodImpl(256 | 512)]
public float3 closest_point(float3 point)
public readonly float3 closest_point(float3 point)
{
var normal = this.normal;
return point - normal * (normal.dot(point) + distance);
Expand All @@ -247,11 +247,12 @@ public float3 closest_point(float3 point)

namespace Coplt.Mathematics
{
[Ex]
public static partial class math
{
/// <summary>
/// Normalizes the plane represented by the given plane coefficients.
/// </summary>
public static plane normalize(this plane plane) => new(plane.normalize(plane.normal_and_distance));
public static plane normalize([This] plane plane) => new(plane.normalize(plane.normal_and_distance));
}
}
Loading

0 comments on commit 7308e64

Please sign in to comment.