Difference between revisions of "GAM666/DPS901 Student Resources"

From CDOT Wiki
Jump to: navigation, search
(Created page with '{{GAM666/DPS901 Index | 20103}} =Student Resources= The purpose of this page is to provide a space for students to share useful information that can help groups with their game p…')
 
(Fixed a few typos)
 
(20 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{GAM666/DPS901 Index | 20103}}
+
{{GAM666/DPS901 Index | 20123}}
=Student Resources=
+
 
The purpose of this page is to provide a space for students to share useful information that can help groups with their game projects.
+
 
 +
 
 +
=Fixing Error S1023 for DirectX SDK=
 +
 
 +
I had issues installing the DirectX SDK June 2010. I kept getting an error (S1023).
 +
 
 +
I found a blog that explains how to fix the error.http://blogs.msdn.com/b/chuckw/archive/2011/12/09/known-issue-directx-sdk-june-2010-setup-and-the-s1023-error.aspx
 +
 
 +
From the blog:
 +
 
 +
(1) Remove the Visual C++ 2010 Redistributable Package version 10.0.40219 (Service Pack 1) from the system (both x86 and x64 if applicable). This can be easily done via a command-line with administrator rights:
 +
 
 +
<pre>MsiExec.exe /passive /X{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}
 +
 
 +
MsiExec.exe /passive /X{1D8E6291-B0D5-35EC-8441-6616F567A0F7}</pre>
 +
 
 +
(2) Install the DirectX SDK (June 2010)
 +
 
 +
(3) Reinstall the Visual C++ 2010 Redistributable Package version 10.0.40219 (Service Pack 1). On an x64 system, you should install both the x86 and x64 versions of the C++ REDIST. Be sure to install the most [http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=26999  current version available] , which at this point is the KB 2565063 with a security fix.
 +
 
 +
Following those steps fixed my problem with the installation of DirectX SDK.
 +
 
 +
-[[User:Maronin|maronin]]
 +
 
 +
=Power Tools for Visual Studio=
 +
 
 +
I found a neat extension for VS that includes productivity tools that makes it even better to use. I just thought I'd share this.
 +
 
 +
[http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef Link]
 +
 
 +
Some of the tools include useful features like:
 +
 
 +
*highlighting all occurrences of a word
 +
 
 +
*triple click to highlight entire line
 +
 
 +
*formatting tool to align assignment
 +
 
 +
*ctrl+click to the source of the defenition
 +
 
 +
*and more...
 +
 
 +
You can always disable a feature that you don't want in tools>options>Productivity Extension.
 +
 
 +
Note: This extension only works with 2010 version of Visual Studio.
 +
 
 +
-[[User:Maronin|maronin]]
 +
 
 +
=Review Material for Test 1=
 +
 
 +
Possible test question
 +
 
 +
  d3d->CreateDevice( ) //returns &d3dd
 +
  sprite->D3DCreateSprite() //returns &sprite
 +
    //com Direct3D object
 +
d3dd -> Clear ()
 +
  // { single frame
 +
  d3dd -> BeginScene()
 +
  //[ drawing graphic
 +
  sprite->Begin()
 +
  sprite->Draw()
 +
  sprite->End()
 +
// ]
 +
d3dd ->EndScene()
 +
  //}
 +
d3dd -> Present()
 +
[[User:Sezar Gantous | -Sezar]]
 +
<hr/>
 +
 
 +
* Windows Programming
 +
** Windows Functions ([http://msdn.microsoft.com/en-us/library/windows/desktop/ms633559%28v=vs.85%29.aspx WinMain], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms646291%28v=vs.85%29.aspx EnableWindow], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms632667%28v=vs.85%29.aspx AdjustWindowRectEx], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms645515%28v=vs.85%29.aspx SendDlgItemMessage], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms645481%28v=vs.85%29.aspx GetDlgItem], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633586%28v=vs.85%29.aspx RegisterClass], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms645452%28v=vs.85%29.aspx DialogBox] (macro), [http://msdn.microsoft.com/en-us/library/windows/desktop/ms632682%28v=vs.85%29.aspx DestroyWindow], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms632679%28v=vs.85%29.aspx CreateWindow], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx ShowWindow], [http://msdn.microsoft.com/en-us/library/windows/desktop/dd145167%28v=vs.85%29.aspx UpdateWindow], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms644943%28v=vs.85%29.aspx PeekMessage], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms644955%28v=vs.85%29.aspx TranslateMessage], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms644944%28v=vs.85%29.aspx PostMessage], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms644934%28v=vs.85%29.aspx DispatchMessage], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms648393%28v=vs.85%29.aspx Setcursor], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms644945%28v=vs.85%29.aspx PostQuitMessage], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633572%28v=vs.85%29.aspx DefWindowProc], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms644956%28v=vs.85%29.aspx WaitMessage], [http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505%28v=vs.85%29.aspx MessageBox])
 +
** [http://msdn.microsoft.com/en-us/library/windows/desktop/ms633570%28v=vs.85%29.aspx Window Procedures]or Scroll UP on this [https://scs.senecac.on.ca/~gam666/pages/content/windo.html#s01 page] and Scroll UP on this [https://scs.senecac.on.ca/~gam666/pages/content/displ.html#dis page]
 +
* [https://scs.senecac.on.ca/~gam666/pages/content/direc.html#com COM Technology]
 +
* [https://scs.senecac.on.ca/~gam666/pages/content/direc.html#dir Direct3D]
 +
** Direct3D COM Object
 +
** Direct3D Display Device COM Object
 +
** Direct3D Texture COM Object
 +
* Game Programming Aspects
 +
** Singletons and Interfaces
 +
** Event Iteration, Messages, and Timing
 +
** Re-Configuration, Loss and Restoration of Focus
 +
** Design, Coordination, Graphic Representation
 +
** Colour and Backbuffering
 +
** Action-Key Mapping
 +
 
 +
modified by [[User:Sezar Gantous | -Sezar]] Oct 06 2012(Found a mistake? let me know [http://nullbyte777.blogspot.ca/2012/09/test-1-finction-links.html here])
 +
<br />
 +
 
 +
=Project Resources=
 +
The purpose of this page is to share useful information that can help groups with their game projects.
 +
 
 +
 
 +
==A Note on Visual Studio Includes==
 +
* Brings this uptodate for DirectX June 2010 SDK
 +
A problem that we ran into here at [[Team Mutalisk]] was that our '''vcxproj''' file was being committed into the repository along with the committing user's include information. The problem with this was that other members had different include paths to the DX SDK and so when they updated after that user had committed, their '''vcxproj''' file would be updated and the project would not compile for them.
 +
 
 +
We've come up with a solution to this problem:
 +
 
 +
# Set the header include path ('''Solution->Right-Click Project->Properties->Configuration Properties->VC++ Directories->Include Directories''') for the project to: <code>$(IncludePath);%INCLUDE%;</code>
 +
# Set the library include path ('''Solution->Right-Click Project->Properties->Configuration Properties->VC++ Directories->Library Directories''') for the project to: <code>$(LibraryPath);%LIB%;</code>
 +
# Do this for all configurations ('''Solution->Right-Click Project->Properties->Configuration(top of box)''')
 +
# Create/Set the environmental variables <code>INCLUDE</code> and <code>LIB</code> on your system. Do this through the '''Environment Variables''' dialog box.
 +
#* ('''Win7/Vista:''' Start Menu->Right-Click Computer->Properties->Advanced system settings->Advanced tab->Environment Variables)
 +
#* ('''WinXP:''' Start Menu->Right-Click My Computer->Properties->Advanced tab->Environment Variables)
 +
# You can add the environment variables to either only your account, at which point the project will only compile when you are logged into your own account, or to the entire system, at which point the project will compile will compile on any account on your machine. Make a decision and then click '''New''' under the appropriate list (top is user, bottom is system).
 +
#* Please note that in order to modify system environmental variables, your account must possess admin privileges or you must know the admin credentials (win 7) or must be logged into the admin account (Vista or older).
 +
# First create the variable <code>INCLUDE</code>. Enter <code>INCLUDE</code> in the '''Variable name''' box. Enter the path to your DX SDK/Include in the '''Variable value''' box; eg if my DX SDK is located at <code>C:\Program Files\Microsoft DirectX SDK (August 2007)</code> then the value of my <code>INCLUDE</code> variable would be: <code>C:\Program Files\Microsoft DirectX SDK (August 2007)\Include;</code>
 +
# Second create the variable <code>LIB</code>. Enter <code>LIB</code> in the '''Variable name''' box. Enter the path to your DX SDK/Lib/x86 in the '''Variable value''' box; eg if my DX SDK is located at <code>C:\Program Files\Microsoft DirectX SDK (August 2007)</code> then the value of my <code>LIB</code> variable would be: <code>C:\Program Files\Microsoft DirectX SDK (August 2007)\Lib\x86;</code>
 +
#* Please note that if either of the two variables already exists on your system, simply edit its value and concatenate the relevant path to its current value. Ensure that all paths are separated by semicolons. Eg: <code>C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib;C:\Program Files\Microsoft DirectX SDK (August 2007)\Lib\x86;</code>
 +
# Logout then login to refresh the windows environmental variable cache.
 +
# Attempt to compile the project. Assuming that you have no syntax errors or other unrelated problems, the project should compile. If it does, then it's time commit the '''vcxproj''' file to your repository. Now that it's up there, others can modify it (add/remove files) without worrying about breaking other group members' dependencies.
 +
 
 +
This concludes the vcxproj tutorial, cheers!
 +
 
 +
-[[User:NorthWind87|northWind]]
  
 
==Useful diagrams==
 
==Useful diagrams==
Line 12: Line 126:
 
==Useful code snippets==
 
==Useful code snippets==
 
     foo("Hello World");
 
     foo("Hello World");
 +
==Collision Code Snippets ==
 +
Two teams have asked me to upgrade the framework to handle collisions.  You can complete the upgrade by adding the follow snippets:
 +
 +
<pre>
 +
// add this code to Design::initialize() - use proper values for min max points
 +
 +
    jumper->setAxisAligned(Vector(-10, -10, -10), Vector(10, 10, 10));
 +
    pedestal->setAxisAligned(Vector(-10, -10, -10), Vector(10, 10, 10));
 +
 
 +
 
 +
// add this code to Design::update() where dx, dy, dz are time increments in x, y, z directions
 +
 
 +
    // check for collision
 +
    unsigned flags = 0u;
 +
    Vector d((float)dx, (float)dy, (float)dz);
 +
    d *= FORWARD_SPEED;
 +
    if (collision(pedestal, jumper, d, flags)) {
 +
        // respond to collision with left object
 +
        rollRight->translate(-d.x, -d.y, -d.z);
 +
        if (flags & 1u)
 +
            d.x = -d.x;
 +
        if (flags & 2u)
 +
            d.y = -d.y;
 +
        if (flags & 4u)
 +
            d.z = -d.z;
 +
        rollRight->translate(d.x, d.y, d.z);
 +
    }
 +
     
 +
 
 +
// add this code to Frame.cpp and change signature of collision() in Frame.h
 +
 
 +
bool collision(const Shape* f1, const Shape* f2, Vector& d, unsigned& flags) {
 +
    // ...
 +
    else if (f1->axisAligned && f2->axisAligned) {
 +
        Vector a = f1->position();
 +
        Vector b = f2->position();
 +
        Vector ax = f1->maximum * f1->world();
 +
        Vector an = f1->minimum * f1->world();
 +
        Vector bx = f2->maximum * f2->world();
 +
        Vector bn = f2->minimum * f2->world();
 +
        collide =
 +
            ax.x >= bn.x && an.x <= bx.x &&
 +
            ax.y >= bn.y && an.y <= bx.y &&
 +
            ax.z >= bn.z && an.z <= bx.z;
 +
        if (collide) {
 +
            float lambdaxp, lambdayp, lambdazp, lambdaxn, lambdayn, lambdazn, lambda = 1.0f;
 +
            Vector n = d / d.length();
 +
            if (fabs(n.x) > 1.0e-5f) {
 +
                lambdaxp = (ax.x - bn.x) / n.x;
 +
                lambdaxn = (an.x - bx.x) / n.x;
 +
                if (lambdaxp <= 1.0f && lambdaxn >= 0.0f && lambdaxp < lambdaxn)
 +
                    lambda = lambdaxp;
 +
                else if (lambdaxp <= 1.0f && lambdaxn >= 0.0f && lambdaxn < lambdaxp)
 +
                    lambda = lambdaxn;
 +
                else if (lambdaxp <= 1.0f && lambdaxp >= 0.0f)
 +
                    lambda = lambdaxp;
 +
                else if (lambdaxn >= 0.0f && lambdaxn <= 1.0f)
 +
                    lambda = lambdaxn;
 +
                flags = 1u;
 +
            }
 +
            if (fabs(n.y) > 1.0e-5f) {
 +
                lambdayp = (ax.y - bn.y) / n.y;
 +
                lambdayn = (an.y - bx.y) / n.y;
 +
                float lambda0 = lambda;
 +
                if (lambdayp <= 1.0f && lambdayn >= 0.0f && lambdayp < lambdayn && lambda > lambdayp)
 +
                    lambda = lambdayp;
 +
                else if (lambdayp <= 1.0f && lambdayn >= 0.0f && lambdayn < lambdayp && lambda > lambdayn)
 +
                    lambda = lambdayn;
 +
                else if (lambdayp <= 1.0f && lambdayp >= 0.0f && lambda > lambdayp)
 +
                    lambda = lambdayp;
 +
                else if (lambda >= 0.0f && lambdayn <= 1.0f && lambda > lambdayn)
 +
                    lambda = lambdayn;
 +
                if (lambda != lambda0)
 +
                    flags = 2u;
 +
            }
 +
            if (fabs(n.z) > 1.0e-5f) {
 +
                lambdazp = (ax.z - bn.z) / n.z;
 +
                lambdazn = (an.z - bx.z) / n.z;
 +
                float lambda0 = lambda;
 +
                if (lambdazp <= 1.0f && lambdazn >= 0.0f && lambdazp < lambdazn && lambda > lambdazp)
 +
                    lambda = lambdazp;
 +
                else if (lambdazp <= 1.0f && lambdazn >= 0.0f && lambdazn < lambdazp && lambda > lambdazn)
 +
                    lambda = lambdazn;
 +
                else if (lambdazp <= 1.0f && lambdazp >= 0.0f && lambda > lambdazp)
 +
                    lambda = lambdazp;
 +
                else if (lambdazn >= 0.0f && lambdazn <= 1.0f && lambda > lambdazn)
 +
                    lambda = lambdazn;
 +
                if (lambda != lambda0)
 +
                    flags = 4u;
 +
            }
 +
            d -= lambda * n;
 +
        }
 +
    }
 +
</pre>

Latest revision as of 17:59, 13 October 2012


GAM666/DPS901 | Weekly Schedule | Student List | Project Requirements | Teams and their Projects | Student Resources




Fixing Error S1023 for DirectX SDK

I had issues installing the DirectX SDK June 2010. I kept getting an error (S1023).

I found a blog that explains how to fix the error.http://blogs.msdn.com/b/chuckw/archive/2011/12/09/known-issue-directx-sdk-june-2010-setup-and-the-s1023-error.aspx

From the blog:

(1) Remove the Visual C++ 2010 Redistributable Package version 10.0.40219 (Service Pack 1) from the system (both x86 and x64 if applicable). This can be easily done via a command-line with administrator rights:

MsiExec.exe /passive /X{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}

MsiExec.exe /passive /X{1D8E6291-B0D5-35EC-8441-6616F567A0F7}

(2) Install the DirectX SDK (June 2010)

(3) Reinstall the Visual C++ 2010 Redistributable Package version 10.0.40219 (Service Pack 1). On an x64 system, you should install both the x86 and x64 versions of the C++ REDIST. Be sure to install the most current version available , which at this point is the KB 2565063 with a security fix.

Following those steps fixed my problem with the installation of DirectX SDK.

-maronin

Power Tools for Visual Studio

I found a neat extension for VS that includes productivity tools that makes it even better to use. I just thought I'd share this.

Link

Some of the tools include useful features like:

  • highlighting all occurrences of a word
  • triple click to highlight entire line
  • formatting tool to align assignment
  • ctrl+click to the source of the defenition
  • and more...

You can always disable a feature that you don't want in tools>options>Productivity Extension.

Note: This extension only works with 2010 version of Visual Studio.

-maronin

Review Material for Test 1

Possible test question

 d3d->CreateDevice( ) //returns &d3dd
 sprite->D3DCreateSprite() //returns &sprite
   //com Direct3D object
d3dd -> Clear ()
 // { single frame
 d3dd -> BeginScene()
 //[ drawing graphic
  sprite->Begin()
  sprite->Draw()
  sprite->End()
// ]
d3dd ->EndScene()
 //}
d3dd -> Present()

-Sezar


modified by -Sezar Oct 06 2012(Found a mistake? let me know here)

Project Resources

The purpose of this page is to share useful information that can help groups with their game projects.


A Note on Visual Studio Includes

  • Brings this uptodate for DirectX June 2010 SDK

A problem that we ran into here at Team Mutalisk was that our vcxproj file was being committed into the repository along with the committing user's include information. The problem with this was that other members had different include paths to the DX SDK and so when they updated after that user had committed, their vcxproj file would be updated and the project would not compile for them.

We've come up with a solution to this problem:

  1. Set the header include path (Solution->Right-Click Project->Properties->Configuration Properties->VC++ Directories->Include Directories) for the project to: $(IncludePath);%INCLUDE%;
  2. Set the library include path (Solution->Right-Click Project->Properties->Configuration Properties->VC++ Directories->Library Directories) for the project to: $(LibraryPath);%LIB%;
  3. Do this for all configurations (Solution->Right-Click Project->Properties->Configuration(top of box))
  4. Create/Set the environmental variables INCLUDE and LIB on your system. Do this through the Environment Variables dialog box.
    • (Win7/Vista: Start Menu->Right-Click Computer->Properties->Advanced system settings->Advanced tab->Environment Variables)
    • (WinXP: Start Menu->Right-Click My Computer->Properties->Advanced tab->Environment Variables)
  5. You can add the environment variables to either only your account, at which point the project will only compile when you are logged into your own account, or to the entire system, at which point the project will compile will compile on any account on your machine. Make a decision and then click New under the appropriate list (top is user, bottom is system).
    • Please note that in order to modify system environmental variables, your account must possess admin privileges or you must know the admin credentials (win 7) or must be logged into the admin account (Vista or older).
  6. First create the variable INCLUDE. Enter INCLUDE in the Variable name box. Enter the path to your DX SDK/Include in the Variable value box; eg if my DX SDK is located at C:\Program Files\Microsoft DirectX SDK (August 2007) then the value of my INCLUDE variable would be: C:\Program Files\Microsoft DirectX SDK (August 2007)\Include;
  7. Second create the variable LIB. Enter LIB in the Variable name box. Enter the path to your DX SDK/Lib/x86 in the Variable value box; eg if my DX SDK is located at C:\Program Files\Microsoft DirectX SDK (August 2007) then the value of my LIB variable would be: C:\Program Files\Microsoft DirectX SDK (August 2007)\Lib\x86;
    • Please note that if either of the two variables already exists on your system, simply edit its value and concatenate the relevant path to its current value. Ensure that all paths are separated by semicolons. Eg: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib;C:\Program Files\Microsoft DirectX SDK (August 2007)\Lib\x86;
  8. Logout then login to refresh the windows environmental variable cache.
  9. Attempt to compile the project. Assuming that you have no syntax errors or other unrelated problems, the project should compile. If it does, then it's time commit the vcxproj file to your repository. Now that it's up there, others can modify it (add/remove files) without worrying about breaking other group members' dependencies.

This concludes the vcxproj tutorial, cheers!

-northWind

Useful diagrams

Useful links around the web

Useful code snippets

   foo("Hello World");

Collision Code Snippets

Two teams have asked me to upgrade the framework to handle collisions. You can complete the upgrade by adding the follow snippets:

// add this code to Design::initialize() - use proper values for min max points

    jumper->setAxisAligned(Vector(-10, -10, -10), Vector(10, 10, 10));
    pedestal->setAxisAligned(Vector(-10, -10, -10), Vector(10, 10, 10));
   
   
// add this code to Design::update() where dx, dy, dz are time increments in x, y, z directions
   
    // check for collision
    unsigned flags = 0u;
    Vector d((float)dx, (float)dy, (float)dz);
    d *= FORWARD_SPEED;
    if (collision(pedestal, jumper, d, flags)) {
        // respond to collision with left object
        rollRight->translate(-d.x, -d.y, -d.z);
        if (flags & 1u)
            d.x = -d.x;
        if (flags & 2u)
            d.y = -d.y;
        if (flags & 4u)
            d.z = -d.z;
        rollRight->translate(d.x, d.y, d.z);
    }
       
   
// add this code to Frame.cpp and change signature of collision() in Frame.h
   
bool collision(const Shape* f1, const Shape* f2, Vector& d, unsigned& flags) {
    // ...
    else if (f1->axisAligned && f2->axisAligned) {
        Vector a = f1->position();
        Vector b = f2->position();
        Vector ax = f1->maximum * f1->world();
        Vector an = f1->minimum * f1->world();
        Vector bx = f2->maximum * f2->world();
        Vector bn = f2->minimum * f2->world();
        collide =
            ax.x >= bn.x && an.x <= bx.x &&
            ax.y >= bn.y && an.y <= bx.y &&
            ax.z >= bn.z && an.z <= bx.z;
        if (collide) {
            float lambdaxp, lambdayp, lambdazp, lambdaxn, lambdayn, lambdazn, lambda = 1.0f;
            Vector n = d / d.length();
            if (fabs(n.x) > 1.0e-5f) {
                lambdaxp = (ax.x - bn.x) / n.x;
                lambdaxn = (an.x - bx.x) / n.x;
                if (lambdaxp <= 1.0f && lambdaxn >= 0.0f && lambdaxp < lambdaxn)
                    lambda = lambdaxp;
                else if (lambdaxp <= 1.0f && lambdaxn >= 0.0f && lambdaxn < lambdaxp)
                    lambda = lambdaxn;
                else if (lambdaxp <= 1.0f && lambdaxp >= 0.0f)
                    lambda = lambdaxp;
                else if (lambdaxn >= 0.0f && lambdaxn <= 1.0f)
                    lambda = lambdaxn;
                flags = 1u;
            }
            if (fabs(n.y) > 1.0e-5f) {
                lambdayp = (ax.y - bn.y) / n.y;
                lambdayn = (an.y - bx.y) / n.y;
                float lambda0 = lambda;
                if (lambdayp <= 1.0f && lambdayn >= 0.0f && lambdayp < lambdayn && lambda > lambdayp)
                    lambda = lambdayp;
                else if (lambdayp <= 1.0f && lambdayn >= 0.0f && lambdayn < lambdayp && lambda > lambdayn)
                    lambda = lambdayn;
                else if (lambdayp <= 1.0f && lambdayp >= 0.0f && lambda > lambdayp)
                    lambda = lambdayp;
                else if (lambda >= 0.0f && lambdayn <= 1.0f && lambda > lambdayn)
                    lambda = lambdayn;
                if (lambda != lambda0)
                    flags = 2u;
            }
            if (fabs(n.z) > 1.0e-5f) {
                lambdazp = (ax.z - bn.z) / n.z;
                lambdazn = (an.z - bx.z) / n.z;
                float lambda0 = lambda;
                if (lambdazp <= 1.0f && lambdazn >= 0.0f && lambdazp < lambdazn && lambda > lambdazp)
                    lambda = lambdazp;
                else if (lambdazp <= 1.0f && lambdazn >= 0.0f && lambdazn < lambdazp && lambda > lambdazn)
                    lambda = lambdazn;
                else if (lambdazp <= 1.0f && lambdazp >= 0.0f && lambda > lambdazp)
                    lambda = lambdazp;
                else if (lambdazn >= 0.0f && lambdazn <= 1.0f && lambda > lambdazn)
                    lambda = lambdazn;
                if (lambda != lambda0)
                    flags = 4u;
            }
            d -= lambda * n;
        }
    }