Updates


August 31, 2014. Added support for picking point primitives and line segment primitives. The picking for triangles uses intersection tests. The picking for points and segments uses distance tests. The sample application was updated to show how this works. The line-segment distance code had a porting bug that was fixed; the returned distance was incorrectly set to zero when the segment closest point was an interior point. Modified our header dependency tool to trap problems when precompiled headers are disabled. The include of GTEngine.h in GTEnginePCH.h needed to be disabled to trap problems in cpp files. The following files had missing dependencies when we did this. These are nonessential changes for the engine, because the GTEngine project has precompiled headers enabled. You can get these changes when we post GTEngine 1.3.
August 30, 2014. Added the ability to specify the matrix storage convention and matrix-vector multiplication convention externally. The comments in the file explain the rationale and consequences of doing so. Added new template functions to allow conversions between N-tuples and (N+1)-tuples. These include HLift, HProject, Lift, and Project. The comments in the .h file explain what each function does. The HLift and HProject functions are particularly useful for conversions between Vector3<Real> and Vector4<Real> objects. The SetSegment and GetSegment functions needed to distinguish between disjoint line segments (IP_POLYSEGMENT_DISJOINT) and contiguous line segments (IP_POLYSEGMENT_CONTIGUOUS).
August 29, 2014. Posted GeometricToolsEngine1p2.zip.
August 29, 2014. Added HasMember functions to test for the existence of member data with the specified name. A small amount of refactoring of Picker to prepare for supporting point and line primitives (distance based). The triangle picking code was tested using a new sample application. Fixed a bug in the Shader constructor when generating the member layouts for constant buffers and texture buffers. The indices into the layout arrays were not incremented, which led to incorrect behavior for shaders with two or more such buffers. Fixed a bug in the GenerateLayout member function. The shader type's offset was used to determine member offset in the structure, but the shader variable's offset has to be used instead (at the root of the recursion). A change in the semantics for Environment::GetPath when no directories exist was not propagated to the append-consume buffer sample application, causing a bogus assertion when trying to find the HLSL file associated with the application. The hiding of the trackball rotation matrix inside the Window class prevented picking from working properly. The registration system that updated shader constants with projection-view-world transforms from the world transforms of associated objects needed a redesign. The trackball rotation is no longer applied implicitly. You can access it via a public member function. The Register/Unregister calls were replaced by two subscription interfaces, one to subscribe to changes in the camera changes and have the pvw-matrices automatically updated--this is what the Register/Unregister system did. However, there is interaction between updating world transforms and pvw-matrices for effects, so a second subscription interface is used to have world transforms of objects automatically updated when the virtual trackball moves. The redesign led to many changes in sample applications. While we were in there, we cleaned up and refactored some of the samples to make the code more readable (consistent use of 'bool SetEnvironment' and 'bool CreateScene'). The Window class also has a new member function for computing a picking line for the current viewport and camera settings. This is used in conjunction with the Picker class.
August 26, 2014. Refactored the basic lighting effects to share code, fixing several bugs in the process. Two new classes were added, LightingConstants and LightingEffect. Added a new sample application to illustrate the effects; this is a port of the Wild Magic 5 Lights sample. The files GteLightAmbientEffect.inl, GteLightDirectionPerVertexEffect.inl, GteLightDirectionPerPixelEffect.inl, GteLightPointPerVertexEffect.inl, GteLightPointPerPixelEffect.inl, GteLightSpotPerVertexEffect.inl, and GteLightSpotPerPixelEffect.inl were removed from the distribution. The MSDN documentation for ID3D11DeviceContext::IASetVertexBuffers and ID3D11DeviceContext::Draw(numVertices, startVertex) appears not to mention that startVertex is relative to the offsets[] passed to IASetVertexBuffers. Fixed the enabling of vertex buffers to set the offsets to zero. The DX11Engine::DrawPrimitive function passes the vertex buffer offset through the startVertex parameter.
August 19, 2014. Posted GeometricToolsEngine1p1.zip.
August 19, 2014. These modifications are related to getting the code, not including the Windows-specific graphics and application code, to compile on Linux and Macintosh OS X. The first batch of changes were consequences of trying to compile on Macintosh OS X. The second batch is due to Linux compilation, although changes in the first batch no doubt were needed anyway on Linux.

Hide the Windows-specific information from the other platforms. The compiler did not like the #pragma once in the precompiled header file. The LLVM compiler successfully compiled Delaunay2Mesh and Delaunay3Mesh in our header verification tool when you compile in a single file. However, when a build-project is initiated, LLVM attempted to use the template parameter Rational as if it were an actual type and complained when trying to instantiate Vector{2,3}::ComputeBarycentrics. In particular, we had a line if (std::abs(det) > epsilon) for which LLVM said std::abs is ambiguous and that it did not match any of the standard functions for floating-point types. For now, we modified the code for ComputeBarycentrics to use if (det < -epsilon || det > epsilon). LLVM does not have versions of the secure memcpy_s that Microsoft Visual Studio does. Added conditional compilation to handle this. Eliminated the typedef of Function. LLVM had difficulties with this in the derived classes. Removed the (WM5) using statements and added the explicit scoping by this->. Removed the explicit last parameter to ComputeBarycentrics. The default parameter has the same value. The file <iterator> needed to be included to access the definitions of std::begin, std::end, and std::reverse_iterator. Microsoft Visual Studio 2013 allowed the compilation without it, but not LLVM. The class had two member functions that required two implicit conversions to return values. One of them has to be explicit, and LLVM requires this. The definition of size_t appears to be built into Microsoft Visual Studio 2013. On LLVM, it is defined in <cstddef>, so this header file needed to be #include-d. The declaration for triangle barycentric coordinates was the incorrect size. The header needed to #include <set> because the class has a member using this container. We have an internal tool that #include-s each header file in a cpp file and tests whether it compiles. This is designed to expose a header file that might not #include any dependencies it has. If the header is for template classes or functions, we also explicitly instantiate those in order to trap any compiler errors. Naturally, the tool has precompiled headers disabled. Surprisingly, some code passed the tests when compiling with Microsoft Visual Studio 2013 but the same code failed compilation on LLVM. For example, the GetContainer function in GteContEllipsoid3.inl incorrectly had a Vector2 input when it should have been Vector3. This code passed the explicit instantiation compiler test using Microsoft Visual Studio 2013. Microsoft's compilers still violate the ANSI C++ standard that requires template derived classes to explicitly scope any access to template base class members or functions via this->mBaseMember and this->BaseFunction. [In Wild Magic, we chose the using statement in the derived-class headers but decided against this in GTEngine because of the potential change in access rights (public, protected, private).] Added typename modifiers to some variable declarations. Microsoft Visual Studio 2013 allowed the declarations without the modifiers, but not LLVM. BSNumber had a declaration to make BSRational a friend. Microsoft Visual Studio 2013 allowed the original code, but not LLVM. Forward declared the BSRational template and modified the friend statement. [The same mechanism had been used in Wild Magic to satisfy all compilers.] Microsoft Visual Studio 2013 allows you to make calls to math library functions such as std::abs and sqrt without #include-ing <cmath>. Added the #include to satisfy LLVM. Removed an incorrect static cast of a 32-bit value to a 64-bit value when the return value of the function is in fact 32-bit. The explicit instantiation of the oppositeFace array required a template< > modifier. The explicit instantiation of image classes needed to be inside a namespace block. Removed the AlignedMemory class from the engine. It is not used, and the _aligned_malloc and _aligned_free calls do not exist on Macintosh OS X. The changes below were necessary after the previous ones to get the code to compile on Linux.

The explicit instantiations had to occur inside a namespace block. A 'using namespace gte' was not sufficient. The class uses the var-args system so we needed to include <cstdarg>. The files use std::numeric_limits and needed to include <limits>. The files use memcpy or memset and needed to include <cstring>. The conditional compilation is now based on WIN32 (or not). The files use std::min, std::max, std::sort, or std::nth_element and needed to include <algorithm>.
August 17, 2014. These modifications are related to the porting of the Wild Magic interpolation code to GTEngine.

Ported most of the Wild Magic interpolation code to GTEngine. A sample application illustrates use of the interpolators for 2D height-field data. Added wrappers for the meshes produced by Delaunay triangulation and tetrahedralization. Access to the input vertices of the DelaunayN classes was required to support this. The wrappers allow the interpolators to interact with general triangles mesh that are not produced by the Delaunay code. (Wild Magic forced you to use Delaunay meshes.) Added a mesh creator for regular triangle meshes ("half" a rectangle mesh). When computing barycentric coordinates, replaced the separate Dot and Cross functions by the single calls to DotCross. Added functions AllocateMapN and DeallocateMapN for N = 2, 3, 4. This allows for wrapping an already existing 1-dimensional array with multidimensional array access.
August 15, 2014. Fixed a typographical error in Equation (14). (Thanks to Pierre Maxted for reporting this.) Replaced the LaTeX verbatim commands with lstlisting commands for more readable pseudocode.
August 13, 2014. The files were missing the #pragma once guards against multiple inclusions.
August 11, 2014. Posted GeometricToolsEngine1p0.zip.