Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 30, 2019. It is now read-only.
/SharpDXPublic archive

Commit707244f

Browse files
committed
Replaced perspective view matrix calculation
Replaced perspective view matrix calculation when given FOV and aspectratio. The new implementation does not calculate the view rectangle, sothe result matrix is still valid when znear = 0.
1 parent23bfaa5 commit707244f

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

‎Source/SharpDX.Mathematics/Matrix.cs‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,13 +2291,15 @@ public static Matrix PerspectiveRH(float width, float height, float znear, float
22912291
/// <param name="result">When the method completes, contains the created projection matrix.</param>
22922292
publicstaticvoidPerspectiveFovLH(floatfov,floataspect,floatznear,floatzfar,outMatrixresult)
22932293
{
2294-
floatyScale=(float)(1.0/Math.Tan(fov*0.5f));
2295-
floatxScale=yScale/aspect;
2294+
floatyScale=(float)(1.0f/Math.Tan(fov*0.5f));
2295+
floatq=zfar/(zfar-znear);
22962296

2297-
floathalfWidth=znear/xScale;
2298-
floathalfHeight=znear/yScale;
2299-
2300-
PerspectiveOffCenterLH(-halfWidth,halfWidth,-halfHeight,halfHeight,znear,zfar,outresult);
2297+
result=newMatrix();
2298+
result.M11=yScale/aspect;
2299+
result.M22=yScale;
2300+
result.M33=q;
2301+
result.M34=1.0f;
2302+
result.M43=-q*znear;
23012303
}
23022304

23032305
/// <summary>
@@ -2325,13 +2327,15 @@ public static Matrix PerspectiveFovLH(float fov, float aspect, float znear, floa
23252327
/// <param name="result">When the method completes, contains the created projection matrix.</param>
23262328
publicstaticvoidPerspectiveFovRH(floatfov,floataspect,floatznear,floatzfar,outMatrixresult)
23272329
{
2328-
floatyScale=(float)(1.0/Math.Tan(fov*0.5f));
2329-
floatxScale=yScale/aspect;
2330+
floatyScale=(float)(1.0f/Math.Tan(fov*0.5f));
2331+
floatq=zfar/(znear-zfar);
23302332

2331-
floathalfWidth=znear/xScale;
2332-
floathalfHeight=znear/yScale;
2333-
2334-
PerspectiveOffCenterRH(-halfWidth,halfWidth,-halfHeight,halfHeight,znear,zfar,outresult);
2333+
result=newMatrix();
2334+
result.M11=yScale/aspect;
2335+
result.M22=yScale;
2336+
result.M33=q;
2337+
result.M34=-1.0f;
2338+
result.M43=q*znear;
23352339
}
23362340

23372341
/// <summary>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp