2
0
Эх сурвалжийг харах

TMatrix from GLS.VectorGeometry renamed to TGLMatrix to be able use TMatrix from System.Math.Vectors without conflicts of names

GLScene 4 жил өмнө
parent
commit
0bfd0aba28
89 өөрчлөгдсөн 811 нэмэгдсэн , 768 устгасан
  1. 5 5
      AdvDemos/CPP/Quake3Demo/Unit1.cpp
  2. 2 2
      AdvDemos/CPP/Quake3Demo/Unit1.h
  3. 6 6
      AdvDemos/Delphi/Forest/Unit1.pas
  4. 3 3
      AdvDemos/Delphi/Quake3Demo/Unit1.pas
  5. 2 2
      Demos/CPP/collisions/BoxSphere/Unit1.cpp
  6. 1 1
      Demos/CPP/collisions/BoxSphere/Unit1.h
  7. 1 1
      Demos/CPP/glslshaders/Ocean/Unit1.cpp
  8. 1 1
      Demos/CPP/graph/projection/Unit1.cpp
  9. 1 1
      Demos/CPP/interface/camera/Unit1.cpp
  10. 1 1
      Demos/CPP/meshes/actorms3d/Unit1.cpp
  11. 2 2
      Demos/CPP/meshes/tiles/Unit1.h
  12. 3 3
      Demos/CPP/physics/NewtonDensity/Unit1.cpp
  13. 5 5
      Demos/CPP/specialsFX/ShadowmappingFBO/Unit1.h
  14. 3 3
      Demos/Delphi/collisions/BoxSphereFm.pas
  15. 1 1
      Demos/Delphi/graph/ProjectionFm.pas
  16. 1 1
      Demos/Delphi/interface/CameraFm.pas
  17. 10 10
      Demos/Delphi/meshes/Actorms3dFm.pas
  18. 1 1
      Demos/Delphi/physics/NewtonDensityFm.pas
  19. 5 5
      Demos/Delphi/specialsFX/ShadowFBOFm.pas
  20. 1 1
      Packages/GLScene_Cg_RT.dproj
  21. 1 1
      Packages/GLScene_Physics_RT.dproj
  22. 1 1
      Packages/GLScene_RT.dproj
  23. 1 1
      Packages/GLScene_Sounds_RT.dproj
  24. 3 3
      Source/DWS.OpenGL.pas
  25. 7 7
      Source/DWS.Scene.pas
  26. 25 25
      Source/DWS.VectorGeometry.pas
  27. 4 4
      Source/Formats.GL2.pas
  28. 5 5
      Source/Formats.X.pas
  29. 1 1
      Source/GLS.AnimatedSprite.pas
  30. 2 2
      Source/GLS.CameraController.pas
  31. 1 1
      Source/GLS.Canvas.pas
  32. 4 4
      Source/GLS.Collision.pas
  33. 5 5
      Source/GLS.Context.pas
  34. 1 1
      Source/GLS.EllipseCollision.pas
  35. 1 1
      Source/GLS.ExplosionFx.pas
  36. 9 9
      Source/GLS.File3DS.pas
  37. 6 6
      Source/GLS.File3DSSceneObjects.pas
  38. 2 2
      Source/GLS.FileASE.pas
  39. 2 2
      Source/GLS.FileB3D.pas
  40. 2 2
      Source/GLS.FileMD5.pas
  41. 1 1
      Source/GLS.FileMS3D.pas
  42. 1 1
      Source/GLS.FileOBJ.pas
  43. 3 2
      Source/GLS.FileQ3MD3.pas
  44. 2 2
      Source/GLS.FileVRML.pas
  45. 1 1
      Source/GLS.FileX.pas
  46. 2 2
      Source/GLS.FireFX.pas
  47. 1 1
      Source/GLS.GeomObjects.pas
  48. 10 10
      Source/GLS.GeometryBB.pas
  49. 7 7
      Source/GLS.Gizmo.pas
  50. 7 7
      Source/GLS.GizmoEx.pas
  51. 5 5
      Source/GLS.Imposter.pas
  52. 1 1
      Source/GLS.LensFlare.pas
  53. 1 1
      Source/GLS.LinePFX.pas
  54. 5 5
      Source/GLS.Material.pas
  55. 5 5
      Source/GLS.MaterialEx.pas
  56. 2 2
      Source/GLS.Mirror.pas
  57. 1 1
      Source/GLS.Objects.pas
  58. 5 5
      Source/GLS.Octree.pas
  59. 3 3
      Source/GLS.ParticleFX.pas
  60. 35 35
      Source/GLS.PipelineTransformation.pas
  61. 2 2
      Source/GLS.ProjectedTextures.pas
  62. 5 5
      Source/GLS.ProxyObjects.pas
  63. 155 123
      Source/GLS.Ragdoll.pas
  64. 1 0
      Source/GLS.RenderContextInfo.pas
  65. 50 50
      Source/GLS.Scene.pas
  66. 2 2
      Source/GLS.ShadowPlane.pas
  67. 2 2
      Source/GLS.ShadowVolume.pas
  68. 1 1
      Source/GLS.SpaceText.pas
  69. 1 1
      Source/GLS.Spline.pas
  70. 2 2
      Source/GLS.State.pas
  71. 7 7
      Source/GLS.Texture.pas
  72. 1 1
      Source/GLS.ThorFX.pas
  73. 8 8
      Source/GLS.Tree.pas
  74. 32 32
      Source/GLS.VectorFileObjects.pas
  75. 126 128
      Source/GLS.VectorGeometry.pas
  76. 4 4
      Source/GLS.VectorLists.pas
  77. 1 1
      Source/GLS.VectorTypes.pas
  78. 2 2
      Source/GLS.VectorTypesExt.pas
  79. 2 2
      Source/GLSL.ProjectedTextures.pas
  80. 4 4
      Source/GLSL.TextureShaders.pas
  81. 16 16
      Source/Physics.NGDManager.pas
  82. 5 5
      Source/Physics.NGDRagdoll.pas
  83. 30 30
      Source/Physics.ODEManager.pas
  84. 95 86
      Source/Physics.ODERagdoll.pas
  85. 3 2
      Source/Physics.ODESkeletonColliders.pas
  86. 12 12
      Source/Physics.ODEUtils.pas
  87. 3 3
      Source/Physics.SPIInertias.pas
  88. 2 2
      Source/Physics.SPIJoints.pas
  89. 1 0
      Source/Sounds.OpenAL.pas

+ 5 - 5
AdvDemos/CPP/Quake3Demo/Unit1.cpp

@@ -51,10 +51,10 @@ void __fastcall TForm1::FormCreate(TObject *Sender) {
 }
 
 // ---------------------------------------------------------------------------
-Glvectorgeometry::TMatrix __fastcall TForm1::InterpolateMatrix
-	(Glvectorgeometry::TMatrix m1, Glvectorgeometry::TMatrix m2, float delta) {
+Glvectorgeometry::TGLMatrix __fastcall TForm1::InterpolateMatrix
+	(Glvectorgeometry::TGLMatrix m1, Glvectorgeometry::TGLMatrix m2, float delta) {
 	int i, j;
-	Glvectorgeometry::TMatrix mat;
+	Glvectorgeometry::TGLMatrix mat;
 	// This is used for interpolating between 2 matrices. The result
 	// is used to reposition the model parts each frame.
 	//
@@ -140,8 +140,8 @@ void __fastcall TForm1::ComboBox2Change(TObject *Sender) {
 // ---------------------------------------------------------------------------
 void __fastcall TForm1::GLCadencer1Progress(TObject *Sender,
 	const double deltaTime, const double newTime) {
-	Glvectorgeometry::TMatrix m1;
-	Glvectorgeometry::TMatrix m2;
+	Glvectorgeometry::TGLMatrix m1;
+	Glvectorgeometry::TGLMatrix m2;
 
 	// Set the transform for the torso
 	m1 = LegsTags->GetTransform("tag_torso", Legs->CurrentFrame);

+ 2 - 2
AdvDemos/CPP/Quake3Demo/Unit1.h

@@ -84,8 +84,8 @@ private:	// User declarations
 	TMD3TagList *TorsoTags;
 	TMD3TagList *WeaponTags;
 	void __fastcall BuildModel();
-	Glvectorgeometry::TMatrix __fastcall InterpolateMatrix(
-	       Glvectorgeometry::TMatrix m1, Glvectorgeometry::TMatrix m2, Single Delta);
+	Glvectorgeometry::TGLMatrix __fastcall InterpolateMatrix(
+	       Glvectorgeometry::TGLMatrix m1, Glvectorgeometry::TGLMatrix m2, Single Delta);
 public:		// User declarations
 	__fastcall TForm1(TComponent* Owner);
 };

+ 6 - 6
AdvDemos/Delphi/Forest/Unit1.pas

@@ -115,7 +115,7 @@ type
     lmp: TPoint;
     camPitch, camTurn, camTime, curPitch, curTurn: Single;
 
-    function GetTextureReflectionMatrix: TMatrix;
+    function GetTextureReflectionMatrix: TGLMatrix;
   public
      
     TestTree: TGLTree;
@@ -418,7 +418,7 @@ procedure TForm1.DOTreesRender(Sender: TObject;
 var
   i: Integer;
   particle: TGLParticle;
-  TreeModelMatrix: TMatrix;
+  TreeModelMatrix: TGLMatrix;
 begin
   rci.GLStates.Disable(stBlend);
   for i := 0 to nearTrees.Count - 1 do
@@ -504,7 +504,7 @@ procedure TForm1.DOInitializeReflectionRender(Sender: TObject;
   var rci: TGLRenderContextInfo);
 var
   w, h: Integer;
-  refMat: TMatrix;
+  refMat: TGLMatrix;
   cameraPosBackup, cameraDirectionBackup: TGLVector;
   frustumBackup: TFrustum;
   clipPlane: TDoubleHmgPlane;
@@ -607,7 +607,7 @@ const
   cWaveSpeed = 0.02;
   cSinScale = 0.02;
 var
-  tex0Matrix, tex1Matrix: TMatrix;
+  tex0Matrix, tex1Matrix: TGLMatrix;
   tWave: Single;
   pos: TAffineVector;
   tex: TTexPoint;
@@ -743,9 +743,9 @@ end;
 // SetupReflectionMatrix
 //
 
-function TForm1.GetTextureReflectionMatrix: TMatrix;
+function TForm1.GetTextureReflectionMatrix: TGLMatrix;
 const
-  cBaseMat: TMatrix =
+  cBaseMat: TGLMatrix =
   (V:((X:0.5; Y:0;   Z:0; W:0),
       (X:0;   Y:0.5; Z:0; W:0),
       (X:0;   Y:0; Z:1; W:0),

+ 3 - 3
AdvDemos/Delphi/Quake3Demo/Unit1.pas

@@ -84,7 +84,7 @@ type
   public
     LegsTags, TorsoTags, WeaponTags: TMD3TagList;
     procedure BuildModel;
-    function InterpolateMatrix(m1, m2: TMatrix; delta: single): TMatrix;
+    function InterpolateMatrix(m1, m2: TGLMatrix; delta: single): TGLMatrix;
   end;
 
 var
@@ -278,7 +278,7 @@ begin
   LoadQ3Anims(Torso.Animations, '.\model\animation.cfg', 'TORSO');
 end;
 
-function TForm1.InterpolateMatrix(m1, m2: TMatrix; delta: single): TMatrix;
+function TForm1.InterpolateMatrix(m1, m2: TGLMatrix; delta: single): TGLMatrix;
 var
   i, j: Integer;
 begin
@@ -293,7 +293,7 @@ end;
 procedure TForm1.GLCadencer1Progress(Sender: TObject;
   const deltaTime, newTime: Double);
 var
-  m1, m2: TMatrix;
+  m1, m2: TGLMatrix;
 begin
   // Set the transform for the torso
   m1 := LegsTags.GetTransform('tag_torso', Legs.CurrentFrame);

+ 2 - 2
Demos/CPP/collisions/BoxSphere/Unit1.cpp

@@ -44,10 +44,10 @@ void __fastcall TForm1::CheckBox04Click(TObject *Sender)
 //---------------------------------------------------------------------------
 
 // Generates random rotation for matrix. It remains a scale.
-Gls::Vectorgeometry::TMatrix RandomRotation(Gls::Vectorgeometry::TMatrix const &aMatrix)
+Gls::Vectorgeometry::TGLMatrix RandomRotation(Gls::Vectorgeometry::TGLMatrix const &aMatrix)
 {
   TAffineVector aScale;
-  Gls::Vectorgeometry::TMatrix mat;
+  Gls::Vectorgeometry::TGLMatrix mat;
   int I;
 
   // Save scale.

+ 1 - 1
Demos/CPP/collisions/BoxSphere/Unit1.h

@@ -83,7 +83,7 @@ __published:	// IDE-managed Components
 private:	// User declarations
 	int mdx, mdy;
 	TAffineVector intersPoint, ResNormal, BoxScale, SpherePos;
-	Gls::Vectorgeometry::TMatrix BoxMatrix;
+	Gls::Vectorgeometry::TGLMatrix BoxMatrix;
 	float SphereRadius;
 public:		// User declarations
 	__fastcall TForm1(TComponent* Owner);

+ 1 - 1
Demos/CPP/glslshaders/Ocean/Unit1.cpp

@@ -93,7 +93,7 @@ void __fastcall TForm1::DOInitializeRender(TObject *Sender, TGLRenderContextInfo
 void __fastcall TForm1::GLUserShader1DoApply(TObject *Sender, TGLRenderContextInfo &rci)
 
 {
-  TVector camPos;
+  TGLVector camPos;
 
   programObject = new TGLProgramHandle();
   programObject->UseProgramObject();

+ 1 - 1
Demos/CPP/graph/projection/Unit1.cpp

@@ -39,7 +39,7 @@ void __fastcall TForm1::DirectOpenGLRender(TObject *Sender, TGLRenderContextInfo
 
 {
    int i;
-   Gls::Vectorgeometry::TMatrix mat;
+   Gls::Vectorgeometry::TGLMatrix mat;
    TGLVector p, pProj;
    TGLVector planePoint, planeNormal;
    THmgPlane plane;

+ 1 - 1
Demos/CPP/interface/camera/Unit1.cpp

@@ -57,7 +57,7 @@ void __fastcall TForm1::RadioGroup2Click(TObject *Sender)
 void __fastcall TForm1::GLCamera1CustomPerspective(const TRectangle &viewport, int width,
           int height, int DPI, float &viewPortRadius)
 {
-  Gls::Vectorgeometry::TMatrix Mat;
+  Gls::Vectorgeometry::TGLMatrix Mat;
 
   Mat =  CreatePerspectiveMatrix(GLCamera1->GetFieldOfView(Width)/4,
 	Width / Height, GLCamera1->NearPlaneBias, GLCamera1->DepthOfView);

+ 1 - 1
Demos/CPP/meshes/actorms3d/Unit1.cpp

@@ -50,7 +50,7 @@ int mdx, mdy;
 Gls::Vectorgeometry::TMatrix4f FBiasMatrix;
 Gls::Vectorgeometry::TMatrix4f FLightModelViewMatrix;
 Gls::Vectorgeometry::TMatrix4f FLightProjMatrix;
-Gls::VectorGeometry::TMatrix FInvCameraMatrix;
+Gls::VectorGeometry::TGLMatrix FInvCameraMatrix;
 Gls::Vectorgeometry::TMatrix4f FEyeToLightMatrix;
 
 Gls::Vectorgeometry::TMatrix4f FLightModelViewMatrix2;

+ 2 - 2
Demos/CPP/meshes/tiles/Unit1.h

@@ -47,8 +47,8 @@ __published:	// IDE-managed Components
 private:	// User declarations
 	int mx, my;
 	int tileX, tileY;
-	TVector* mip;
-	TVector* translateOffset;
+	TGLVector* mip;
+	TGLVector* translateOffset;
 	bool translating;
 public:		// User declarations
 	__fastcall TForm1(TComponent* Owner);

+ 3 - 3
Demos/CPP/physics/NewtonDensity/Unit1.cpp

@@ -29,14 +29,14 @@ TForm1 *Form1;
 int __cdecl BuoyancyPlaneCallback(const int collisionID, void *context,
   const PNGDFloat globalSpaceMatrix, PNGDFloat globalSpacePlane)
 {
-  Gls::Vectorgeometry::TMatrix *BodyMatrix;
+  Gls::Vectorgeometry::TGLMatrix *BodyMatrix;
   TGLVector PlaneEquation;
-  Gls::Vectorgeometry::PVector pv;
+  Gls::Vectorgeometry::PGLVector pv;
   TForm1 *MyForm;
 
   // Get the matrix of the actual body
 
-  BodyMatrix = (PMatrix) globalSpaceMatrix;
+  BodyMatrix = (PGLMatrix) globalSpaceMatrix;
   MyForm = (TForm1 *) context;
 
   // this is the 4-value vector that represents the plane equation for

+ 5 - 5
Demos/CPP/specialsFX/ShadowmappingFBO/Unit1.h

@@ -61,11 +61,11 @@ __published:	// IDE-managed Components
 	void __fastcall PrepareShadowMappingRender(TObject *Sender, TGLRenderContextInfo &rci);
 
 private:	// User declarations
-	TMatrix FBiasMatrix;
-	TMatrix FLightModelViewMatrix;
-	TMatrix FLightProjMatrix;
-	TMatrix FInvCameraMatrix;
-	TMatrix FEyeToLightMatrix;
+	TGLMatrix FBiasMatrix;
+	TGLMatrix FLightModelViewMatrix;
+	TGLMatrix FLightProjMatrix;
+	TGLMatrix FInvCameraMatrix;
+	TGLMatrix FEyeToLightMatrix;
 public:		// User declarations
 	__fastcall TForm1(TComponent* Owner);
 };

+ 3 - 3
Demos/Delphi/collisions/BoxSphereFm.pas

@@ -94,12 +94,12 @@ type
   private
     mdx, mdy: Integer;
     intersPoint, ResNormal, BoxScale, SpherePos: TAffineVector;
-    BoxMatrix: TMatrix;
+    BoxMatrix: TGLMatrix;
     SphereRadius: Single;
   end;
 
 // Generates random rotation for matrix. It remains a scale.
-function RandomRotation(const aMatrix: TMatrix): TMatrix;
+function RandomRotation(const aMatrix: TGLMatrix): TGLMatrix;
 
 var
   FormBoxSphere: TFormBoxSphere;
@@ -195,7 +195,7 @@ begin
 end;
 
 // Generates random rotation for matrix. It remains a scale.
-function RandomRotation(const aMatrix: TMatrix): TMatrix;
+function RandomRotation(const aMatrix: TGLMatrix): TGLMatrix;
 var
   aScale: TAffineVector;
   I:      Integer;

+ 1 - 1
Demos/Delphi/graph/ProjectionFm.pas

@@ -73,7 +73,7 @@ end;
 procedure TFormProjection.DirectOpenGLRender(Sender: TObject; var rci: TGLRenderContextInfo);
 var
   i: Integer;
-  mat: TMatrix;
+  mat: TGLMatrix;
   p, pProj: TGLVector;
   planePoint, planeNormal: TGLVector;
   plane: THmgPlane;

+ 1 - 1
Demos/Delphi/interface/CameraFm.pas

@@ -152,7 +152,7 @@ end;
 procedure TFormCamera.GLCamera1CustomPerspective(const viewport: TRectangle;
   width, height, DPI: Integer; var viewPortRadius: Single);
 var
-  Mat: TMatrix;
+  Mat: TGLMatrix;
 begin
   Mat :=  CreatePerspectiveMatrix(GLCamera1.GetFieldOfView(Width)/4,
     Width / Height, GLCamera1.NearPlaneBias, GLCamera1.DepthOfView);

+ 10 - 10
Demos/Delphi/meshes/Actorms3dFm.pas

@@ -107,16 +107,16 @@ var
   mdx: Integer;
   mdy: integer;
 
-  FBiasMatrix: TMatrix;
-  FLightModelViewMatrix: TMatrix;
-  FLightProjMatrix: TMatrix;
-  FInvCameraMatrix: TMatrix;
-  FEyeToLightMatrix: TMatrix;
-
-  FLightModelViewMatrix2: TMatrix;
-  FLightProjMatrix2: TMatrix;
-  FInvCameraMatrix2: TMatrix;
-  FEyeToLightMatrix2: TMatrix;
+  FBiasMatrix: TGLMatrix;
+  FLightModelViewMatrix: TGLMatrix;
+  FLightProjMatrix: TGLMatrix;
+  FInvCameraMatrix: TGLMatrix;
+  FEyeToLightMatrix: TGLMatrix;
+
+  FLightModelViewMatrix2: TGLMatrix;
+  FLightProjMatrix2: TGLMatrix;
+  FInvCameraMatrix2: TGLMatrix;
+  FEyeToLightMatrix2: TGLMatrix;
 
 implementation
 

+ 1 - 1
Demos/Delphi/physics/NewtonDensityFm.pas

@@ -82,7 +82,7 @@ function BuoyancyPlaneCallback(const collisionID: Integer; context: Pointer;
   const globalSpaceMatrix: PNGDFloat; globalSpacePlane: PNGDFloat): Integer;
   cdecl;
 var
-  BodyMatrix: TMatrix;
+  BodyMatrix: TGLMatrix;
   PlaneEquation: TGLVector;
   pv: PGLVector;
   MyForm: TFormNewtonDensity;

+ 5 - 5
Demos/Delphi/specialsFX/ShadowFBOFm.pas

@@ -82,11 +82,11 @@ type
   private
      
 
-    FBiasMatrix: TMatrix;
-    FLightModelViewMatrix: TMatrix;
-    FLightProjMatrix: TMatrix;
-    FInvCameraMatrix: TMatrix;
-    FEyeToLightMatrix: TMatrix;
+    FBiasMatrix: TGLMatrix;
+    FLightModelViewMatrix: TGLMatrix;
+    FLightProjMatrix: TGLMatrix;
+    FInvCameraMatrix: TGLMatrix;
+    FEyeToLightMatrix: TGLMatrix;
   public
      
   end;

+ 1 - 1
Packages/GLScene_Cg_RT.dproj

@@ -8,7 +8,7 @@
         <AppType>Package</AppType>
         <FrameworkType>VCL</FrameworkType>
         <ProjectVersion>19.0</ProjectVersion>
-        <Platform Condition="'$(Platform)'==''">Win32</Platform>
+        <Platform Condition="'$(Platform)'==''">Win64</Platform>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
         <Base>true</Base>

+ 1 - 1
Packages/GLScene_Physics_RT.dproj

@@ -8,7 +8,7 @@
         <AppType>Package</AppType>
         <FrameworkType>VCL</FrameworkType>
         <ProjectVersion>19.0</ProjectVersion>
-        <Platform Condition="'$(Platform)'==''">Win32</Platform>
+        <Platform Condition="'$(Platform)'==''">Win64</Platform>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
         <Base>true</Base>

+ 1 - 1
Packages/GLScene_RT.dproj

@@ -8,7 +8,7 @@
         <AppType>Package</AppType>
         <FrameworkType>VCL</FrameworkType>
         <ProjectVersion>19.0</ProjectVersion>
-        <Platform Condition="'$(Platform)'==''">Win64</Platform>
+        <Platform Condition="'$(Platform)'==''">Win32</Platform>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
         <Base>true</Base>

+ 1 - 1
Packages/GLScene_Sounds_RT.dproj

@@ -8,7 +8,7 @@
         <AppType>Package</AppType>
         <FrameworkType>VCL</FrameworkType>
         <ProjectVersion>19.0</ProjectVersion>
-        <Platform Condition="'$(Platform)'==''">Win32</Platform>
+        <Platform Condition="'$(Platform)'==''">Win64</Platform>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
         <Base>true</Base>

+ 3 - 3
Source/DWS.OpenGL.pas

@@ -285,7 +285,7 @@ begin
   RegisterComponents('GLScene DWS', [TdwsOpenGLUnit]);
 end;
 
-function GetMatrixFromInfo(Info : IInfo) : TMatrix;
+function GetMatrixFromInfo(Info : IInfo) : TGLMatrix;
 var
   i : Integer;
 begin
@@ -1048,7 +1048,7 @@ begin
   TGLPushMatrix.Create(SymbolTable, 'glPushMatrix', [], '');
   TGLPopMatrix.Create(SymbolTable, 'glPopMatrix', [], '');
   TGLLoadIdentity.Create(SymbolTable, 'glLoadIdentity', [], '');
-  TGLLoadMatrixf.Create(SymbolTable, 'glLoadMatrixf', ['m', 'TMatrix'], '');
+  TGLLoadMatrixf.Create(SymbolTable, 'glLoadMatrixf', ['m', 'TGLMatrix'], '');
   TGLTranslatef.Create(SymbolTable, 'glTranslatef', ['x', 'Float', 'y', 'Float', 'z', 'Float'], '');
   TGLRotatef.Create(SymbolTable, 'glRotatef', ['angle', 'Float', 'x', 'Float', 'y', 'Float', 'z', 'Float'], '');
   TGLScalef.Create(SymbolTable, 'glScalef', ['x', 'Float', 'y', 'Float', 'z', 'Float'], '');
@@ -2111,7 +2111,7 @@ end;
 
 procedure TGLLoadMatrixf.Execute;
 var
-  m: TMatrix;
+  m: TGLMatrix;
 begin
   m := GetMatrixFromInfo(Info.Vars['m']);
   glLoadMatrixf(@m[0]);

+ 7 - 7
Source/DWS.Scene.pas

@@ -336,7 +336,7 @@ begin
     Info.Element([i]).Value := vec[i];
 end;
 
-function GetMatrixFromInfo(Info: IInfo): TMatrix;
+function GetMatrixFromInfo(Info: IInfo): TGLMatrix;
 var
   i: Integer;
 begin
@@ -346,7 +346,7 @@ begin
       .Value, Info.Element([i]).Element([3]).Value);
 end;
 
-procedure SetInfoFromMatrix(Info: IInfo; mat: TMatrix);
+procedure SetInfoFromMatrix(Info: IInfo; mat: TGLMatrix);
 var
   i, j: Integer;
 begin
@@ -930,16 +930,16 @@ begin
       [], 'Boolean', ClassSym, SymbolTable);
   if not Assigned(ClassSym.Members.FindLocal('SetMatrix')) then
     TGLBaseSceneObjectSetMatrixMethod.Create(mkProcedure, [], 0, 'SetMatrix',
-      ['Value', 'TMatrix'], '', ClassSym, SymbolTable);
+      ['Value', 'TGLMatrix'], '', ClassSym, SymbolTable);
   if not Assigned(ClassSym.Members.FindLocal('GetMatrix')) then
     TGLBaseSceneObjectGetMatrixMethod.Create(mkFunction, [], 0, 'GetMatrix', [],
-      'TMatrix', ClassSym, SymbolTable);
+      'TGLMatrix', ClassSym, SymbolTable);
   if not Assigned(ClassSym.Members.FindLocal('AbsoluteMatrix')) then
     TGLBaseSceneObjectAbsoluteMatrixMethod.Create(mkFunction, [], 0,
-      'AbsoluteMatrix', [], 'TMatrix', ClassSym, SymbolTable);
+      'AbsoluteMatrix', [], 'TGLMatrix', ClassSym, SymbolTable);
   if not Assigned(ClassSym.Members.FindLocal('InvAbsoluteMatrix')) then
     TGLBaseSceneObjectInvAbsoluteMatrixMethod.Create(mkFunction, [], 0,
-      'InvAbsoluteMatrix', [], 'TMatrix', ClassSym, SymbolTable);
+      'InvAbsoluteMatrix', [], 'TGLMatrix', ClassSym, SymbolTable);
   if not Assigned(ClassSym.Members.FindLocal('SetAbsolutePosition')) then
     TGLBaseSceneObjectSetAbsolutePositionMethod.Create(mkProcedure, [], 0,
       'SetAbsolutePosition', ['Value', 'TGLVector'], '', ClassSym, SymbolTable);
@@ -1021,7 +1021,7 @@ begin
   // Properties
   AddPropertyToClass('Visible', 'Boolean', 'GetVisible', 'SetVisible', '',
     False, ClassSym, SymbolTable);
-  AddPropertyToClass('Matrix', 'TMatrix', 'GetMatrix', 'SetMatrix', '', False,
+  AddPropertyToClass('Matrix', 'TGLMatrix', 'GetMatrix', 'SetMatrix', '', False,
     ClassSym, SymbolTable);
   AddPropertyToClass('AbsolutePosition', 'TGLVector', 'GetAbsolutePosition',
     'SetAbsolutePosition', '', False, ClassSym, SymbolTable);

+ 25 - 25
Source/DWS.VectorGeometry.pas

@@ -159,7 +159,7 @@ begin
     Info.Element([i]).Value := vec[i];
 end;
 
-function GetMatrixFromInfo(Info: IInfo): TMatrix;
+function GetMatrixFromInfo(Info: IInfo): TGLMatrix;
 var
   i: Integer;
 begin
@@ -169,7 +169,7 @@ begin
       .Value, Info.Element([i]).Element([3]).Value);
 end;
 
-procedure SetInfoFromMatrix(Info: IInfo; mat: TMatrix);
+procedure SetInfoFromMatrix(Info: IInfo; mat: TGLMatrix);
 var
   i, j: Integer;
 begin
@@ -187,7 +187,7 @@ begin
   // Array types
   SymbolTable.AddSymbol(TStaticArraySymbol.Create('TGLVector',
     FloatSymbol, 0, 3));
-  SymbolTable.AddSymbol(TStaticArraySymbol.Create('TMatrix',
+  SymbolTable.AddSymbol(TStaticArraySymbol.Create('TGLMatrix',
     SymbolTable.FindSymbol('TGLVector'), 0, 3));
 
   // Vector functions
@@ -217,30 +217,30 @@ begin
   TVectorNormalizeFunction.Create(SymbolTable, 'VectorNormalize',
     ['v', 'TGLVector'], 'TGLVector');
   TVectorTransformFunction.Create(SymbolTable, 'VectorTransform',
-    ['v', 'TGLVector', 'm', 'TMatrix'], 'TGLVector');
+    ['v', 'TGLVector', 'm', 'TGLMatrix'], 'TGLVector');
 
   // Matrix function
   TInvertMatrixFunction.Create(SymbolTable, 'InvertMatrix',
-    ['@mat', 'TMatrix'], '');
+    ['@mat', 'TGLMatrix'], '');
   TTransposeMatrixFunction.Create(SymbolTable, 'TransposeMatrix',
-    ['@mat', 'TMatrix'], '');
+    ['@mat', 'TGLMatrix'], '');
   TMatrixMultiplyFunction.Create(SymbolTable, 'MatrixMultiply',
-    ['m1', 'TMatrix', 'm2', 'TMatrix'], 'TMatrix');
+    ['m1', 'TGLMatrix', 'm2', 'TGLMatrix'], 'TGLMatrix');
   TCreateScaleMatrixFunction.Create(SymbolTable, 'CreateScaleMatrix',
-    ['v', 'TGLVector'], 'TMatrix');
+    ['v', 'TGLVector'], 'TGLMatrix');
   TCreateTranslationMatrixFunction.Create(SymbolTable,
-    'CreateTranslationMatrix', ['v', 'TGLVector'], 'TMatrix');
+    'CreateTranslationMatrix', ['v', 'TGLVector'], 'TGLMatrix');
   TCreateScaleAndTranslationMatrixFunction.Create(SymbolTable,
     'CreateScaleAndTranslationMatrix', ['scale', 'TGLVector', 'offset',
-    'TGLVector'], 'TMatrix');
+    'TGLVector'], 'TGLMatrix');
   TCreateRotationMatrixXFunction.Create(SymbolTable, 'CreateRotationMatrixX',
-    ['angle', 'Float'], 'TMatrix');
+    ['angle', 'Float'], 'TGLMatrix');
   TCreateRotationMatrixYFunction.Create(SymbolTable, 'CreateRotationMatrixY',
-    ['angle', 'Float'], 'TMatrix');
+    ['angle', 'Float'], 'TGLMatrix');
   TCreateRotationMatrixZFunction.Create(SymbolTable, 'CreateRotationMatrixZ',
-    ['angle', 'Float'], 'TMatrix');
+    ['angle', 'Float'], 'TGLMatrix');
   TCreateRotationMatrixFunction.Create(SymbolTable, 'CreateRotationMatrix',
-    ['anAxis', 'TGLVector', 'angle', 'Float'], 'TMatrix');
+    ['anAxis', 'TGLVector', 'angle', 'Float'], 'TGLMatrix');
 end;
 
 constructor TdwsVectorGeometryUnit.Create(AOwner: TComponent);
@@ -368,7 +368,7 @@ end;
 procedure TVectorTransformFunction.Execute;
 var
   v, vr: TGLVector;
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
   v := GetVectorFromInfo(Info.Vars['v']);
   mat := GetMatrixFromInfo(Info.Vars['mat']);
@@ -378,7 +378,7 @@ end;
 
 procedure TInvertMatrixFunction.Execute;
 var
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
   mat := GetMatrixFromInfo(Info.Vars['mat']);
   InvertMatrix(mat);
@@ -387,7 +387,7 @@ end;
 
 procedure TTransposeMatrixFunction.Execute;
 var
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
   mat := GetMatrixFromInfo(Info.Vars['mat']);
   TransposeMatrix(mat);
@@ -396,7 +396,7 @@ end;
 
 procedure TMatrixMultiplyFunction.Execute;
 var
-  m1, m2, mr: TMatrix;
+  m1, m2, mr: TGLMatrix;
 begin
   m1 := GetMatrixFromInfo(Info.Vars['m1']);
   m2 := GetMatrixFromInfo(Info.Vars['m2']);
@@ -407,7 +407,7 @@ end;
 procedure TCreateScaleMatrixFunction.Execute;
 var
   v: TGLVector;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
   v := GetVectorFromInfo(Info.Vars['v']);
   mr := CreateScaleMatrix(v);
@@ -417,7 +417,7 @@ end;
 procedure TCreateTranslationMatrixFunction.Execute;
 var
   v: TGLVector;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
   v := GetVectorFromInfo(Info.Vars['v']);
   mr := CreateTranslationMatrix(v);
@@ -427,7 +427,7 @@ end;
 procedure TCreateScaleAndTranslationMatrixFunction.Execute;
 var
   scale, offset: TGLVector;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
   scale := GetVectorFromInfo(Info.Vars['scale']);
   offset := GetVectorFromInfo(Info.Vars['offset']);
@@ -438,7 +438,7 @@ end;
 procedure TCreateRotationMatrixXFunction.Execute;
 var
   angle: Single;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
   angle := Info['angle'];
   mr := CreateRotationMatrixX(angle);
@@ -448,7 +448,7 @@ end;
 procedure TCreateRotationMatrixYFunction.Execute;
 var
   angle: Single;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
   angle := Info['angle'];
   mr := CreateRotationMatrixY(angle);
@@ -458,7 +458,7 @@ end;
 procedure TCreateRotationMatrixZFunction.Execute;
 var
   angle: Single;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
   angle := Info['angle'];
   mr := CreateRotationMatrixZ(angle);
@@ -469,7 +469,7 @@ procedure TCreateRotationMatrixFunction.Execute;
 var
   angle: Single;
   anAxis: TGLVector;
-  mr: TMatrix;
+  mr: TGLMatrix;
 begin
   anAxis := GetVectorFromInfo(Info.Vars['anAxis']);
   angle := Info['angle'];

+ 4 - 4
Source/Formats.GL2.pas

@@ -129,7 +129,7 @@ type
     BoneIndices: array of integer;
     CompBonePool: array of TGLACompQuatBone;
     function GetCompressedMatrix(Frame, Bone: integer): TGLACompQuatBone;
-    function GetUnCompressedMatrix(Frame, Bone: integer): TMatrix;
+    function GetUnCompressedMatrix(Frame, Bone: integer): TGLMatrix;
     procedure LoadFromStream(aStream: TStream);
   end;
 
@@ -139,7 +139,7 @@ function G2_GetVertBoneIndex(const vert: TGLMVertex;
 function G2_GetVertBoneWeight(const vert: TGLMVertex; iWeightNum: Cardinal;
   var fTotalWeight: single; const iNumWeights: Cardinal): single;
 
-procedure MC_UnCompressQuat(var mat: TMatrix; const comp: TGLACompQuatBone);
+procedure MC_UnCompressQuat(var mat: TGLMatrix; const comp: TGLACompQuatBone);
 
 // ------------------------------------------------------------------
 implementation
@@ -198,7 +198,7 @@ end;
 // Adapted from matcomp.c
 // void MC_UnCompressQuat(float mat[3][4],const unsigned char * comp)
 
-procedure MC_UnCompressQuat(var mat: TMatrix; const comp: TGLACompQuatBone);
+procedure MC_UnCompressQuat(var mat: TGLMatrix; const comp: TGLACompQuatBone);
 begin
   mat := QuaternionToMatrix(QuaternionMake([comp[1] - 32726, comp[2] - 32726,
     comp[3] - 32726], comp[0] - 32726));
@@ -305,7 +305,7 @@ end;
 
 // GetUnCompressedMatrix
 //
-function TFileGLA.GetUnCompressedMatrix(Frame, Bone: integer): TMatrix;
+function TFileGLA.GetUnCompressedMatrix(Frame, Bone: integer): TGLMatrix;
 begin
   MC_UnCompressQuat(result, CompBonePool[BoneIndices[Frame * AnimHeader.numBones
     + Bone]]);

+ 5 - 5
Source/Formats.X.pas

@@ -71,11 +71,11 @@ type
 
   TDXFrame = class(TDXNode)
   private
-    FMatrix: TMatrix;
+    FMatrix: TGLMatrix;
   public
     constructor Create; override;
-    function GlobalMatrix: TMatrix;
-    property Matrix: TMatrix read FMatrix write FMatrix;
+    function GlobalMatrix: TGLMatrix;
+    property Matrix: TGLMatrix read FMatrix write FMatrix;
 
   end;
 
@@ -259,7 +259,7 @@ var
     Result := StrToFloatDef(str, 0);
   end;
 
-  function ReadMatrix: TMatrix;
+  function ReadMatrix: TGLMatrix;
   var
     i, j: Integer;
   begin
@@ -670,7 +670,7 @@ begin
   FMatrix := IdentityHMGMatrix;
 end;
 
-function TDXFrame.GlobalMatrix: TMatrix;
+function TDXFrame.GlobalMatrix: TGLMatrix;
 begin
   if Owner is TDXFrame then
     Result := MatrixMultiply(TDXFrame(Owner).GlobalMatrix, FMatrix)

+ 1 - 1
Source/GLS.AnimatedSprite.pas

@@ -673,7 +673,7 @@ procedure TGLAnimatedSprite.BuildList(var rci: TGLRenderContextInfo);
 var
   vx, vy: TAffineVector;
   w, h, temp: Single;
-  mat: TMatrix;
+  mat: TGLMatrix;
   u0, v0, u1, v1: Single;
   x0, y0, x1, y1, TexWidth, TexHeight: Integer;
   Anim: TGLSpriteAnimation;

+ 2 - 2
Source/GLS.CameraController.pas

@@ -126,7 +126,7 @@ type
   private
     FCutoffAngle: Single;
     FNeedToRecalculateZoom: boolean;
-    FShouldBeMatrix: TMatrix;
+    FShouldBeMatrix: TGLMatrix;
     FSmoothNavigator: TGLNavigatorSmoothChangeVector;
   public
     constructor Create(const AJoblist: TGLCameraJobList); override;
@@ -890,7 +890,7 @@ procedure TGLSmoothOrbitToPos.Step;
 var
   lCurrentDistanceToTarget: Single;
   lTargetPosition: TGLVector;
-  lCurrentMatrix: TMatrix;
+  lCurrentMatrix: TGLMatrix;
   lAngle: Single;
   lAbsTargetPosition: TGLVector;
 

+ 1 - 1
Source/GLS.Canvas.pas

@@ -255,7 +255,7 @@ end;
 
 procedure TGLCanvas.InvertYAxis;
 var
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
   mat := IdentityHmgMatrix;
   mat.Y.Y := -1;

+ 4 - 4
Source/GLS.Collision.pas

@@ -441,7 +441,7 @@ const
     (4, 5), (5, 6), (6, 7), (7, 4), (0, 4), (1, 5), (2, 6), (3, 7));
 var
   pt1: array [0 .. 7] of TGLVector;
-  M: TMatrix;
+  M: TGLMatrix;
   i: Integer;
   aad: TGLVector;
 begin
@@ -507,7 +507,7 @@ end;
 function FastCheckCubeVsFace(obj1, obj2: TGLBaseSceneObject): Boolean;
 // var
 // triList : TAffineVectorList;
-// m1to2, m2to1 : TMatrix;
+// m1to2, m2to1 : TGLMatrix;
 // i:integer;
 begin
   if (obj2 is TGLFreeForm) then
@@ -544,7 +544,7 @@ var
   i: Integer;
   triList: TAffineVectorList;
   tri: PTriangle;
-  m1to2, m2to1: TMatrix;
+  m1to2, m2to1: TGLMatrix;
   AABB2: TAABB;
 begin
   Result := false;
@@ -600,7 +600,7 @@ end;
 function IntersectCubes(obj1, obj2: TGLBaseSceneObject): Boolean;
 var
   aabb1, AABB2: TAABB;
-  m1to2, m2to1: TMatrix;
+  m1to2, m2to1: TGLMatrix;
 begin
   // Calc AABBs
   aabb1 := obj1.AxisAlignedBoundingBoxUnscaled;

+ 5 - 5
Source/GLS.Context.pas

@@ -816,8 +816,8 @@ type
     procedure SetUniformMatrix2fv(const index: string; const val: TMatrix2f);
     function GetUniformMatrix3fv(const index: string): TMatrix3f;
     procedure SetUniformMatrix3fv(const index: string; const val: TMatrix3f);
-    function GetUniformMatrix4fv(const index: string): TMatrix;
-    procedure SetUniformMatrix4fv(const index: string; const val: TMatrix);
+    function GetUniformMatrix4fv(const index: string): TGLMatrix;
+    procedure SetUniformMatrix4fv(const index: string; const val: TGLMatrix);
     function GetUniformTextureHandle(const Index: string; const TextureIndex: Integer; const TextureTarget: TGLTextureTarget)
       : TGLuint;
     procedure SetUniformTextureHandle(const Index: string; const TextureIndex: Integer; const TextureTarget: TGLTextureTarget;
@@ -868,7 +868,7 @@ type
     property Uniform4f[const index: string]: TGLVector read GetUniform4f write SetUniform4f;
     property UniformMatrix2fv[const index: string]: TMatrix2f read GetUniformMatrix2fv write SetUniformMatrix2fv;
     property UniformMatrix3fv[const index: string]: TMatrix3f read GetUniformMatrix3fv write SetUniformMatrix3fv;
-    property UniformMatrix4fv[const index: string]: TMatrix read GetUniformMatrix4fv write SetUniformMatrix4fv;
+    property UniformMatrix4fv[const index: string]: TGLMatrix read GetUniformMatrix4fv write SetUniformMatrix4fv;
     property UniformTextureHandle[const index: string; const TextureIndex: Integer; const TextureTarget: TGLTextureTarget]
       : TGLuint read GetUniformTextureHandle write SetUniformTextureHandle;
     property UniformBuffer[const index: string]: TGLUniformBufferHandle write SetUniformBuffer;
@@ -3256,12 +3256,12 @@ begin
   gl.UniformMatrix3fv(GetUniformLocation(index), 1, False, @val);
 end;
 
-function TGLProgramHandle.GetUniformMatrix4fv(const index: string): TMatrix;
+function TGLProgramHandle.GetUniformMatrix4fv(const index: string): TGLMatrix;
 begin
   gl.GetUniformfv(GetHandle, GetUniformLocation(index), @Result);
 end;
 
-procedure TGLProgramHandle.SetUniformMatrix4fv(const index: string; const val: TMatrix);
+procedure TGLProgramHandle.SetUniformMatrix4fv(const index: string; const val: TGLMatrix);
 begin
   gl.UniformMatrix4fv(GetUniformLocation(index), 1, False, @val);
 end;

+ 1 - 1
Source/GLS.EllipseCollision.pas

@@ -31,7 +31,7 @@ type
 
   // Object collision properties
   TECObjectInfo = record
-    AbsoluteMatrix: TMatrix;
+    AbsoluteMatrix: TGLMatrix;
     Solid: Boolean;
     IsDynamic: Boolean;
     ObjectID: Integer;

+ 1 - 1
Source/GLS.ExplosionFx.pas

@@ -220,7 +220,7 @@ procedure TGLBExplosionFX.Render(var rci : TGLRenderContextInfo);
 var
   Face: integer;
   dir, p1, p2, p3: TAffineVector;
-  mat: TMatrix;
+  mat: TGLMatrix;
 
 begin
   if not FEnabled then

+ 9 - 9
Source/GLS.File3DS.pas

@@ -39,7 +39,7 @@ type
 
   // A record that holds all the information that is used during 3ds animation.
   TGLFile3DSAnimationData = packed record
-    ModelMatrix: TMatrix;
+    ModelMatrix: TGLMatrix;
     Color: TGLVector; // Omni Light.
     TargetPos: TAffineVector; // Spot Light.
     SpotLightCutOff: Single;
@@ -56,7 +56,7 @@ type
   protected
     function InterpolateValue(const AValues: array of Single; const AFrame: real): Single; overload;
     function InterpolateValue(const AValues: array of TAffineVector; const AFrame: real): TAffineVector; overload;
-    function InterpolateValue(const AValues: array of TKFRotKey3DS; const AFrame: real): TMatrix; overload;
+    function InterpolateValue(const AValues: array of TKFRotKey3DS; const AFrame: real): TGLMatrix; overload;
   public
     procedure LoadData(const ANumKeys: Integer; const Keys: PKeyHeaderList; const AData: Pointer); virtual;
     procedure Apply(var DataTransf: TGLFile3DSAnimationData; const AFrame: real); virtual; abstract;
@@ -350,11 +350,11 @@ begin
   Result.RealPart := v.W;
 end;
 
-function QuaternionToRotateMatrix(const Quaternion: TQuaternion): TMatrix;
+function QuaternionToRotateMatrix(const Quaternion: TQuaternion): TGLMatrix;
 var
   wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2: Single;
   quat: TGLVector;
-  m: TMatrix;
+  m: TGLMatrix;
 begin
   quat := VectorMake(Quaternion.ImagPart);
   quat.W := Quaternion.RealPart;
@@ -453,7 +453,7 @@ begin
   Result := VectorLerp(start, stop, w);
 end;
 
-function TGLFile3DSAnimationKeys.InterpolateValue(const AValues: array of TKFRotKey3DS; const AFrame: real): TMatrix;
+function TGLFile3DSAnimationKeys.InterpolateValue(const AValues: array of TKFRotKey3DS; const AFrame: real): TGLMatrix;
 var
   I: Integer;
   w: real;
@@ -1155,8 +1155,8 @@ var
   aScale: TGLFile3DSScaleAnimationKeys;
   aRot: TGLFile3DSRotationAnimationKeys;
   aPos: TGLFile3DSPositionAnimationKeys;
-  Mat : TMatrix;
-  RotMat : TMatrix;
+  Mat : TGLMatrix;
+  RotMat : TGLMatrix;
   AffVect : TAffineVector;
 begin
   inherited;
@@ -1702,13 +1702,13 @@ var
 
 // ----------------------------------------------------------------------
 
-  function InvertMeshMatrix(Objects: TObjectList; const Name: string): TMatrix;
+  function InvertMeshMatrix(Objects: TObjectList; const Name: string): TGLMatrix;
   // constructs a 4x4 matrix from 3x4 local mesh matrix given by Name and
   // inverts it so it can be used for the keyframer stuff
   var
     I, Index: Integer;
     boolY: Boolean;
-    m: TMatrix;
+    m: TGLMatrix;
     v4: TGLVector;
     factor: Single;
   begin

+ 6 - 6
Source/GLS.File3DSSceneObjects.pas

@@ -70,7 +70,7 @@ type
 
   TGLFile3DSFreeForm = class(TGLFreeForm)
   private
-    FTransfMat, FScaleMat, ParentMatrix: TMatrix;
+    FTransfMat, FScaleMat, ParentMatrix: TGLMatrix;
 
     FS_Rot3DS: TGLCoordinates4;
     FRot3DS: TGLCoordinates4;
@@ -80,7 +80,7 @@ type
   protected
     procedure DefineProperties(Filer: TFiler); override;
   public
-    FRefMat: TMatrix;
+    FRefMat: TGLMatrix;
     constructor Create(AOWner: TComponent); override;
     destructor Destroy; override;
     procedure BuildList(var rci: TGLRenderContextInfo); override;
@@ -117,11 +117,11 @@ begin
   Result.RealPart := v.W;
 end;
 
-function QuaternionToRotateMatrix(const Quaternion: TQuaternion): TMatrix;
+function QuaternionToRotateMatrix(const Quaternion: TQuaternion): TGLMatrix;
 var
   wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2: Single;
   quat: TGLVector;
-  m: TMatrix;
+  m: TGLMatrix;
 begin
   quat := VectorMake(Quaternion.ImagPart);
   quat.W := Quaternion.RealPart;
@@ -460,7 +460,7 @@ end;
 function TGLFile3DSFreeForm.AxisAlignedDimensionsUnscaled: TGLVector;
 var
   dMin, dMax: TAffineVector;
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
   MeshObjects.GetExtents(dMin, dMax);
   mat := ParentMatrix;
@@ -479,7 +479,7 @@ end;
 function TGLFile3DSFreeForm.BarycenterAbsolutePosition: TGLVector;
 var
   dMin, dMax: TAffineVector;
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
   MeshObjects.GetExtents(dMin, dMax);
   mat := ParentMatrix;

+ 2 - 2
Source/GLS.FileASE.pas

@@ -90,7 +90,7 @@ type
   private
     FFaces: TGLASEFaceList;
     FVertices: TAffineVectorList;
-    FMatrix: TMatrix;
+    FMatrix: TGLMatrix;
     FInheritedPosition: TAffineVector;
     FInheritedScale: TAffineVector;
     FInheritedRotation: TAffineVector;
@@ -113,7 +113,7 @@ type
     property Vertices: TAffineVectorList read FVertices;
     property TextChannel[Channel: Integer]: TAffineVectorList read GetTextChannel;
     property TextChannelsCount: Integer read FTexChannelsCount;
-    property Matrix: TMatrix read FMatrix;
+    property Matrix: TGLMatrix read FMatrix;
     property InheritedPosition: TAffineVector read FInheritedPosition;
     property InheritedRotation: TAffineVector read FInheritedRotation;
     property InheritedScale: TAffineVector read FInheritedScale;

+ 2 - 2
Source/GLS.FileB3D.pas

@@ -56,11 +56,11 @@ var
   Vertex: PVertexData;
   Triangles: PTRISChunk;
   V, V1: TAffineVector;
-  Matrix: TMatrix;
+  Matrix: TGLMatrix;
   MatLib: TGLMaterialLibrary;
   LightLib: TGLMaterialLibrary;
   RotQuat: TQuaternion;
-  RotMat: TMatrix;
+  RotMat: TGLMatrix;
 
   function GetOrAllocateMaterial(MaterialNum: Integer; AMat: TB3DMaterial;
     ATex: TB3DTexture; ALightmap: TB3DTexture): string;

+ 2 - 2
Source/GLS.FileMD5.pas

@@ -127,7 +127,7 @@ procedure TGLMD5VectorFile.LoadFromStream(aStream: TStream);
     bonename: String;
     pos: TAffineVector;
     quat: TQuaternion;
-    mat, rmat: TMatrix;
+    mat, rmat: TGLMatrix;
     ParentBoneID: Integer;
     bone, parentbone: TGLSkeletonBone;
   begin
@@ -208,7 +208,7 @@ procedure TGLMD5VectorFile.LoadFromStream(aStream: TStream);
     VertexWeighted: TAffineVectorList;
     blendedVert, transformedVert: TAffineVector;
     i, j, k: Integer;
-    mat: TMatrix;
+    mat: TGLMatrix;
   begin
     VertexWeightID := TIntegerList.Create;
     VertexWeightCount := TIntegerList.Create;

+ 1 - 1
Source/GLS.FileMS3D.pas

@@ -411,7 +411,7 @@ var
 
   function AddRotations(rot, baserot: TAffineVector): TAffineVector;
   var
-    mat1, mat2, rmat: TMatrix;
+    mat1, mat2, rmat: TGLMatrix;
     s, c: Single;
     Trans: TTransformations;
   begin

+ 1 - 1
Source/GLS.FileOBJ.pas

@@ -20,6 +20,7 @@ uses
   System.Classes,
   System.SysUtils,
 
+  GLS.VectorTypes,
   GLS.ApplicationFileIO,
   GLS.PersistentClasses,
   GLS.VectorGeometry,
@@ -100,7 +101,6 @@ implementation
 // ------------------------------------------------------------------
 
 uses
-  GLS.VectorTypes,
   GLS.Strings,
   GLS.OpenGLTokens,
   GLS.XOpenGL,

+ 3 - 2
Source/GLS.FileQ3MD3.pas

@@ -11,6 +11,7 @@ uses
   System.Classes,
   System.SysUtils,
 
+  GLS.VectorTypes,
   GLS.VectorGeometry,
   GLS.VectorFileObjects,
   GLS.VectorLists,
@@ -30,7 +31,7 @@ type
   public
     procedure LoadFromFile(const FileName: String);
     procedure LoadFromStream(AStream: TStream);
-    function GetTransform(const TagName: string; Frame: Integer): TMatrix;
+    function GetTransform(const TagName: string; Frame: Integer): TGLMatrix;
     property TagCount: Integer read FNumTags;
     property FrameCount: Integer read FNumFrames;
     property Tags[index: Integer]: TMD3Tag read GetTag;
@@ -304,7 +305,7 @@ begin
 end;
 
 function TMD3TagList.GetTransform(const TagName: string;
-  Frame: Integer): TMatrix;
+  Frame: Integer): TGLMatrix;
 var
   TagIdx, i, j: Integer;
   Tag: TMD3Tag;

+ 2 - 2
Source/GLS.FileVRML.pas

@@ -164,7 +164,7 @@ var
   mesh: TMeshObject;
   uniqueMatID: Integer;
   currentMaterial: TGLLibMaterial;
-  currentTransform: TMatrix;
+  currentTransform: TGLMatrix;
   creaseAngle: Single;
 
   function GetUniqueMaterialName: String;
@@ -443,7 +443,7 @@ var
     fg: TFGVertexNormalTexIndexList;
     face: TIntegerList;
     tempLibMat: TGLLibMaterial;
-    saveTransform, mat: TMatrix;
+    saveTransform, mat: TGLMatrix;
     saveMaterial: TGLLibMaterial;
     axis: TAffineVector;
     angle: Single;

+ 1 - 1
Source/GLS.FileX.pas

@@ -47,7 +47,7 @@ var
   var
     i, j, k, l, vertcount: integer;
     mo: TMeshObject;
-    mat: TMatrix;
+    mat: TGLMatrix;
     libmat: TGLLibMaterial;
     fg: TFGVertexNormalTexIndexList;
     str: String;

+ 2 - 2
Source/GLS.FireFX.pas

@@ -79,7 +79,7 @@ type
     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
     procedure CalcFire(deltaTime: Double; ParticleInterval, ParticleLife: Single;
       FireAlpha: Single);
-    procedure AffParticle3d(Color2: TColorVector; const mat: TMatrix);
+    procedure AffParticle3d(Color2: TColorVector; const mat: TGLMatrix);
   public
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
@@ -526,7 +526,7 @@ begin
   end;
 end;
 
-procedure TGLFireFXManager.AffParticle3d(Color2: TColorVector; const mat: TMatrix);
+procedure TGLFireFXManager.AffParticle3d(Color2: TColorVector; const mat: TGLMatrix);
 var
   vx, vy: TGLVector;
   i: Integer;

+ 1 - 1
Source/GLS.GeomObjects.pas

@@ -3585,7 +3585,7 @@ end;
 procedure TGLTeapot.DoRender(var ARci: TGLRenderContextInfo;
   ARenderSelf, ARenderChildren: Boolean);
 const
-  M: TMatrix = (
+  M: TGLMatrix = (
   X:(X:0.150000005960464; Y:0; Z:0; W:0);
   Y:(X:0; Y:-6.55670850946422e-09; Z:-0.150000005960464; W:0);
   Z:(X:0; Y:0.150000005960464; Z:-6.55670850946422e-09; W:0);

+ 10 - 10
Source/GLS.GeometryBB.pas

@@ -77,8 +77,8 @@ procedure AddAABB(var Aabb: TAABB; const Aabb1: TAABB);
 procedure SetBB(var C: THmgBoundingBox; const V: TGLVector);
 procedure SetAABB(var Bb: TAABB; const V: TGLVector); inline;
 
-procedure BBTransform(var C: THmgBoundingBox; const M: TMatrix);
-procedure AABBTransform(var Bb: TAABB; const M: TMatrix);
+procedure BBTransform(var C: THmgBoundingBox; const M: TGLMatrix);
+procedure AABBTransform(var Bb: TAABB; const M: TGLMatrix);
 procedure AABBScale(var Bb: TAABB; const V: TAffineVector);
 
 function BBMinX(const C: THmgBoundingBox): Single;
@@ -100,7 +100,7 @@ function BBToAABB(const ABB: THmgBoundingBox): TAABB;
 // Converts an AABB to its canonical BB. 
 function AABBToBB(const AnAABB: TAABB): THmgBoundingBox; overload;
 // Transforms an AABB to a BB. 
-function AABBToBB(const AnAABB: TAABB; const M: TMatrix): THmgBoundingBox; overload;
+function AABBToBB(const AnAABB: TAABB; const M: TGLMatrix): THmgBoundingBox; overload;
 //  Adds delta to min and max of the AABB. 
 procedure OffsetAABB(var Aabb: TAABB; const Delta: TAffineVector); overload;
 procedure OffsetAABB(var Aabb: TAABB; const Delta: TGLVector); overload;
@@ -111,7 +111,7 @@ procedure OffsetBB(var Bb: THmgBoundingBox; const Delta: TGLVector); overload;
 procedure OffsetBBPoint(var Bb: THmgBoundingBox; const Delta: TGLVector); overload;
 (* Determines if two AxisAlignedBoundingBoxes intersect.
   The matrices are the ones that convert one point to the other's AABB system *)
-function IntersectAABBs(const Aabb1, Aabb2: TAABB; const M1To2, M2To1: TMatrix): Boolean; overload;
+function IntersectAABBs(const Aabb1, Aabb2: TAABB; const M1To2, M2To1: TGLMatrix): Boolean; overload;
 // Checks whether two Bounding boxes aligned with the world axes collide in the XY plane.
 function IntersectAABBsAbsoluteXY(const Aabb1, Aabb2: TAABB): Boolean;
 // Checks whether two Bounding boxes aligned with the world axes collide in the XZ plane.
@@ -180,7 +180,7 @@ function BSphereIntersectsBSphere(const MainBSphere, TestBSphere: TBSphere): Boo
 // Extend the clip rect to include given coordinate. 
 procedure IncludeInClipRect(var ClipRect: TClipRect; X, Y: Single);
 // Projects an AABB and determines the extent of its projection as a clip rect. 
-function AABBToClipRect(const Aabb: TAABB; const ModelViewProjection: TMatrix;
+function AABBToClipRect(const Aabb: TAABB; const ModelViewProjection: TGLMatrix;
   ViewportSizeX, ViewportSizeY: Integer): TClipRect;
 
 // Finds the intersection between a ray and an axis aligned bounding box. 
@@ -301,7 +301,7 @@ begin
   Bb.Min.Z := -Bb.Max.Z;
 end;
 
-procedure BBTransform(var C: THmgBoundingBox; const M: TMatrix);
+procedure BBTransform(var C: THmgBoundingBox; const M: TGLMatrix);
 var
   I: Integer;
 begin
@@ -309,7 +309,7 @@ begin
     C.BBox[I] := VectorTransform(C.BBox[I], M);
 end;
 
-procedure AABBTransform(var Bb: TAABB; const M: TMatrix);
+procedure AABBTransform(var Bb: TAABB; const M: TGLMatrix);
 var
   OldMin, OldMax: TAffineVector;
 begin
@@ -492,7 +492,7 @@ begin
   end;
 end;
 
-function AABBToBB(const AnAABB: TAABB; const M: TMatrix): THmgBoundingBox;
+function AABBToBB(const AnAABB: TAABB; const M: TGLMatrix): THmgBoundingBox;
 begin
   Result := AABBToBB(AnAABB);
   BBTransform(Result, M);
@@ -537,7 +537,7 @@ begin
 end;
 
 function IntersectAABBs(const Aabb1, Aabb2: TAABB;
-  const M1To2, M2To1: TMatrix): Boolean;
+  const M1To2, M2To1: TGLMatrix): Boolean;
 const
   CWires: array [0 .. 11, 0 .. 1] of Integer // Points of the wire
     = ((0, 1), (1, 2), (2, 3), (3, 0), (4, 5), (5, 6), (6, 7), (7, 4), (0, 4),
@@ -1288,7 +1288,7 @@ begin
   end;
 end;
 
-function AABBToClipRect(const Aabb: TAABB; const ModelViewProjection: TMatrix;
+function AABBToClipRect(const Aabb: TAABB; const ModelViewProjection: TGLMatrix;
   ViewportSizeX, ViewportSizeY: Integer): TClipRect;
 var
   I: Integer;

+ 7 - 7
Source/GLS.Gizmo.pas

@@ -86,11 +86,11 @@ type
     FOldLibMaterialName: string;
     FOldAutoScaling: TGLCoordinates;
     FEffectedObject: TGLCustomSceneObject;
-    FOldMatr: TMatrix;
-    FOldMatrix: TMatrix;
+    FOldMatr: TGLMatrix;
+    FOldMatrix: TGLMatrix;
     procedure SetEffectedObject(const Value: TGLCustomSceneObject);
     procedure SetOldAutoScaling(const Value: TGLCoordinates);
-    procedure SetOldMatrix(const Value: TMatrix);
+    procedure SetOldMatrix(const Value: TGLMatrix);
   protected
     procedure DoUndo; virtual;
     function GetParent: TGLGizmoUndoCollection;
@@ -102,7 +102,7 @@ type
       Operation: TOperation); virtual;
     procedure AssignFromObject(const AObject: TGLCustomSceneObject);
     // TODO: create a special type for Matrix.
-    property OldMatrix: TMatrix read FOldMatrix write SetOldMatrix;
+    property OldMatrix: TGLMatrix read FOldMatrix write SetOldMatrix;
   published
     property EffectedObject: TGLCustomSceneObject read FEffectedObject
       write SetEffectedObject;
@@ -317,7 +317,7 @@ implementation
 procedure RotateAroundArbitraryAxis(const AnObject: TGLBaseSceneObject;
   const Axis, Origin: TAffineVector; const Angle: Single);
 var
-  M, M1, M2, M3: TMatrix;
+  M, M1, M2, M3: TGLMatrix;
 begin
   M1 := CreateTranslationMatrix(VectorNegate(Origin));
   M2 := CreateRotationMatrix(Axis, Angle * PI / 180);
@@ -1312,7 +1312,7 @@ var
   var
     Vec1: TGLVector;
     RotV: TAffineVector;
-    Pmat: TMatrix;
+    Pmat: TGLMatrix;
 
   begin
     Vec1.X := 0;
@@ -1797,7 +1797,7 @@ begin
   FOldAutoScaling.Assign(Value);
 end;
 
-procedure TGLGizmoUndoItem.SetOldMatrix(const Value: TMatrix);
+procedure TGLGizmoUndoItem.SetOldMatrix(const Value: TGLMatrix);
 begin
   FOldMatrix := Value;
 end;

+ 7 - 7
Source/GLS.GizmoEx.pas

@@ -54,10 +54,10 @@ type
     FIndexOldObject: Integer;
     FNameOldObject: string;
     FReturnObject: Boolean;
-    FOldMatrix: TMatrix;
+    FOldMatrix: TGLMatrix;
     FGizmoTmpRoot: TGLBaseSceneObject;
     procedure SetEffectedObject(const Value: TGLBaseSceneObject);
-    procedure SetOldMatrix(const Value: TMatrix);
+    procedure SetOldMatrix(const Value: TGLMatrix);
   protected
     procedure DoUndo;
     function GetParent: TGLGizmoExObjectCollection;
@@ -69,7 +69,7 @@ type
     procedure Notification(AComponent: TComponent; Operation: TOperation); virtual;
     procedure AssignFromObject(const AObject: TGLBaseSceneObject; AssignAndRemoveObj: Boolean = False);
     // TODO: create a special type for Matrix.
-    property OldMatrix: TMatrix read FOldMatrix write SetOldMatrix;
+    property OldMatrix: TGLMatrix read FOldMatrix write SetOldMatrix;
   published
     property EffectedObject: TGLBaseSceneobject read FEffectedObject write SetEffectedObject;
   end;
@@ -480,7 +480,7 @@ uses
 
 procedure RotateAroundArbitraryAxis(const anObject: TGLBaseSceneObject; const Axis, Origin: TAffineVector; const angle: Single);
 var
-  M, M1, M2, M3: TMatrix;
+  M, M1, M2, M3: TGLMatrix;
 begin
   M1 := CreateTranslationMatrix(VectorNegate(Origin));
   M2 := CreateRotationMatrix(Axis, Angle * PI / 180);
@@ -2138,7 +2138,7 @@ procedure TGLGizmoEx.InternalRender(Sender: TObject; var rci: TGLRenderContextIn
   var
     FLayout: TTextLayout;
     FAlignment: TAlignment;
-    wm:   TMatrix;
+    wm:   TGLMatrix;
     I, J: Integer;
   begin
     if not Assigned(FLabelFont) and (Text = '') then
@@ -3560,7 +3560,7 @@ var
   var
     vec1: TGLVector;
     rotV: TAffineVector;
-    pmat: TMatrix;
+    pmat: TGLMatrix;
     I:    Integer;
     IncludeCh: Boolean;
     v:    TGLVector;
@@ -4324,7 +4324,7 @@ begin
   FEffectedObject := Value;
 end;
 
-procedure TGLGizmoExObjectItem.SetOldMatrix(const Value: TMatrix);
+procedure TGLGizmoExObjectItem.SetOldMatrix(const Value: TGLMatrix);
 begin
   FOldMatrix := Value;
 end;

+ 5 - 5
Source/GLS.Imposter.pas

@@ -417,7 +417,7 @@ end;
 
 procedure TImposter.BeginRender(var rci: TGLRenderContextInfo);
 var
-  mat: TMatrix;
+  mat: TGLMatrix;
   filter: Cardinal;
   fx, fy, yOffset, cosAlpha, dynScale: Single;
 begin
@@ -1124,7 +1124,7 @@ var
   xDest, xSrc, yDest, ySrc: Integer;
   corona: TGLStaticImposterBuilderCorona;
   fx, fy, yOffset: Single;
-  LM: TMatrix;
+  LM: TGLMatrix;
 begin
   FTextureSize := ComputeOptimalTextureSize;
   if (FTextureSize.X <= 0) and (FTextureSize.Y <= 0) then
@@ -1302,7 +1302,7 @@ procedure TGLDynamicImposterBuilder.DoRender(var rci : TGLRenderContextInfo;
 var
   i, size, Left, Top, Width, Height : Integer;
   imposter : TGLImposter;
-  mat, projection, modelview : TMatrix;
+  mat, projection, modelview : TGLMatrix;
   BackColor, pos, temp : TGLVector;
   rad : Single;
   AABB : TAABB;
@@ -1508,10 +1508,10 @@ begin
    Result:=NullHMGVector;
 end;
 
-function TGLImposter.CalcError(NewMatrix : TMatrix) : Single;
+function TGLImposter.CalcError(NewMatrix : TGLMatrix) : Single;
 var
    i : Integer;
-   mat : TMatrix;
+   mat : TGLMatrix;
    err : Single;
 begin
    err:=0;

+ 1 - 1
Source/GLS.LensFlare.pas

@@ -461,7 +461,7 @@ var
   screenPos: TAffineVector;
   flareInViewPort, dynamicSize: Boolean;
   oldSeed: LongInt;
-  projMatrix: TMatrix;
+  projMatrix: TGLMatrix;
   CurrentBuffer: TGLSceneBuffer;
 begin
   if (rci.drawState = dsPicking) then

+ 1 - 1
Source/GLS.LinePFX.pas

@@ -113,7 +113,7 @@ end;
 procedure TGLLinePFXManager.InitializeRendering(var rci: TGLRenderContextInfo);
 var
   i: Integer;
-  matrix: TMatrix;
+  matrix: TGLMatrix;
 begin
   inherited;
   gl.GetFloatv(GL_MODELVIEW_MATRIX, @matrix);

+ 5 - 5
Source/GLS.Material.pas

@@ -460,7 +460,7 @@ type
     FTextureRotate: Single;
     FTextureMatrixIsIdentity: Boolean;
     FTextureOverride: Boolean;
-    FTextureMatrix: TMatrix;
+    FTextureMatrix: TGLMatrix;
     FTexture2Name: TGLLibMaterialName;
     FShader: TGLShader;
     libMatTexture2: TGLLibMaterial; // internal cache
@@ -469,7 +469,7 @@ type
     procedure SetMaterial(const val: TGLMaterial);
     procedure SetTextureOffset(const val: TGLCoordinates);
     procedure SetTextureScale(const val: TGLCoordinates);
-    procedure SetTextureMatrix(const Value: TMatrix);
+    procedure SetTextureMatrix(const Value: TGLMatrix);
     procedure SetTexture2Name(const val: TGLLibMaterialName);
     procedure SetShader(const val: TGLShader);
     procedure SetTextureRotate(Value: Single);
@@ -487,7 +487,7 @@ type
     { Restore non-standard material states that were altered}
     function UnApply(var ARci: TGLRenderContextInfo): Boolean; override;
     procedure NotifyUsersOfTexMapChange;
-    property TextureMatrix: TMatrix read FTextureMatrix write SetTextureMatrix;
+    property TextureMatrix: TGLMatrix read FTextureMatrix write SetTextureMatrix;
     property TextureMatrixIsIdentity: boolean read FTextureMatrixIsIdentity;
     procedure NotifyTexMapChange(Sender: TObject);
     function Blended: Boolean; override;
@@ -1968,9 +1968,9 @@ begin
   CalculateTextureMatrix;
 end;
 
-procedure TGLLibMaterial.SetTextureMatrix(const Value: TMatrix);
+procedure TGLLibMaterial.SetTextureMatrix(const Value: TGLMatrix);
 begin
-  FTextureMatrixIsIdentity := CompareMem(@Value.V[0], @IdentityHmgMatrix.V[0], SizeOf(TMatrix));
+  FTextureMatrixIsIdentity := CompareMem(@Value.V[0], @IdentityHmgMatrix.V[0], SizeOf(TGLMatrix));
   FTextureMatrix := Value;
   FTextureOverride := True;
   NotifyUsers;

+ 5 - 5
Source/GLS.MaterialEx.pas

@@ -408,7 +408,7 @@ type
     FTextureRotate: Single;
     FTextureMatrixIsIdentity: Boolean;
     FTextureOverride: Boolean;
-    FTextureMatrix: TMatrix;
+    FTextureMatrix: TGLMatrix;
     FMappingMode: TGLTextureMappingMode;
     FEnvColor: TGLColor;
     FMapSCoordinates: TGLCoordinates4;
@@ -426,7 +426,7 @@ type
     function GetTextureScale: TGLCoordinates;
     procedure SetTextureScale(const AValue: TGLCoordinates);
     function StoreTextureScale: Boolean;
-    procedure SetTextureMatrix(const AValue: TMatrix);
+    procedure SetTextureMatrix(const AValue: TGLMatrix);
     procedure SetTextureRotate(AValue: Single);
     function StoreTextureRotate: Boolean;
     procedure SetMappingMode(const AValue: TGLTextureMappingMode);
@@ -459,7 +459,7 @@ type
     function IsValid: Boolean;
     procedure Apply(var ARci: TGLRenderContextInfo);
     procedure UnApply(var ARci: TGLRenderContextInfo);
-    property TextureMatrix: TMatrix read FTextureMatrix write SetTextureMatrix;
+    property TextureMatrix: TGLMatrix read FTextureMatrix write SetTextureMatrix;
   published
     property LibTextureName: TGLMaterialComponentName read GetLibTextureName
       write SetLibTextureName;
@@ -3903,10 +3903,10 @@ begin
   FSwizzling.Assign(AValue);
 end;
 
-procedure TGLTextureProperties.SetTextureMatrix(const AValue: TMatrix);
+procedure TGLTextureProperties.SetTextureMatrix(const AValue: TGLMatrix);
 begin
   FTextureMatrixIsIdentity := CompareMem(@AValue.V[0], @IdentityHmgMatrix.V[0],
-    SizeOf(TMatrix));
+    SizeOf(TGLMatrix));
   FTextureMatrix := AValue;
   FTextureOverride := True;
   NotifyChange(Self);

+ 2 - 2
Source/GLS.Mirror.pas

@@ -139,7 +139,7 @@ procedure TGLMirror.DoRender(var ARci: TGLRenderContextInfo;
   ARenderSelf, ARenderChildren: Boolean);
 var
   oldProxySubObject: Boolean;
-  refMat, curMat, ModelMat: TMatrix;
+  refMat, curMat, ModelMat: TGLMatrix;
   clipPlane: TDoubleHmgPlane;
   bgColor: TColorVector;
   cameraPosBackup, cameraDirectionBackup: TGLVector;
@@ -307,7 +307,7 @@ end;
 
 procedure TGLMirror.ClearZBufferArea(aBuffer: TGLSceneBuffer);
 var
-  worldMat: TMatrix;
+  worldMat: TGLMatrix;
   p: TAffineVector;
 begin
   with aBuffer do

+ 1 - 1
Source/GLS.Objects.pas

@@ -1303,7 +1303,7 @@ procedure TGLSprite.BuildList(var rci: TGLRenderContextInfo);
 var
   vx, vy: TAffineVector;
   W, h: Single;
-  mat: TMatrix;
+  mat: TGLMatrix;
   u0, v0, u1, v1: Integer;
 begin
   if FAlphaChannel <> 1 then

+ 5 - 5
Source/GLS.Octree.pas

@@ -118,9 +118,9 @@ type
       : TAffineVectorList;
     //  Returns all triangles in an arbitrarily placed cube
     function GetTrianglesFromNodesIntersectingCube(const ObjAABB: TAABB;
-      const ObjToSelf, SelfToObj: TMatrix): TAffineVectorList;
+      const ObjToSelf, SelfToObj: TGLMatrix): TAffineVectorList;
     //  Checks if an AABB intersects a face on the octree
-    function AABBIntersect(const AABB: TAABB; const M1to2, M2to1: TMatrix;
+    function AABBIntersect(const AABB: TAABB; const M1to2, M2to1: TGLMatrix;
       Triangles: TAffineVectorList = nil): Boolean;
     // function SphereIntersect(position:TAffineVector; radius:single);
   end;
@@ -1410,7 +1410,7 @@ begin
   end; // end for i nodes
 end;
 
-function TGLOctree.AABBIntersect(const AABB: TAABB; const M1to2, M2to1: TMatrix;
+function TGLOctree.AABBIntersect(const AABB: TAABB; const M1to2, M2to1: TGLMatrix;
   Triangles: TAffineVectorList = nil): Boolean;
 var
   TriList: TAffineVectorList;
@@ -1512,10 +1512,10 @@ begin
 end;
 
 function TGLOctree.GetTrianglesFromNodesIntersectingCube(const ObjAABB: TAABB;
-  const ObjToSelf, SelfToObj: TMatrix): TAffineVectorList;
+  const ObjToSelf, SelfToObj: TGLMatrix): TAffineVectorList;
 var
   AABB1: TAABB;
-  M1To2, M2To1: TMatrix;
+  M1To2, M2To1: TGLMatrix;
 
   procedure HandleNode(Onode: POctreeNode);
   var

+ 3 - 3
Source/GLS.ParticleFX.pas

@@ -2286,7 +2286,7 @@ procedure TGLLifeColoredPFXManager.RotateVertexBuf(buf: TAffineVectorList;
   lifeTime: Single; const axis: TAffineVector; offsetAngle: Single);
 var
   rotateAngle: Single;
-  rotMatrix: TMatrix;
+  rotMatrix: TGLMatrix;
   diff: Single;
   lifeRotationApplied: Boolean;
 begin
@@ -2421,7 +2421,7 @@ end;
 procedure TGLPolygonPFXManager.InitializeRendering(var rci: TGLRenderContextInfo);
 var
   i: Integer;
-  matrix: TMatrix;
+  matrix: TGLMatrix;
   s, c: Single;
 begin
   inherited;
@@ -2629,7 +2629,7 @@ end;
 procedure TGLBaseSpritePFXManager.InitializeRendering(var rci: TGLRenderContextInfo);
 var
   i: Integer;
-  matrix: TMatrix;
+  matrix: TGLMatrix;
   s, c, w, h: Single;
 begin
   inherited;

+ 35 - 35
Source/GLS.PipelineTransformation.pas

@@ -40,14 +40,14 @@ type
   PTransformationRec = ^TTransformationRec;
   TTransformationRec = record
     FStates: TGLPipelineTransformationStates;
-    FModelMatrix: TMatrix;
-    FViewMatrix: TMatrix;
-    FProjectionMatrix: TMatrix;
-    FInvModelMatrix: TMatrix;
+    FModelMatrix: TGLMatrix;
+    FViewMatrix: TGLMatrix;
+    FProjectionMatrix: TGLMatrix;
+    FInvModelMatrix: TGLMatrix;
     FNormalModelMatrix: TAffineMatrix;
-    FModelViewMatrix: TMatrix;
-    FInvModelViewMatrix: TMatrix;
-    FViewProjectionMatrix: TMatrix;
+    FModelViewMatrix: TGLMatrix;
+    FInvModelViewMatrix: TGLMatrix;
+    FViewProjectionMatrix: TGLMatrix;
     FFrustum: TFrustum;
   end;
 
@@ -61,14 +61,14 @@ type
     FStack: array of TTransformationRec;
     FLoadMatricesEnabled: Boolean;
     FOnPush: TOnMatricesPush;
-    function GetModelMatrix: PMatrix; inline;
-    function GetViewMatrix: PMatrix; inline;
-    function GetProjectionMatrix: PMatrix; inline;
-    function GetModelViewMatrix: PMatrix; inline;
-    function GetInvModelViewMatrix: PMatrix; inline;
-    function GetInvModelMatrix: PMatrix; inline;
+    function GetModelMatrix: PGLMatrix; inline;
+    function GetViewMatrix: PGLMatrix; inline;
+    function GetProjectionMatrix: PGLMatrix; inline;
+    function GetModelViewMatrix: PGLMatrix; inline;
+    function GetInvModelViewMatrix: PGLMatrix; inline;
+    function GetInvModelMatrix: PGLMatrix; inline;
     function GetNormalModelMatrix: PAffineMatrix; inline;
-    function GetViewProjectionMatrix: PMatrix; inline;
+    function GetViewProjectionMatrix: PGLMatrix; inline;
     function GetFrustum: TFrustum; inline;
   protected
     procedure LoadModelViewMatrix; inline;
@@ -77,23 +77,23 @@ type
     property OnPush: TOnMatricesPush read FOnPush write FOnPush;
   public
     constructor Create;
-    procedure SetModelMatrix(const AMatrix: TMatrix); inline;
-    procedure SetViewMatrix(const AMatrix: TMatrix); inline;
-    procedure SetProjectionMatrix(const AMatrix: TMatrix); inline;
+    procedure SetModelMatrix(const AMatrix: TGLMatrix); inline;
+    procedure SetViewMatrix(const AMatrix: TGLMatrix); inline;
+    procedure SetProjectionMatrix(const AMatrix: TGLMatrix); inline;
     procedure IdentityAll; inline;
     procedure Push(AValue: PTransformationRec); overload;
     procedure Push(); overload; inline;
     procedure Pop;
     procedure ReplaceFromStack;
     function StackTop: TTransformationRec; inline;
-    property ModelMatrix: PMatrix read GetModelMatrix;
-    property ViewMatrix: PMatrix read GetViewMatrix;
-    property ProjectionMatrix: PMatrix read GetProjectionMatrix;
-    property InvModelMatrix: PMatrix read GetInvModelMatrix;
-    property ModelViewMatrix: PMatrix read GetModelViewMatrix;
+    property ModelMatrix: PGLMatrix read GetModelMatrix;
+    property ViewMatrix: PGLMatrix read GetViewMatrix;
+    property ProjectionMatrix: PGLMatrix read GetProjectionMatrix;
+    property InvModelMatrix: PGLMatrix read GetInvModelMatrix;
+    property ModelViewMatrix: PGLMatrix read GetModelViewMatrix;
     property NormalModelMatrix: PAffineMatrix read GetNormalModelMatrix;
-    property InvModelViewMatrix: PMatrix read GetInvModelViewMatrix;
-    property ViewProjectionMatrix: PMatrix read GetViewProjectionMatrix;
+    property InvModelViewMatrix: PGLMatrix read GetInvModelViewMatrix;
+    property ViewProjectionMatrix: PGLMatrix read GetViewProjectionMatrix;
     property Frustum: TFrustum read GetFrustum;
     property LoadMatricesEnabled: Boolean read FLoadMatricesEnabled write FLoadMatricesEnabled;
   end;
@@ -116,7 +116,7 @@ begin
   glMatrixMode(GL_MODELVIEW);
 end;
 
-function TGLTransformation.GetModelViewMatrix: PMatrix;
+function TGLTransformation.GetModelViewMatrix: PGLMatrix;
 begin
   if trsModelViewChanged in FStack[FStackPos].FStates then
   begin
@@ -232,22 +232,22 @@ begin
   end;
 end;
 
-function TGLTransformation.GetModelMatrix: PMatrix;
+function TGLTransformation.GetModelMatrix: PGLMatrix;
 begin
   Result := @FStack[FStackPos].FModelMatrix;
 end;
 
-function TGLTransformation.GetViewMatrix: PMatrix;
+function TGLTransformation.GetViewMatrix: PGLMatrix;
 begin
   Result := @FStack[FStackPos].FViewMatrix;
 end;
 
-function TGLTransformation.GetProjectionMatrix: PMatrix;
+function TGLTransformation.GetProjectionMatrix: PGLMatrix;
 begin
   Result := @FStack[FStackPos].FProjectionMatrix;
 end;
 
-procedure TGLTransformation.SetModelMatrix(const AMatrix: TMatrix);
+procedure TGLTransformation.SetModelMatrix(const AMatrix: TGLMatrix);
 begin
   FStack[FStackPos].FModelMatrix := AMatrix;
   FStack[FStackPos].FStates := FStack[FStackPos].FStates +
@@ -256,7 +256,7 @@ begin
     LoadModelViewMatrix;
 end;
 
-procedure TGLTransformation.SetViewMatrix(const AMatrix: TMatrix);
+procedure TGLTransformation.SetViewMatrix(const AMatrix: TGLMatrix);
 begin
   FStack[FStackPos].FViewMatrix:= AMatrix;
   FStack[FStackPos].FStates := FStack[FStackPos].FStates +
@@ -270,7 +270,7 @@ begin
   Result := FStack[FStackPos];
 end;
 
-procedure TGLTransformation.SetProjectionMatrix(const AMatrix: TMatrix);
+procedure TGLTransformation.SetProjectionMatrix(const AMatrix: TGLMatrix);
 begin
   FStack[FStackPos].FProjectionMatrix := AMatrix;
   FStack[FStackPos].FStates := FStack[FStackPos].FStates +
@@ -280,7 +280,7 @@ begin
 end;
 
 
-function TGLTransformation.GetInvModelViewMatrix: PMatrix;
+function TGLTransformation.GetInvModelViewMatrix: PGLMatrix;
 begin
   if trsInvModelViewChanged in FStack[FStackPos].FStates then
   begin
@@ -291,7 +291,7 @@ begin
   Result := @FStack[FStackPos].FInvModelViewMatrix;
 end;
 
-function TGLTransformation.GetInvModelMatrix: PMatrix;
+function TGLTransformation.GetInvModelMatrix: PGLMatrix;
 begin
   if trsInvModelChanged in FStack[FStackPos].FStates then
   begin
@@ -303,7 +303,7 @@ end;
 
 function TGLTransformation.GetNormalModelMatrix: PAffineMatrix;
 var
-  M: TMatrix;
+  M: TGLMatrix;
 begin
   if trsNormalModelChanged in FStack[FStackPos].FStates then
   begin
@@ -315,7 +315,7 @@ begin
   Result := @FStack[FStackPos].FNormalModelMatrix;
 end;
 
-function TGLTransformation.GetViewProjectionMatrix: PMatrix;
+function TGLTransformation.GetViewProjectionMatrix: PGLMatrix;
 begin
   if trsViewProjChanged in FStack[FStackPos].FStates then
   begin

+ 2 - 2
Source/GLS.ProjectedTextures.pas

@@ -125,14 +125,14 @@ end;
 
 procedure TGLTextureEmitter.SetupTexMatrix(var ARci: TGLRenderContextInfo);
 const
-  cBaseMat: TMatrix =
+  cBaseMat: TGLMatrix =
       (V:((X:0.5; Y:0;   Z:0; W:0),
           (X:0;   Y:0.5; Z:0; W:0),
           (X:0;   Y:0; Z:1; W:0),
           (X:0.5; Y:0.5; Z:0; W:1)));
 
 var
-  PM: TMatrix;
+  PM: TGLMatrix;
 begin
   // Set the projector's "perspective" (i.e. the "spotlight cone"):.
   PM := MatrixMultiply(CreatePerspectiveMatrix(FFOVy, FAspect, 0.1, 1), cBaseMat);

+ 5 - 5
Source/GLS.ProxyObjects.pas

@@ -118,7 +118,7 @@ type
   // An object containing the bone matrix for TGLActorProxy.  
   TBoneMatrixObj = class
   public
-    Matrix: TMatrix;
+    Matrix: TGLMatrix;
     BoneName: string;
     BoneIndex: integer;
   end;
@@ -172,8 +172,8 @@ type
     property CurrentTime: TGLProgressTimes read FCurrentTime;
     (* Gets the Bones Matrix in the current animation frame.
      (since the masterobject is shared between all proxies, each proxy will have it's bones matrices) *)
-    function BoneMatrix(BoneIndex: integer): TMatrix; overload;
-    function BoneMatrix(BoneName: string): TMatrix; overload;
+    function BoneMatrix(BoneIndex: integer): TGLMatrix; overload;
+    function BoneMatrix(BoneName: string): TGLMatrix; overload;
     procedure BoneMatricesClear;
     // A standard version of the RayCastIntersect function. 
     function RayCastIntersect(const rayStart, rayVector: TGLVector;
@@ -388,13 +388,13 @@ end;
 // ------------------ TGLActorProxy ------------------
 // ------------------
 
-function TGLActorProxy.BoneMatrix(BoneIndex: integer): TMatrix;
+function TGLActorProxy.BoneMatrix(BoneIndex: integer): TGLMatrix;
 begin
   if BoneIndex < FBonesMatrices.count then
     result := TBoneMatrixObj(FBonesMatrices.Objects[BoneIndex]).Matrix;
 end;
 
-function TGLActorProxy.BoneMatrix(BoneName: string): TMatrix;
+function TGLActorProxy.BoneMatrix(BoneName: string): TGLMatrix;
 var
   i: Integer;
 begin

+ 155 - 123
Source/GLS.Ragdoll.pas

@@ -1,7 +1,6 @@
 //
 // The graphics rendering engine GLScene http://glscene.org
 //
-
 unit GLS.Ragdoll;
 
 (* Base abstract ragdoll class. Should be extended to use any physics system. *)
@@ -12,8 +11,9 @@ interface
 
 uses
   GLS.Scene,
-  GLS.PersistentClasses, 
-  GLS.VectorGeometry, 
+  GLS.PersistentClasses,
+  GLS.VectorTypes,
+  GLS.VectorGeometry,
   GLS.VectorFileObjects,
   GLS.VectorLists,
   GLS.Objects;
@@ -21,38 +21,41 @@ uses
 type
   TGLRagdoll = class;
   TGLRagdolBone = class;
-
   TGLRagdolJoint = class
   end;
 
-  TGLRagdolBoneList = class (TPersistentObjectList)
+  TGLRagdolBoneList = class(TPersistentObjectList)
   private
-     FRagdoll : TGLRagdoll;
+    FRagdoll: TGLRagdoll;
   protected
-    function GetRagdollBone(Index: Integer) : TGLRagdolBone;
+    function GetRagdollBone(Index: Integer): TGLRagdolBone;
   public
     constructor Create(Ragdoll: TGLRagdoll); reintroduce;
     destructor Destroy; override;
-    procedure WriteToFiler(writer : TVirtualWriter); override;
-    procedure ReadFromFiler(reader : TVirtualReader); override;
-    property Ragdoll : TGLRagdoll read FRagdoll;
-    property Items[Index: Integer] : TGLRagdolBone read GetRagdollBone; default;
-	end;
-	TGLRagdolBone = class (TGLRagdolBoneList)
+    procedure WriteToFiler(writer: TVirtualWriter); override;
+    procedure ReadFromFiler(reader: TVirtualReader); override;
+    property Ragdoll: TGLRagdoll read FRagdoll;
+    property Items[Index: Integer]: TGLRagdolBone read GetRagdollBone; default;
+  end;
+
+  TGLRagdolBone = class(TGLRagdolBoneList)
   private
-    FOwner : TGLRagdolBoneList;
-    FName : String;
-    FBoneID : Integer; //Refering to TGLActor Bone
+    FOwner: TGLRagdolBoneList;
+    FName: String;
+    FBoneID: Integer; // Refering to TGLActor Bone
     FBoundMax: TAffineVector;
     FBoundMin: TAffineVector;
-    FBoundBoneDelta: TAffineVector; //Stores the diference from the bone.GlobalMatrix to the center of the bone's bounding box
+    FBoundBoneDelta: TAffineVector;
+    // Stores the diference from the bone.GlobalMatrix to the center of the bone's bounding box
     FOrigin: TAffineVector;
     FSize: TAffineVector;
-    FBoneMatrix: TMatrix;
+    FBoneMatrix: TGLMatrix;
     FJoint: TGLRagdolJoint;
-    FOriginalMatrix: TMatrix; //Stores the Bone.GlobalMatrix before the ragdoll start
-    FReferenceMatrix: TMatrix; //Stores the first bone matrix to be used as reference
-    FAnchor: TAffineVector; //The position of the joint
+    FOriginalMatrix: TGLMatrix;
+    // Stores the Bone.GlobalMatrix before the ragdoll start
+    FReferenceMatrix: TGLMatrix;
+    // Stores the first bone matrix to be used as reference
+    FAnchor: TAffineVector; // The position of the joint
     procedure CreateBoundingBox;
     procedure SetAnchor(const Anchor: TAffineVector);
     procedure AlignToSkeleton;
@@ -62,60 +65,60 @@ type
     procedure UpdateChild;
     procedure StopChild;
   protected
-    function GetRagdollBone(Index: Integer) : TGLRagdolBone;
+    function GetRagdollBone(Index: Integer): TGLRagdolBone;
     procedure Start; virtual; abstract;
     procedure Align; virtual; abstract;
     procedure Update; virtual; abstract;
     procedure Stop; virtual; abstract;
   public
-    constructor CreateOwned(aOwner : TGLRagdolBoneList);
+    constructor CreateOwned(aOwner: TGLRagdolBoneList);
     constructor Create(Ragdoll: TGLRagdoll);
     destructor Destroy; override;
-    procedure WriteToFiler(writer : TVirtualWriter); override;
-    procedure ReadFromFiler(reader : TVirtualReader); override;
-    property Owner : TGLRagdolBoneList read FOwner;
-    property Name : String read FName write FName;
-    property BoneID : Integer read FBoneID write FBoneID;
-    property Origin : TAffineVector read FOrigin;
-    property Size : TAffineVector read FSize;
-    property BoneMatrix : TMatrix read FBoneMatrix;
-    property ReferenceMatrix : TMatrix read FReferenceMatrix;
-    property Anchor : TAffineVector read FAnchor;
-    property Joint : TGLRagdolJoint read FJoint write FJoint;
-    property Items[Index: Integer] : TGLRagdolBone read GetRagdollBone; default;
-	end;
+    procedure WriteToFiler(writer: TVirtualWriter); override;
+    procedure ReadFromFiler(reader: TVirtualReader); override;
+    property Owner: TGLRagdolBoneList read FOwner;
+    property Name: String read FName write FName;
+    property BoneID: Integer read FBoneID write FBoneID;
+    property Origin: TAffineVector read FOrigin;
+    property Size: TAffineVector read FSize;
+    property BoneMatrix: TGLMatrix read FBoneMatrix;
+    property ReferenceMatrix: TGLMatrix read FReferenceMatrix;
+    property Anchor: TAffineVector read FAnchor;
+    property Joint: TGLRagdolJoint read FJoint write FJoint;
+    property Items[Index: Integer]: TGLRagdolBone read GetRagdollBone; default;
+  end;
 
   TGLRagdoll = class(TPersistentObject)
-	private
-    FOwner : TGLBaseMesh;
-    FRootBone : TGLRagdolBone;
+  private
+    FOwner: TGLBaseMesh;
+    FRootBone: TGLRagdolBone;
     FEnabled: Boolean;
     FBuilt: Boolean;
   public
-    constructor Create(AOwner : TGLBaseMesh); reintroduce;
+    constructor Create(aOwner: TGLBaseMesh); reintroduce;
     destructor Destroy; override;
-    procedure WriteToFiler(writer : TVirtualWriter); override;
-    procedure ReadFromFiler(reader : TVirtualReader); override;
-    {Must be set before build the ragdoll }
+    procedure WriteToFiler(writer: TVirtualWriter); override;
+    procedure ReadFromFiler(reader: TVirtualReader); override;
+    // Must be set before build the ragdoll
     procedure SetRootBone(RootBone: TGLRagdolBone);
-    {Create the bounding box and setup the ragdoll do be started later }
+    // Create the bounding box and setup the ragdoll do be started later
     procedure BuildRagdoll;
     procedure Start;
     procedure Update;
     procedure Stop;
-    property Owner : TGLBaseMesh read FOwner;
-    property RootBone : TGLRagdolBone read FRootBone;
-    property Enabled : Boolean read FEnabled;
- end;
+    property Owner: TGLBaseMesh read FOwner;
+    property RootBone: TGLRagdolBone read FRootBone;
+    property Enabled: Boolean read FEnabled;
+  end;
 
-//------------------------------------------------------------------------	
+// ------------------------------------------------------------------------
 implementation
-//------------------------------------------------------------------------	
+// ------------------------------------------------------------------------
 
-uses
-  GLS.VectorTypes;
 
-{ TGLRagdolBoneList }
+//--------------------------
+// TGLRagdolBoneList
+//--------------------------
 
 constructor TGLRagdolBoneList.Create(Ragdoll: TGLRagdoll);
 begin
@@ -124,30 +127,34 @@ begin
 end;
 
 destructor TGLRagdolBoneList.Destroy;
-var i: integer;
+var
+  i: Integer;
 begin
-  for i:=0 to Count-1 do Items[i].Destroy;
+  for i := 0 to Count - 1 do
+    Items[i].Destroy;
   inherited;
 end;
 
 function TGLRagdolBoneList.GetRagdollBone(Index: Integer): TGLRagdolBone;
 begin
-  Result:=TGLRagdolBone(List^[Index]);
+  Result := TGLRagdolBone(List^[Index]);
 end;
 
 procedure TGLRagdolBoneList.ReadFromFiler(reader: TVirtualReader);
 begin
   inherited;
-  //Not implemented
+  // Not implemented
 end;
 
 procedure TGLRagdolBoneList.WriteToFiler(writer: TVirtualWriter);
 begin
   inherited;
-  //Not implemented
+  // Not implemented
 end;
 
-{ TGLRagdolBone }
+//----------------------------------
+// TGLRagdolBone
+//----------------------------------
 
 constructor TGLRagdolBone.Create(Ragdoll: TGLRagdoll);
 begin
@@ -157,54 +164,63 @@ end;
 procedure TGLRagdolBone.CreateBoundingBox;
 var
   bone: TGLSkeletonBone;
-  i, j: integer;
-  BoneVertices : TAffineVectorList;
-  BoneVertex, max,min: TAffineVector;
-  invMat, mat: TMatrix;
+  i, j: Integer;
+  BoneVertices: TAffineVectorList;
+  BoneVertex, max, min: TAffineVector;
+  invMat, mat: TGLMatrix;
 begin
   bone := Ragdoll.Owner.Skeleton.BoneByID(FBoneID);
 
-  //Get all vertices weighted to this bone
-  BoneVertices:=TAffineVectorList.Create;
-  for i:=0 to Ragdoll.Owner.MeshObjects.Count-1 do
-  with TGLSkeletonMeshObject(Ragdoll.Owner.MeshObjects[i]) do
-    for j:=0 to Vertices.Count-1 do
-      if bone.BoneID = VerticesBonesWeights[j][0].BoneID then
-        BoneVertices.FindOrAdd(Vertices[j]);
+  // Get all vertices weighted to this bone
+  BoneVertices := TAffineVectorList.Create;
+  for i := 0 to Ragdoll.Owner.MeshObjects.Count - 1 do
+    with TGLSkeletonMeshObject(Ragdoll.Owner.MeshObjects[i]) do
+      for j := 0 to Vertices.Count - 1 do
+        if bone.BoneID = VerticesBonesWeights[j][0].BoneID then
+          BoneVertices.FindOrAdd(Vertices[j]);
 
   invMat := bone.GlobalMatrix;
   InvertMatrix(invMat);
 
-  //For each vertex, get the max and min XYZ (Bounding box)
+  // For each vertex, get the max and min XYZ (Bounding box)
   if BoneVertices.Count > 0 then
   begin
     BoneVertex := VectorTransform(BoneVertices[0], invMat);
     max := BoneVertex;
     min := BoneVertex;
-    for i:=1 to BoneVertices.Count-1 do begin
+    for i := 1 to BoneVertices.Count - 1 do
+    begin
       BoneVertex := VectorTransform(BoneVertices[i], invMat);
-      if (BoneVertex.X > max.X) then max.X := BoneVertex.X;
-      if (BoneVertex.Y > max.Y) then max.Y := BoneVertex.Y;
-      if (BoneVertex.Z > max.Z) then max.Z := BoneVertex.Z;
-
-      if (BoneVertex.X < min.X) then min.X := BoneVertex.X;
-      if (BoneVertex.Y < min.Y) then min.Y := BoneVertex.Y;
-      if (BoneVertex.Z < min.Z) then min.Z := BoneVertex.Z;
+      if (BoneVertex.X > max.X) then
+        max.X := BoneVertex.X;
+      if (BoneVertex.Y > max.Y) then
+        max.Y := BoneVertex.Y;
+      if (BoneVertex.Z > max.Z) then
+        max.Z := BoneVertex.Z;
+
+      if (BoneVertex.X < min.X) then
+        min.X := BoneVertex.X;
+      if (BoneVertex.Y < min.Y) then
+        min.Y := BoneVertex.Y;
+      if (BoneVertex.Z < min.Z) then
+        min.Z := BoneVertex.Z;
     end;
 
     FBoundMax := max;
     FBoundMin := min;
-    //Get the origin and subtract from the bone matrix
+    // Get the origin and subtract from the bone matrix
     FBoundBoneDelta := VectorScale(VectorAdd(FBoundMax, FBoundMin), 0.5);
-  end else begin
+  end
+  else
+  begin
     FBoundMax := NullVector;
     FBoundMin := NullVector;
   end;
 
   AlignToSkeleton;
   FReferenceMatrix := FBoneMatrix;
-  mat := MatrixMultiply(bone.GlobalMatrix,FRagdoll.Owner.AbsoluteMatrix);
-  //Set Joint position
+  mat := MatrixMultiply(bone.GlobalMatrix, FRagdoll.Owner.AbsoluteMatrix);
+  // Set Joint position
   SetAnchor(AffineVectorMake(mat.V[3]));
 
   BoneVertices.Free; // NEW1
@@ -212,8 +228,8 @@ end;
 
 constructor TGLRagdolBone.CreateOwned(aOwner: TGLRagdolBoneList);
 begin
-	Create(aOwner.Ragdoll);
-  FOwner:=aOwner;
+  Create(aOwner.Ragdoll);
+  FOwner := aOwner;
   aOwner.Add(Self);
 end;
 
@@ -226,14 +242,14 @@ procedure TGLRagdolBone.AlignToSkeleton;
 var
   o: TAffineVector;
   bone: TGLSkeletonBone;
-  mat, posMat: TMatrix;
+  mat, posMat: TGLMatrix;
   noBounds: Boolean;
 begin
   bone := Ragdoll.Owner.Skeleton.BoneByID(FBoneID);
   noBounds := VectorIsNull(FBoundMax) and VectorIsNull(FBoundMin);
-  //Get the bone matrix relative to the Actor matrix
-  mat := MatrixMultiply(bone.GlobalMatrix,FRagdoll.Owner.AbsoluteMatrix);
-  //Set Rotation
+  // Get the bone matrix relative to the Actor matrix
+  mat := MatrixMultiply(bone.GlobalMatrix, FRagdoll.Owner.AbsoluteMatrix);
+  // Set Rotation
   FBoneMatrix := mat;
   NormalizeMatrix(FBoneMatrix);
 
@@ -241,25 +257,27 @@ begin
   begin
     FOrigin := AffineVectorMake(mat.V[3]);
     FSize := AffineVectorMake(0.1, 0.1, 0.1);
-  end else begin
-    //Set Origin
+  end
+  else
+  begin
+    // Set Origin
     posMat := mat;
     posMat.V[3] := NullHmgVector;
     o := VectorTransform(FBoundBoneDelta, posMat);
     FOrigin := VectorAdd(AffineVectorMake(mat.V[3]), o);
-    //Set Size
-    FSize := VectorScale(VectorSubtract(FBoundMax, FBoundMin),0.9);
-    FSize.X := FSize.X*VectorLength(mat.V[0]);
-    FSize.Y := FSize.Y*VectorLength(mat.V[1]);
-    FSize.Z := FSize.Z*VectorLength(mat.V[2]);
+    // Set Size
+    FSize := VectorScale(VectorSubtract(FBoundMax, FBoundMin), 0.9);
+    FSize.X := FSize.X * VectorLength(mat.V[0]);
+    FSize.Y := FSize.Y * VectorLength(mat.V[1]);
+    FSize.Z := FSize.Z * VectorLength(mat.V[2]);
   end;
-  //Put the origin in the BoneMatrix
-  FBoneMatrix.V[3] := VectorMake(FOrigin,1);
+  // Put the origin in the BoneMatrix
+  FBoneMatrix.V[3] := VectorMake(FOrigin, 1);
 end;
 
 function TGLRagdolBone.GetRagdollBone(Index: Integer): TGLRagdolBone;
 begin
-  Result:=TGLRagdolBone(List^[Index]);
+  Result := TGLRagdolBone(List^[Index]);
 end;
 
 procedure TGLRagdolBone.ReadFromFiler(reader: TVirtualReader);
@@ -269,40 +287,47 @@ begin
 end;
 
 procedure TGLRagdolBone.StartChild;
-var i: integer;
+var
+  i: Integer;
 begin
   FOriginalMatrix := Ragdoll.Owner.Skeleton.BoneByID(FBoneID).GlobalMatrix;
   AlignToSkeleton;
   Start;
-  for i := 0 to Count-1 do items[i].StartChild;
+  for i := 0 to Count - 1 do
+    Items[i].StartChild;
 end;
 
 procedure TGLRagdolBone.UpdateChild;
-var i: integer;
+var
+  i: Integer;
 begin
   Update;
-  for i := 0 to Count-1 do items[i].UpdateChild;
+  for i := 0 to Count - 1 do
+    Items[i].UpdateChild;
 end;
 
 procedure TGLRagdolBone.WriteToFiler(writer: TVirtualWriter);
 begin
   inherited;
-
 end;
 
 procedure TGLRagdolBone.StopChild;
-var i: integer;
+var
+  i: Integer;
 begin
   Stop;
   Ragdoll.Owner.Skeleton.BoneByID(FBoneID).SetGlobalMatrix(FOriginalMatrix);
-  for i := 0 to Count-1 do items[i].StopChild;
+  for i := 0 to Count - 1 do
+    Items[i].StopChild;
 end;
 
 procedure TGLRagdolBone.CreateBoundsChild;
-var i: integer;
+var
+  i: Integer;
 begin
   CreateBoundingBox;
-  for i := 0 to Count-1 do items[i].CreateBoundsChild;
+  for i := 0 to Count - 1 do
+    Items[i].CreateBoundsChild;
 end;
 
 procedure TGLRagdolBone.SetAnchor(const Anchor: TAffineVector);
@@ -311,25 +336,28 @@ begin
 end;
 
 procedure TGLRagdolBone.AlignChild;
-var i: integer;
+var
+  i: Integer;
 begin
   Align;
   Update;
-  for i := 0 to Count-1 do items[i].AlignChild;
+  for i := 0 to Count - 1 do
+    Items[i].AlignChild;
 end;
 
 { TGLRagdoll }
 
-constructor TGLRagdoll.Create(AOwner : TGLBaseMesh);
+constructor TGLRagdoll.Create(aOwner: TGLBaseMesh);
 begin
-  FOwner := AOwner;
+  FOwner := aOwner;
   FEnabled := False;
   FBuilt := False;
 end;
 
 destructor TGLRagdoll.Destroy;
 begin
-  if FEnabled then Stop;
+  if FEnabled then
+    Stop;
   inherited Destroy;
 end;
 
@@ -337,6 +365,7 @@ procedure TGLRagdoll.ReadFromFiler(reader: TVirtualReader);
 begin
   inherited;
 end;
+
 procedure TGLRagdoll.SetRootBone(RootBone: TGLRagdolBone);
 begin
   FRootBone := RootBone;
@@ -345,13 +374,14 @@ end;
 procedure TGLRagdoll.Start;
 begin
   Assert(FBuilt, 'First you need to build the ragdoll. BuildRagdoll;');
-  if (FEnabled) then Exit;
-  FEnabled:= True;
-  //First start the ragdoll in the reference position
+  if (FEnabled) then
+    Exit;
+  FEnabled := True;
+  // First start the ragdoll in the reference position
   RootBone.StartChild;
-  //Now align it to the animation
+  // Now align it to the animation
   RootBone.AlignChild;
-  //Now it recalculate the vertices to use as reference
+  // Now it recalculate the vertices to use as reference
   FOwner.Skeleton.StartRagDoll;
 end;
 
@@ -360,18 +390,19 @@ begin
   if FEnabled then
   begin
     RootBone.UpdateChild;
-    FOwner.Skeleton.MorphMesh(true);
+    FOwner.Skeleton.MorphMesh(True);
   end;
 end;
 
 procedure TGLRagdoll.Stop;
 begin
-  if not FEnabled then Exit;
+  if not FEnabled then
+    Exit;
   FEnabled := False;
   RootBone.StopChild;
-  //Restore the old information
+  // Restore the old information
   FOwner.Skeleton.StopRagDoll;
-  FOwner.Skeleton.MorphMesh(true);
+  FOwner.Skeleton.MorphMesh(True);
 end;
 
 procedure TGLRagdoll.WriteToFiler(writer: TVirtualWriter);
@@ -382,7 +413,8 @@ end;
 
 procedure TGLRagdoll.BuildRagdoll;
 begin
-  Assert(RootBone <> nil, 'First you need to set the root bone. SetRootBone();');
+  Assert(RootBone <> nil,
+    'First you need to set the root bone. SetRootBone();');
   RootBone.CreateBoundsChild;
   FBuilt := True;
 end;

+ 1 - 0
Source/GLS.RenderContextInfo.pas

@@ -11,6 +11,7 @@ interface
 
 uses
   GLS.PersistentClasses,
+  GLS.VectorTypes,
   GLS.VectorGeometry,
   GLS.State,
   GLS.PipelineTransformation,

+ 50 - 50
Source/GLS.Scene.pas

@@ -157,8 +157,8 @@ type
      move and delete them). Using the regular TComponent methods is not encouraged *)
   TGLBaseSceneObject = class(TGLCoordinatesUpdateAbleComponent)
   private
-    FAbsoluteMatrix, FInvAbsoluteMatrix: TMatrix;
-    FLocalMatrix: TMatrix;
+    FAbsoluteMatrix, FInvAbsoluteMatrix: TGLMatrix;
+    FLocalMatrix: TGLMatrix;
     FObjectStyle: TGLObjectStyles;
     FListHandle: TGLListHandle; // created on 1st use
     FPosition: TGLCoordinates;
@@ -200,7 +200,7 @@ type
     procedure SetIndex(aValue: Integer);
     procedure SetDirection(AVector: TGLCoordinates);
     procedure SetUp(AVector: TGLCoordinates);
-    function GetMatrix: PMatrix; inline;
+    function GetMatrix: PGLMatrix; inline;
     procedure SetPosition(APosition: TGLCoordinates);
     procedure SetPitchAngle(AValue: Single);
     procedure SetRollAngle(AValue: Single);
@@ -221,11 +221,11 @@ type
     function GetAbsoluteScale: TGLVector;
     procedure SetAbsoluteAffineScale(const Value: TAffineVector);
     procedure SetAbsoluteScale(const Value: TGLVector);
-    function GetAbsoluteMatrix: TMatrix; inline;
-    procedure SetAbsoluteMatrix(const Value: TMatrix);
+    function GetAbsoluteMatrix: TGLMatrix; inline;
+    procedure SetAbsoluteMatrix(const Value: TGLMatrix);
     procedure SetBBChanges(const Value: TGLObjectBBChanges);
-    function GetDirectAbsoluteMatrix: PMatrix;
-    function GetLocalMatrix: PMatrix; inline;
+    function GetDirectAbsoluteMatrix: PGLMatrix;
+    function GetLocalMatrix: PGLMatrix; inline;
   protected
     procedure Loaded; override;
     procedure SetScene(const Value: TGLScene); virtual;
@@ -286,34 +286,34 @@ type
     (* The local transformation (relative to parent).
        If you're *sure* the local matrix is up-to-date, you may use LocalMatrix
        for quicker access. *)
-    procedure SetMatrix(const aValue: TMatrix); inline;
-    property Matrix: PMatrix read GetMatrix;
+    procedure SetMatrix(const aValue: TGLMatrix); inline;
+    property Matrix: PGLMatrix read GetMatrix;
     (* Holds the local transformation (relative to parent).
        If you're not *sure* the local matrix is up-to-date, use Matrix property. *)
-    property LocalMatrix: PMatrix read GetLocalMatrix;
+    property LocalMatrix: PGLMatrix read GetLocalMatrix;
     (* Forces the local matrix to the specified value.
        AbsoluteMatrix, InverseMatrix, etc. will honour that change, but
        may become invalid if the specified matrix isn't orthonormal (can
        be used for specific rendering or projection effects).
        The local matrix will be reset by the next TransformationChanged,
        position or attitude change. *)
-    procedure ForceLocalMatrix(const aMatrix: TMatrix); inline;
+    procedure ForceLocalMatrix(const aMatrix: TGLMatrix); inline;
     // See AbsoluteMatrix.
-    function AbsoluteMatrixAsAddress: PMatrix;
+    function AbsoluteMatrixAsAddress: PGLMatrix;
     (* Holds the absolute transformation matrix.
        If you're not *sure* the absolute matrix is up-to-date,
        use the AbsoluteMatrix property, this one may be nil... *)
-    property DirectAbsoluteMatrix: PMatrix read GetDirectAbsoluteMatrix;
+    property DirectAbsoluteMatrix: PGLMatrix read GetDirectAbsoluteMatrix;
     (* Calculates the object's absolute inverse matrix.
        Multiplying an absolute coordinate with this matrix gives a local coordinate.
        The current implem uses transposition(AbsoluteMatrix), which is true
        unless you're using some scaling... *)
-    function InvAbsoluteMatrix: TMatrix; inline;
+    function InvAbsoluteMatrix: TGLMatrix; inline;
     //See InvAbsoluteMatrix.
-    function InvAbsoluteMatrixAsAddress: PMatrix;
+    function InvAbsoluteMatrixAsAddress: PGLMatrix;
     (* The object's absolute matrix by composing all local matrices.
        Multiplying a local coordinate with this matrix gives an absolute coordinate. *)
-    property AbsoluteMatrix: TMatrix read GetAbsoluteMatrix write SetAbsoluteMatrix;
+    property AbsoluteMatrix: TGLMatrix read GetAbsoluteMatrix write SetAbsoluteMatrix;
     // Direction vector in absolute coordinates.
     property AbsoluteDirection: TGLVector read GetAbsoluteDirection write SetAbsoluteDirection;
     property AbsoluteAffineDirection: TAffineVector read GetAbsoluteAffineDirection write SetAbsoluteAffineDirection;
@@ -1275,9 +1275,9 @@ type
     FRendering: Boolean;
     FRenderingContext: TGLContext;
     FAfterRenderEffects: TPersistentObjectList;
-    FViewMatrixStack: array of TMatrix;
-    FProjectionMatrixStack: array of TMatrix;
-    FBaseProjectionMatrix: TMatrix;
+    FViewMatrixStack: array of TGLMatrix;
+    FProjectionMatrixStack: array of TGLMatrix;
+    FBaseProjectionMatrix: TGLMatrix;
     FCameraAbsolutePosition: TGLVector;
     FViewPort: TRectangle;
     FSelector: TGLBaseSelectTechnique;
@@ -1444,22 +1444,22 @@ type
     // Adjusts background alpha channel.
     property BackgroundAlpha: Single read FBackgroundAlpha write SetBackgroundAlpha;
     // Returns the projection matrix in use or used for the last rendering.
-    function ProjectionMatrix: TMatrix; deprecated;
+    function ProjectionMatrix: TGLMatrix; deprecated;
     // Returns the view matrix in use or used for the last rendering.
-    function ViewMatrix: TMatrix; deprecated;
-    function ModelMatrix: TMatrix; deprecated;
+    function ViewMatrix: TGLMatrix; deprecated;
+    function ModelMatrix: TGLMatrix; deprecated;
     (* Returns the base projection matrix in use or used for the last rendering.
        The "base" projection is (as of now) either identity or the pick
        matrix, ie. it is the matrix on which the perspective or orthogonal
        matrix gets applied. *)
-    property BaseProjectionMatrix: TMatrix read FBaseProjectionMatrix;
+    property BaseProjectionMatrix: TGLMatrix read FBaseProjectionMatrix;
     (* Back up current View matrix and replace it with newMatrix.
        This method has no effect on the OpenGL matrix, only on the Buffer's
        matrix, and is intended for special effects rendering. *)
-    procedure PushViewMatrix(const newMatrix: TMatrix); deprecated;
+    procedure PushViewMatrix(const newMatrix: TGLMatrix); deprecated;
     // Restore a View matrix previously pushed.
     procedure PopViewMatrix; deprecated;
-    procedure PushProjectionMatrix(const newMatrix: TMatrix); deprecated;
+    procedure PushProjectionMatrix(const newMatrix: TGLMatrix); deprecated;
     procedure PopProjectionMatrix;  deprecated;
     (* Converts a screen pixel coordinate into 3D coordinates for orthogonal projection.
        This function accepts standard canvas coordinates, with (0,0) being
@@ -2175,7 +2175,7 @@ begin
   Result := FChildren.Count;
 end;
 
-function TGLBaseSceneObject.GetDirectAbsoluteMatrix: PMatrix;
+function TGLBaseSceneObject.GetDirectAbsoluteMatrix: PGLMatrix;
 begin
   Result := @FAbsoluteMatrix;
 end;
@@ -2255,7 +2255,7 @@ begin
   end;
 end;
 
-procedure TGLBaseSceneObject.ForceLocalMatrix(const aMatrix: TMatrix);
+procedure TGLBaseSceneObject.ForceLocalMatrix(const aMatrix: TGLMatrix);
 begin
   FLocalMatrix := aMatrix;
   Exclude(FChanges, ocTransformation);
@@ -2263,7 +2263,7 @@ begin
   Include(FChanges, ocInvAbsoluteMatrix);
 end;
 
-function TGLBaseSceneObject.AbsoluteMatrixAsAddress: PMatrix;
+function TGLBaseSceneObject.AbsoluteMatrixAsAddress: PGLMatrix;
 begin
   if ocAbsoluteMatrix in FChanges then
   begin
@@ -2281,12 +2281,12 @@ begin
   Result := @FAbsoluteMatrix;
 end;
 
-function TGLBaseSceneObject.InvAbsoluteMatrix: TMatrix;
+function TGLBaseSceneObject.InvAbsoluteMatrix: TGLMatrix;
 begin
   Result := InvAbsoluteMatrixAsAddress^;
 end;
 
-function TGLBaseSceneObject.InvAbsoluteMatrixAsAddress: PMatrix;
+function TGLBaseSceneObject.InvAbsoluteMatrixAsAddress: PGLMatrix;
 begin
   if ocInvAbsoluteMatrix in FChanges then
   begin
@@ -2310,12 +2310,12 @@ begin
   Result := @FInvAbsoluteMatrix;
 end;
 
-function TGLBaseSceneObject.GetAbsoluteMatrix: TMatrix;
+function TGLBaseSceneObject.GetAbsoluteMatrix: TGLMatrix;
 begin
   Result := AbsoluteMatrixAsAddress^;
 end;
 
-procedure TGLBaseSceneObject.SetAbsoluteMatrix(const Value: TMatrix);
+procedure TGLBaseSceneObject.SetAbsoluteMatrix(const Value: TGLMatrix);
 begin
   if not MatrixEquals(Value, FAbsoluteMatrix) then
   begin
@@ -2852,7 +2852,7 @@ end;
 
 procedure TGLBaseSceneObject.ResetRotations;
 begin
-  FillChar(FLocalMatrix, SizeOf(TMatrix), 0);
+  FillChar(FLocalMatrix, SizeOf(TGLMatrix), 0);
   FLocalMatrix.X.X := Scale.DirectX;
   FLocalMatrix.Y.Y := Scale.DirectY;
   FLocalMatrix.Z.Z := Scale.DirectZ;
@@ -2866,7 +2866,7 @@ end;
 
 procedure TGLBaseSceneObject.ResetAndPitchTurnRoll(const degX, degY, degZ: Single);
 var
-  rotMatrix: TMatrix;
+  rotMatrix: TGLMatrix;
   V: TGLVector;
 begin
   ResetRotations;
@@ -2903,7 +2903,7 @@ end;
 
 procedure TGLBaseSceneObject.RotateAbsolute(const rx, ry, rz: Single);
 var
-  resMat: TMatrix;
+  resMat: TGLMatrix;
   v: TAffineVector;
 begin
   resMat := Matrix^;
@@ -2966,7 +2966,7 @@ end;
 procedure TGLBaseSceneObject.SetPitchAngle(AValue: Single);
 var
   diff: Single;
-  rotMatrix: TMatrix;
+  rotMatrix: TGLMatrix;
 begin
   if AValue <> FRotation.X then
   begin
@@ -3024,7 +3024,7 @@ end;
 procedure TGLBaseSceneObject.SetRollAngle(AValue: Single);
 var
   diff: Single;
-  rotMatrix: TMatrix;
+  rotMatrix: TGLMatrix;
 begin
   if AValue <> FRotation.Z then
   begin
@@ -3077,7 +3077,7 @@ end;
 procedure TGLBaseSceneObject.SetTurnAngle(AValue: Single);
 var
   diff: Single;
-  rotMatrix: TMatrix;
+  rotMatrix: TGLMatrix;
 begin
   if AValue <> FRotation.Y then
   begin
@@ -3188,7 +3188,7 @@ begin
     Result := -1;
 end;
 
-function TGLBaseSceneObject.GetLocalMatrix: PMatrix;
+function TGLBaseSceneObject.GetLocalMatrix: PGLMatrix;
 begin
   Result := @FLocalMatrix;
 end;
@@ -3859,13 +3859,13 @@ begin
     FScene.NotifyChange(Self);
 end;
 
-function TGLBaseSceneObject.GetMatrix: PMatrix;
+function TGLBaseSceneObject.GetMatrix: PGLMatrix;
 begin
   RebuildMatrix;
   Result := @FLocalMatrix;
 end;
 
-procedure TGLBaseSceneObject.SetMatrix(const aValue: TMatrix);
+procedure TGLBaseSceneObject.SetMatrix(const aValue: TGLMatrix);
 begin
   FLocalMatrix := aValue;
   FDirection.DirectVector := VectorNormalize(FLocalMatrix.Z);
@@ -4459,7 +4459,7 @@ procedure TGLCamera.Apply;
 var
   v, d, v2: TGLVector;
   absPos: TGLVector;
-  LM, mat: TMatrix;
+  LM, mat: TGLMatrix;
 begin
   if Assigned(FDeferredApply) then
     FDeferredApply(Self)
@@ -4499,7 +4499,7 @@ var
   vLeft, vRight, vBottom, vTop, vFar: Single;
   MaxDim, Ratio, f: Double;
   xmax, ymax: Double;
-  mat: TMatrix;
+  mat: TGLMatrix;
 const
   cEpsilon: Single = 1e-4;
 
@@ -4723,7 +4723,7 @@ end;
 procedure TGLCamera.RotateObject(obj: TGLBaseSceneObject; pitchDelta, turnDelta: Single;
   rollDelta: Single = 0);
 var
-  resMat: TMatrix;
+  resMat: TGLMatrix;
   vDir, vUp, vRight: TGLVector;
   v: TAffineVector;
   position1: TGLVector;
@@ -6806,7 +6806,7 @@ begin
   FFirstPerfCounter := 0;
 end;
 
-procedure TGLSceneBuffer.PushViewMatrix(const newMatrix: TMatrix);
+procedure TGLSceneBuffer.PushViewMatrix(const newMatrix: TGLMatrix);
 var
   n: Integer;
 begin
@@ -6826,7 +6826,7 @@ begin
   SetLength(FViewMatrixStack, n);
 end;
 
-procedure TGLSceneBuffer.PushProjectionMatrix(const newMatrix: TMatrix);
+procedure TGLSceneBuffer.PushProjectionMatrix(const newMatrix: TGLMatrix);
 var
   n: Integer;
 begin
@@ -6851,12 +6851,12 @@ begin
   Result := RenderingContext.PipelineTransformation.ProjectionMatrix^;
 end;
 
-function TGLSceneBuffer.ViewMatrix: TMatrix;
+function TGLSceneBuffer.ViewMatrix: TGLMatrix;
 begin
   Result := RenderingContext.PipelineTransformation.ViewMatrix^;
 end;
 
-function TGLSceneBuffer.ModelMatrix: TMatrix;
+function TGLSceneBuffer.ModelMatrix: TGLMatrix;
 begin
   Result := RenderingContext.PipelineTransformation.ModelMatrix^;
 end;
@@ -7803,7 +7803,7 @@ procedure TGLNonVisualViewer.SetupCubeMapCamera(Sender: TObject);
 
 {
 const
-  cFaceMat: array[0..5] of TMatrix =
+  cFaceMat: array[0..5] of TGLMatrix =
   (
     (X: (X:0; Y:0; Z:-1; W:0);
      Y: (X:0; Y:-1; Z:0; W:0);
@@ -7833,7 +7833,7 @@ const
 }
 
 var
-  TM: TMatrix;
+  TM: TGLMatrix;
 begin
   // Setup appropriate FOV
   with CurrentGLContext.PipelineTransformation do

+ 2 - 2
Source/GLS.ShadowPlane.pas

@@ -130,10 +130,10 @@ procedure TGLShadowPlane.DoRender(var ARci: TGLRenderContextInfo;
   ARenderSelf, ARenderChildren: Boolean);
 var
   oldProxySubObject, oldIgnoreMaterials: Boolean;
-  shadowMat: TMatrix;
+  shadowMat: TGLMatrix;
   sr, ds: TRect;
   CurrentBuffer: TGLSceneBuffer;
-  ModelMat: TMatrix;
+  ModelMat: TGLMatrix;
 begin
   if FRendering then
     Exit;

+ 2 - 2
Source/GLS.ShadowVolume.pas

@@ -363,7 +363,7 @@ end;
 function TGLShadowVolumeLight.SetupScissorRect(worldAABB: PAABB; var rci:
   TGLRenderContextInfo): Boolean;
 var
-  mvp: TMatrix;
+  mvp: TGLMatrix;
   ls: TGLLightSource;
   aabb: TAABB;
   clipRect: TClipRect;
@@ -622,7 +622,7 @@ var
   silParams: TGLSilhouetteParameters;
   worldAABB: TAABB;
   pWorldAABB: PAABB;
-  PM: TMatrix;
+  PM: TGLMatrix;
 begin
   if not Active then
   begin

+ 1 - 1
Source/GLS.SpaceText.pas

@@ -1,7 +1,6 @@
 //
 // The graphics rendering engine GLScene http://glscene.org
 //
-
 unit GLS.SpaceText;
 
 (*
@@ -31,6 +30,7 @@ uses
   VCL.Graphics,
   VCL.Controls,
 
+  GLS.VectorTypes,
   GLS.OpenGLTokens,
   GLS.Scene,
   GLS.Texture,

+ 1 - 1
Source/GLS.Spline.pas

@@ -1,7 +1,6 @@
 //
 // The graphics rendering engine GLScene http://glscene.org
 //
-
 unit GLS.Spline;
 
 (* Cubic spline interpolation functions *)
@@ -9,6 +8,7 @@ unit GLS.Spline;
 interface
 
 uses
+  GLS.VectorTypes,
   GLS.VectorGeometry;
 
 {$I GLScene.inc}

+ 2 - 2
Source/GLS.State.pas

@@ -893,7 +893,7 @@ type
     // Call display list
     procedure CallList(list: Cardinal); inline;
     // Defines the OpenGL texture matrix. Assumed texture mode is GL_MODELVIEW.
-    procedure SetGLTextureMatrix(const matrix: TMatrix); inline;
+    procedure SetGLTextureMatrix(const matrix: TGLMatrix); inline;
     procedure ResetGLTextureMatrix; inline;
     procedure ResetAllGLTextureMatrix; inline;
     // note: needs to change to per draw-buffer
@@ -2167,7 +2167,7 @@ begin
   end;
 end;
 
-procedure TGLStateCache.SetGLTextureMatrix(const matrix: TMatrix);
+procedure TGLStateCache.SetGLTextureMatrix(const matrix: TGLMatrix);
 begin
   { if FForwardContext then
     exit; }

+ 7 - 7
Source/GLS.Texture.pas

@@ -471,12 +471,12 @@ type
     procedure Apply(var rci: TGLRenderContextInfo);
     procedure UnApply(var rci: TGLRenderContextInfo);
     // Applies to TEXTURE1
-    procedure ApplyAsTexture2(var rci: TGLRenderContextInfo; textureMatrix: PMatrix = nil);
+    procedure ApplyAsTexture2(var rci: TGLRenderContextInfo; textureMatrix: PGLMatrix = nil);
     procedure UnApplyAsTexture2(var rci: TGLRenderContextInfo;
       reloadIdentityTextureMatrix: boolean);
     // N=1 for TEXTURE0, N=2 for TEXTURE1, etc.
     procedure ApplyAsTextureN(n: Integer; var rci: TGLRenderContextInfo;
-      textureMatrix: PMatrix = nil);
+      textureMatrix: PGLMatrix = nil);
     procedure UnApplyAsTextureN(n: Integer; var rci: TGLRenderContextInfo;
       reloadIdentityTextureMatrix: boolean);
     procedure Assign(Source: TPersistent); override;
@@ -616,7 +616,7 @@ type
     FTextureIndex: Integer;
     FTextureOffset, FTextureScale: TGLCoordinates;
     FTextureMatrixIsIdentity: Boolean;
-    FTextureMatrix: TMatrix;
+    FTextureMatrix: TGLMatrix;
     FApplied: Boolean;
     // Implementing IInterface
     function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
@@ -2393,7 +2393,7 @@ procedure TGLTexture.Apply(var rci: TGLRenderContextInfo);
 
   procedure SetCubeMapTextureMatrix;
   var
-    m, mm: TMatrix;
+    m, mm: TGLMatrix;
   begin
     // compute model view matrix for proper viewing
     case MappingMode of
@@ -2487,7 +2487,7 @@ begin
 end;
 
 procedure TGLTexture.ApplyAsTexture2(var rci: TGLRenderContextInfo; textureMatrix:
-  PMatrix = nil);
+  PGLMatrix = nil);
 begin
   ApplyAsTextureN(2, rci, textureMatrix);
 end;
@@ -2499,9 +2499,9 @@ begin
 end;
 
 procedure TGLTexture.ApplyAsTextureN(n: Integer; var rci: TGLRenderContextInfo;
-  textureMatrix: PMatrix = nil);
+  textureMatrix: PGLMatrix = nil);
 var
-  m: TMatrix;
+  m: TGLMatrix;
 begin
   if not Disabled then
   begin

+ 1 - 1
Source/GLS.ThorFX.pas

@@ -468,7 +468,7 @@ var
   distList: TSingleList;
   objList: TList;
   fp: PThorpoint;
-  mat: TMatrix;
+  mat: TGLMatrix;
 
   vx, vy: TGLVector;
   m: integer;

+ 8 - 8
Source/GLS.Tree.pas

@@ -61,7 +61,7 @@ type
    constructor Create(AOwner: TGLTree);
     destructor Destroy; override;
     procedure BuildList(var rci: TGLRenderContextInfo);
-    procedure AddNew(matrix: TMatrix);
+    procedure AddNew(matrix: TGLMatrix);
     procedure Clear;
     property Owner: TGLTree read FOwner;
     property Count: Integer read FCount;
@@ -79,12 +79,12 @@ type
     FParent: TGLTreeBranch;
     FBranchID: Integer;
     FParentID: Integer;
-    FMatrix: TMatrix;
+    FMatrix: TGLMatrix;
     FLower: TIntegerList;
     FUpper: TIntegerList;
     FCentralLeader: Boolean;
     procedure BuildBranch(branchNoise: TGLTreeBranchNoise;
-      const matrix: TMatrix; TexCoordY, Twist: Single; Level: Integer);
+      const matrix: TGLMatrix; TexCoordY, Twist: Single; Level: Integer);
   public
     constructor Create(AOwner: TGLTreeBranches; AParent: TGLTreeBranch);
     destructor Destroy; override;
@@ -93,7 +93,7 @@ type
     property Center: TGLTreeBranch read FCenter;
     property Right: TGLTreeBranch read FRight;
     property Parent: TGLTreeBranch read FParent;
-    property matrix: TMatrix read FMatrix;
+    property matrix: TGLMatrix read FMatrix;
     property Lower: TIntegerList read FLower;
     property Upper: TIntegerList read FUpper;
   end;
@@ -284,7 +284,7 @@ begin
   inherited;
 end;
 
-procedure TGLTreeLeaves.AddNew(matrix: TMatrix);
+procedure TGLTreeLeaves.AddNew(matrix: TGLMatrix);
 var
   radius: Single;
   pos: TGLVector;
@@ -400,7 +400,7 @@ begin
 end;
 
 procedure TGLTreeBranch.BuildBranch(branchNoise: TGLTreeBranchNoise;
-  const matrix: TMatrix; TexCoordY, Twist: Single; Level: Integer);
+  const matrix: TGLMatrix; TexCoordY, Twist: Single; Level: Integer);
 var
   i: Integer;
   Tree: TGLTree;
@@ -414,7 +414,7 @@ var
   LeftBranchNoise: TGLTreeBranchNoise;
   CenterBranchNoise: TGLTreeBranchNoise;
   RightBranchNoise: TGLTreeBranchNoise;
-  LeftMatrix, RightMatrix, CenterMatrix: TMatrix;
+  LeftMatrix, RightMatrix, CenterMatrix: TGLMatrix;
   central_leader: Boolean;
 begin
   Assert(Assigned(FOwner), 'Incorrect use of TGLTreeBranch');
@@ -839,7 +839,7 @@ procedure TGLTree.BuildMesh(GLBaseMesh: TGLBaseMesh);
     Frame: TGLSkeletonFrame);
   var
     trans: TTransformations;
-    mat: TMatrix;
+    mat: TGLMatrix;
     rot, pos: TAffineVector;
   begin
     bone.Name := 'Branch' + IntToStr(Branch.FBranchID);

+ 32 - 32
Source/GLS.VectorFileObjects.pas

@@ -179,7 +179,7 @@ type
   private
     FSkeleton: TGLSkeleton; // not persistent
   protected
-    FGlobalMatrix: TMatrix;
+    FGlobalMatrix: TGLMatrix;
     function GetSkeletonBone(Index: Integer): TGLSkeletonBone;
     procedure AfterObjectCreatedByReader(Sender: TObject); override;
   public
@@ -208,7 +208,7 @@ type
     procedure ReadFromFiler(reader: TVirtualReader); override;
     // Render skeleton wireframe
     procedure BuildList(var mrci: TGLRenderContextInfo); override;
-    property GlobalMatrix: TMatrix read FGlobalMatrix write FGlobalMatrix;
+    property GlobalMatrix: TGLMatrix read FGlobalMatrix write FGlobalMatrix;
   end;
 
   (* A skeleton bone or node and its children.
@@ -241,16 +241,16 @@ type
     function BoneByID(anID: Integer): TGLSkeletonBone; override;
     function BoneByName(const aName: string): TGLSkeletonBone; override;
     // Set the bone's matrix. Becareful using this.
-    procedure SetGlobalMatrix(const Matrix: TMatrix); // Ragdoll
+    procedure SetGlobalMatrix(const Matrix: TGLMatrix); // Ragdoll
     // Set the bone's GlobalMatrix. Used for Ragdoll.
-    procedure SetGlobalMatrixForRagDoll(const RagDollMatrix: TMatrix); // Ragdoll
+    procedure SetGlobalMatrixForRagDoll(const RagDollMatrix: TGLMatrix); // Ragdoll
     (* Calculates the global matrix for the bone and its sub-bone.
       Call this function directly only the RootBone. *)
     procedure PrepareGlobalMatrices; override;
     (* Global Matrix for the bone in the current frame.
       Global matrices must be prepared by invoking PrepareGlobalMatrices
       on the root bone. *)
-    property GlobalMatrix: TMatrix read FGlobalMatrix;
+    property GlobalMatrix: TGLMatrix read FGlobalMatrix;
     // Free all sub bones and reset BoneID and Name.
     procedure Clean; override;
   end;
@@ -266,11 +266,11 @@ type
     FOwner: TGLSkeletonColliderList;
     FBone: TGLSkeletonBone;
     FBoneID: Integer;
-    FLocalMatrix, FGlobalMatrix: TMatrix;
+    FLocalMatrix, FGlobalMatrix: TGLMatrix;
     FAutoUpdate: Boolean;
   protected
     procedure SetBone(const val: TGLSkeletonBone);
-    procedure SetLocalMatrix(const val: TMatrix);
+    procedure SetLocalMatrix(const val: TGLMatrix);
   public
     constructor Create; override;
     constructor CreateOwned(AOwner: TGLSkeletonColliderList);
@@ -284,10 +284,10 @@ type
     // The bone that this collider associates with.
     property Bone: TGLSkeletonBone read FBone write SetBone;
     // Offset and orientation of the collider in the associated bone's space.
-    property LocalMatrix: TMatrix read FLocalMatrix write SetLocalMatrix;
+    property LocalMatrix: TGLMatrix read FLocalMatrix write SetLocalMatrix;
     (* Global offset and orientation of the collider.
       This gets set in the AlignCollider method. *)
-    property GlobalMatrix: TMatrix read FGlobalMatrix;
+    property GlobalMatrix: TGLMatrix read FGlobalMatrix;
     property AutoUpdate: Boolean read FAutoUpdate write FAutoUpdate;
   end;
 
@@ -693,7 +693,7 @@ type
     property Owner: TGLFaceGroups read FOwner write FOwner;
     property MaterialName: string read FMaterialName write FMaterialName;
     property MaterialCache: TGLLibMaterial read FMaterialCache;
-    { Index of lightmap in the lightmap library. }
+    // Index of lightmap in the lightmap library.
     property LightMapIndex: Integer read FLightMapIndex write FLightMapIndex;
   end;
 
@@ -840,7 +840,7 @@ type
     procedure SaveToStream(aStream: TStream); override;
   end;
 
-  // Base class for mesh objects. 
+  // Base class for mesh objects.
   TGLBaseMesh = class(TGLSceneObject)
   private
     FNormalsOrientation: TGLMeshNormalsOrientation;
@@ -903,7 +903,7 @@ type
       rendering, reduced performance and/or invalid bounding box data
       (ie. invalid collision detection). Use with caution. *)
     procedure StructureChangedNoPrepare;
-    // BEWARE! Utterly inefficient implementation! 
+    // BEWARE! Utterly inefficient implementation!
     function RayCastIntersect(const rayStart, rayVector: TGLVector; intersectPoint: PGLVector = nil;
 	  intersectNormal: PGLVector = nil): Boolean; override;
     function GenerateSilhouette(const silhouetteParameters: TGLSilhouetteParameters): TGLSilhouette; override;
@@ -964,10 +964,10 @@ type
       If you want to alter mesh data, use direct manipulation methods
       (on the TMeshObjects). *)
     property AutoScaling: TGLCoordinates read FAutoScaling write FAutoScaling;
-    { Material library where mesh materials will be stored/retrieved.
+    (* Material library where mesh materials will be stored/retrieved.
       If this property is not defined or if UseMeshMaterials is false,
       only the FreeForm's material will be used (and the mesh's materials
-      will be ignored. }
+      will be ignored. *)
     property MaterialLibrary: TGLMaterialLibrary read FMaterialLibrary write SetMaterialLibrary;
     (* Defines wether materials declared in the vector file mesh are used.
       You must also define the MaterialLibrary property. *)
@@ -981,10 +981,10 @@ type
       Implementation is up to the file loader class (ie. this property
       may be ignored by some loaders) *)
     property IgnoreMissingTextures: Boolean read FIgnoreMissingTextures write FIgnoreMissingTextures default False;
-    // Normals orientation for owned mesh. 
+    // Normals orientation for owned mesh.
     property NormalsOrientation: TGLMeshNormalsOrientation read FNormalsOrientation
 	   write SetNormalsOrientation default mnoDefault;
-    // Request rendering of skeleton bones over the mesh. 
+    // Request rendering of skeleton bones over the mesh.
     property OverlaySkeleton: Boolean read FOverlaySkeleton write SetOverlaySkeleton default False;
   end;
 
@@ -1007,10 +1007,10 @@ type
     (* Returns true if Point is inside the free form - this will only work
       properly on closed meshes. Requires that Octree has been prepared. *)
     function OctreePointInMesh(const Point: TGLVector): Boolean;
-    function OctreeAABBIntersect(const AABB: TAABB; objMatrix, invObjMatrix: TMatrix;
+    function OctreeAABBIntersect(const AABB: TAABB; objMatrix, invObjMatrix: TGLMatrix;
       triangles: TAffineVectorList = nil): Boolean;
     // TODO:  function OctreeSphereIntersect
-    // Octree support *experimental*. Use only if you understand what you're doing! 
+    // Octree support *experimental*. Use only if you understand what you're doing!
     property Octree: TGLOctree read FOctree;
     procedure BuildOctree(TreeDepth: Integer = 3);
   published
@@ -1870,7 +1870,7 @@ function TGLSkeletonFrame.LocalMatrixList: PMatrixArray;
 var
   i: Integer;
   s, c: Single;
-  mat, rmat: TMatrix;
+  mat, rmat: TGLMatrix;
   quat: TQuaternion;
 begin
   if not Assigned(FLocalMatrixList) then
@@ -1878,7 +1878,7 @@ begin
     case FTransformMode of
       sftRotation:
         begin
-          FLocalMatrixList := AllocMem(SizeOf(TMatrix) * Rotation.Count);
+          FLocalMatrixList := AllocMem(SizeOf(TGLMatrix) * Rotation.Count);
           for i := 0 to Rotation.Count - 1 do
           begin
             if Rotation[i].X <> 0 then
@@ -1908,7 +1908,7 @@ begin
         end;
       sftQuaternion:
         begin
-          FLocalMatrixList := AllocMem(SizeOf(TMatrix) * Quaternion.Count);
+          FLocalMatrixList := AllocMem(SizeOf(TGLMatrix) * Quaternion.Count);
           for i := 0 to Quaternion.Count - 1 do
           begin
             quat := Quaternion[i];
@@ -1938,7 +1938,7 @@ procedure TGLSkeletonFrame.ConvertQuaternionsToRotations(KeepQuaternions: Boolea
 var
   i: Integer;
   t: TTransformations;
-  m: TMatrix;
+  m: TGLMatrix;
 begin
   Rotation.Clear;
   for i := 0 to Quaternion.Count - 1 do
@@ -1956,7 +1956,7 @@ end;
 procedure TGLSkeletonFrame.ConvertRotationsToQuaternions(KeepRotations: Boolean = True);
 var
   i: Integer;
-  mat, rmat: TMatrix;
+  mat, rmat: TGLMatrix;
   s, c: Single;
 begin
   Quaternion.Clear;
@@ -2323,12 +2323,12 @@ begin
   inherited;
 end;
 
-procedure TGLSkeletonBone.SetGlobalMatrix(const Matrix: TMatrix); // ragdoll
+procedure TGLSkeletonBone.SetGlobalMatrix(const Matrix: TGLMatrix); // ragdoll
 begin
   FGlobalMatrix := Matrix;
 end;
 
-procedure TGLSkeletonBone.SetGlobalMatrixForRagDoll(const RagDollMatrix: TMatrix);
+procedure TGLSkeletonBone.SetGlobalMatrixForRagDoll(const RagDollMatrix: TGLMatrix);
 // ragdoll
 begin
   FGlobalMatrix := MatrixMultiply(RagDollMatrix,
@@ -2366,7 +2366,7 @@ begin
       WriteInteger(FBone.BoneID)
     else
       WriteInteger(-1);
-    Write(FLocalMatrix, SizeOf(TMatrix));
+    Write(FLocalMatrix, SizeOf(TGLMatrix));
   end;
 end;
 
@@ -2380,7 +2380,7 @@ begin
     with reader do
     begin
       FBoneID := ReadInteger;
-      Read(FLocalMatrix, SizeOf(TMatrix));
+      Read(FLocalMatrix, SizeOf(TGLMatrix));
     end
   else
     RaiseFilerException(archiveVersion);
@@ -2388,7 +2388,7 @@ end;
 
 procedure TGLSkeletonCollider.AlignCollider;
 var
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
   if Assigned(FBone) then
   begin
@@ -2410,7 +2410,7 @@ begin
     FBone := val;
 end;
 
-procedure TGLSkeletonCollider.SetLocalMatrix(const val: TMatrix);
+procedure TGLSkeletonCollider.SetLocalMatrix(const val: TGLMatrix);
 begin
   FLocalMatrix := val;
 end;
@@ -4910,7 +4910,7 @@ procedure TGLSkeletonMeshObject.PrepareBoneMatrixInvertedMeshes;
 var
   i, k, boneIndex: Integer;
   invMesh: TGLBaseMeshObject;
-  invMat: TMatrix;
+  invMat: TGLMatrix;
   Bone: TGLSkeletonBone;
   p: TGLVector;
 begin
@@ -6638,10 +6638,10 @@ begin
   Result := Octree.TriangleIntersect(t1, t2, t3);
 end;
 
-function TGLFreeForm.OctreeAABBIntersect(const AABB: TAABB; objMatrix, invObjMatrix: TMatrix;
+function TGLFreeForm.OctreeAABBIntersect(const AABB: TAABB; objMatrix, invObjMatrix: TGLMatrix;
   triangles: TAffineVectorList = nil): Boolean;
 var
-  m1to2, m2to1: TMatrix;
+  m1to2, m2to1: TGLMatrix;
 begin
   Assert(Assigned(FOctree), strOctreeMustBePreparedBeforeUse);
 

+ 126 - 128
Source/GLS.VectorGeometry.pas

@@ -141,8 +141,6 @@ type
   PVector2f = ^TVector2f;
 
   // some simplified names
-///  PGLVector = ^TGLVector;
-  TGLVector = THomogeneousFltVector;
 
   PHomogeneousVector = ^THomogeneousVector;
   THomogeneousVector = THomogeneousFltVector;
@@ -178,10 +176,10 @@ type
   TAffineExtMatrix = array [0 .. 2] of TAffineExtVector;
 
   // Some simplified names
-  PMatrix = ^TMatrix;
-  TMatrix = THomogeneousFltMatrix;
+///  PGLMatrix = ^TGLMatrix;
+///  TGLMatrix = THomogeneousFltMatrix;
 
-  TMatrixArray = array [0 .. MaxInt shr 7] of TMatrix;
+  TMatrixArray = array [0 .. MaxInt shr 7] of TGLMatrix;
   PMatrixArray = ^TMatrixArray;
 
   PHomogeneousMatrix = ^THomogeneousMatrix;
@@ -272,14 +270,14 @@ const
 
   IdentityMatrix: TAffineMatrix = (V: ((X: 1; Y: 0; Z: 0), (X: 0; Y: 1;
     Z: 0), (X: 0; Y: 0; Z: 1)));
-  IdentityHmgMatrix: TMatrix = (V: ((X: 1; Y: 0; Z: 0; W: 0), (X: 0; Y: 1; Z: 0;
+  IdentityHmgMatrix: TGLMatrix = (V: ((X: 1; Y: 0; Z: 0; W: 0), (X: 0; Y: 1; Z: 0;
     W: 0), (X: 0; Y: 0; Z: 1; W: 0), (X: 0; Y: 0; Z: 0; W: 1)));
   IdentityHmgDblMatrix: THomogeneousDblMatrix = (V: ((X: 1; Y: 0; Z: 0;
     W: 0), (X: 0; Y: 1; Z: 0; W: 0), (X: 0; Y: 0; Z: 1; W: 0), (X: 0; Y: 0;
     Z: 0; W: 1)));
   EmptyMatrix: TAffineMatrix = (V: ((X: 0; Y: 0; Z: 0), (X: 0; Y: 0;
     Z: 0), (X: 0; Y: 0; Z: 0)));
-  EmptyHmgMatrix: TMatrix = (V: ((X: 0; Y: 0; Z: 0; W: 0), (X: 0; Y: 0; Z: 0;
+  EmptyHmgMatrix: TGLMatrix = (V: ((X: 0; Y: 0; Z: 0; W: 0), (X: 0; Y: 0; Z: 0;
     W: 0), (X: 0; Y: 0; Z: 0; W: 0), (X: 0; Y: 0; Z: 0; W: 0)));
 
 
@@ -594,7 +592,7 @@ function Lerp(const start, stop, T: Single): Single; inline;
 function AngleLerp(start, stop, T: Single): Single; inline;
 (* This is used for interpolating between 2 matrices. The result
   is used to reposition the model parts each frame. *)
-function MatrixLerp(const m1, m2: TMatrix; const delta: Single): TMatrix;
+function MatrixLerp(const m1, m2: TGLMatrix; const delta: Single): TGLMatrix;
 
 (* Calculates the angular distance between two angles in radians.
   Result is in the [0; PI] range. *)
@@ -817,84 +815,84 @@ function IsColinear(const V1, V2: TGLVector): Boolean; overload;
 (* ----------------------------------------------------------------------------
   Matrix functions
  ---------------------------------------------------------------------------- *)
-procedure SetMatrix(var dest: THomogeneousDblMatrix; const src: TMatrix); overload;
-procedure SetMatrix(var dest: TAffineMatrix; const src: TMatrix); overload;
-procedure SetMatrix(var dest: TMatrix; const src: TAffineMatrix); overload;
-procedure SetMatrixRow(var dest: TMatrix; rowNb: Integer; const aRow: TGLVector); overload;
+procedure SetMatrix(var dest: THomogeneousDblMatrix; const src: TGLMatrix); overload;
+procedure SetMatrix(var dest: TAffineMatrix; const src: TGLMatrix); overload;
+procedure SetMatrix(var dest: TGLMatrix; const src: TAffineMatrix); overload;
+procedure SetMatrixRow(var dest: TGLMatrix; rowNb: Integer; const aRow: TGLVector); overload;
 
 // Creates scale matrix
-function CreateScaleMatrix(const V: TAffineVector): TMatrix; overload;
+function CreateScaleMatrix(const V: TAffineVector): TGLMatrix; overload;
 // Creates scale matrix
-function CreateScaleMatrix(const V: TGLVector): TMatrix; overload;
+function CreateScaleMatrix(const V: TGLVector): TGLMatrix; overload;
 // Creates translation matrix
-function CreateTranslationMatrix(const V: TAffineVector): TMatrix; overload;
+function CreateTranslationMatrix(const V: TAffineVector): TGLMatrix; overload;
 // Creates translation matrix
-function CreateTranslationMatrix(const V: TGLVector): TMatrix; overload;
+function CreateTranslationMatrix(const V: TGLVector): TGLMatrix; overload;
 { Creates a scale+translation matrix.
   Scale is applied BEFORE applying offset }
-function CreateScaleAndTranslationMatrix(const scale, offset: TGLVector): TMatrix; overload;
+function CreateScaleAndTranslationMatrix(const scale, offset: TGLVector): TGLMatrix; overload;
 // Creates matrix for rotation about x-axis (angle in rad)
-function CreateRotationMatrixX(const sine, cosine: Single): TMatrix; overload;
-function CreateRotationMatrixX(const angle: Single): TMatrix; overload;
+function CreateRotationMatrixX(const sine, cosine: Single): TGLMatrix; overload;
+function CreateRotationMatrixX(const angle: Single): TGLMatrix; overload;
 // Creates matrix for rotation about y-axis (angle in rad)
-function CreateRotationMatrixY(const sine, cosine: Single): TMatrix; overload;
-function CreateRotationMatrixY(const angle: Single): TMatrix; overload;
+function CreateRotationMatrixY(const sine, cosine: Single): TGLMatrix; overload;
+function CreateRotationMatrixY(const angle: Single): TGLMatrix; overload;
 // Creates matrix for rotation about z-axis (angle in rad)
-function CreateRotationMatrixZ(const sine, cosine: Single): TMatrix; overload;
-function CreateRotationMatrixZ(const angle: Single): TMatrix; overload;
+function CreateRotationMatrixZ(const sine, cosine: Single): TGLMatrix; overload;
+function CreateRotationMatrixZ(const angle: Single): TGLMatrix; overload;
 // Creates a rotation matrix along the given Axis by the given Angle in radians.
-function CreateRotationMatrix(const anAxis: TAffineVector; angle: Single): TMatrix; overload;
-function CreateRotationMatrix(const anAxis: TGLVector; angle: Single): TMatrix; overload; 
+function CreateRotationMatrix(const anAxis: TAffineVector; angle: Single): TGLMatrix; overload;
+function CreateRotationMatrix(const anAxis: TGLVector; angle: Single): TGLMatrix; overload; 
 // Creates a rotation matrix along the given Axis by the given Angle in radians.
 function CreateAffineRotationMatrix(const anAxis: TAffineVector; angle: Single): TAffineMatrix;
 
 // Multiplies two 3x3 matrices
 function MatrixMultiply(const m1, m2: TAffineMatrix): TAffineMatrix; overload; 
 // Multiplies two 4x4 matrices
-function MatrixMultiply(const m1, m2: TMatrix): TMatrix; overload;
+function MatrixMultiply(const m1, m2: TGLMatrix): TGLMatrix; overload;
 // Multiplies M1 by M2 and places result in MResult
-procedure MatrixMultiply(const m1, m2: TMatrix; var MResult: TMatrix); overload;
+procedure MatrixMultiply(const m1, m2: TGLMatrix; var MResult: TGLMatrix); overload;
 
 // Transforms a homogeneous vector by multiplying it with a matrix
-function VectorTransform(const V: TGLVector; const M: TMatrix): TGLVector; overload; 
+function VectorTransform(const V: TGLVector; const M: TGLMatrix): TGLVector; overload; 
 // Transforms a homogeneous vector by multiplying it with a matrix
 function VectorTransform(const V: TGLVector; const M: TAffineMatrix): TGLVector; overload; 
 // Transforms an affine vector by multiplying it with a matrix
-function VectorTransform(const V: TAffineVector; const M: TMatrix): TAffineVector; overload; 
+function VectorTransform(const V: TAffineVector; const M: TGLMatrix): TAffineVector; overload; 
 // Transforms an affine vector by multiplying it with a matrix
 function VectorTransform(const V: TAffineVector; const M: TAffineMatrix): TAffineVector; overload; 
 
 // Determinant of a 3x3 matrix
 function MatrixDeterminant(const M: TAffineMatrix): Single; overload; 
 // Determinant of a 4x4 matrix
-function MatrixDeterminant(const M: TMatrix): Single; overload;
+function MatrixDeterminant(const M: TGLMatrix): Single; overload;
 
 // Adjoint of a 4x4 matrix, used in the computation of the inverse of a 4x4 matrix 
-procedure AdjointMatrix(var M: TMatrix); overload;
+procedure AdjointMatrix(var M: TGLMatrix); overload;
 // Adjoint of a 3x3 matrix, used in the computation of the inverse of a 3x3 matrix 
 procedure AdjointMatrix(var M: TAffineMatrix); overload;
 
 // Multiplies all elements of a 3x3 matrix with a factor
 procedure ScaleMatrix(var M: TAffineMatrix; const factor: Single); overload;
 // Multiplies all elements of a 4x4 matrix with a factor
-procedure ScaleMatrix(var M: TMatrix; const factor: Single); overload;
+procedure ScaleMatrix(var M: TGLMatrix; const factor: Single); overload;
 
 // Adds the translation vector into the matrix
-procedure TranslateMatrix(var M: TMatrix; const V: TAffineVector); overload;
-procedure TranslateMatrix(var M: TMatrix; const V: TGLVector); overload;
+procedure TranslateMatrix(var M: TGLMatrix; const V: TAffineVector); overload;
+procedure TranslateMatrix(var M: TGLMatrix; const V: TGLVector); overload;
 
 (* Normalize the matrix and remove the translation component.
   The resulting matrix is an orthonormal matrix (Y direction preserved, then Z) *)
-procedure NormalizeMatrix(var M: TMatrix);
+procedure NormalizeMatrix(var M: TGLMatrix);
 
 // Computes transpose of 3x3 matrix
 procedure TransposeMatrix(var M: TAffineMatrix); overload;
 // Computes transpose of 4x4 matrix
-procedure TransposeMatrix(var M: TMatrix); overload;
+procedure TransposeMatrix(var M: TGLMatrix); overload;
 
 // Finds the inverse of a 4x4 matrix
-procedure InvertMatrix(var M: TMatrix); overload;
-function MatrixInvert(const M: TMatrix): TMatrix; overload;
+procedure InvertMatrix(var M: TGLMatrix); overload;
+function MatrixInvert(const M: TGLMatrix): TGLMatrix; overload;
 
 // Finds the inverse of a 3x3 matrix;
 procedure InvertMatrix(var M: TAffineMatrix); overload;
@@ -903,20 +901,20 @@ function  MatrixInvert(const M: TAffineMatrix): TAffineMatrix; overload;
 (* Finds the inverse of an angle preserving matrix.
   Angle preserving matrices can combine translation, rotation and isotropic
   scaling, other matrices won't be properly inverted by this function. *)
-function AnglePreservingMatrixInvert(const mat: TMatrix): TMatrix;
+function AnglePreservingMatrixInvert(const mat: TGLMatrix): TGLMatrix;
 
 (* Decompose a non-degenerated 4x4 transformation matrix into the sequence of transformations that produced it.
   Modified by ml then eg, original Author: Spencer W. Thomas, University of Michigan
   The coefficient of each transformation is returned in the corresponding
   element of the vector Tran. Returns true upon success, false if the matrix is singular. *)
-function MatrixDecompose(const M: TMatrix; var Tran: TTransformations): Boolean;
-function CreateLookAtMatrix(const eye, center, normUp: TGLVector): TMatrix;
-function CreateMatrixFromFrustum(Left, Right, Bottom, Top, ZNear, ZFar: Single): TMatrix;
-function CreatePerspectiveMatrix(FOV, Aspect, ZNear, ZFar: Single): TMatrix;
-function CreateOrthoMatrix(Left, Right, Bottom, Top, ZNear, ZFar: Single): TMatrix;
-function CreatePickMatrix(X, Y, deltax, deltay: Single; const viewport: TVector4i): TMatrix;
-function Project(objectVector: TGLVector; const ViewProjMatrix: TMatrix; const viewport: TVector4i; out WindowVector: TGLVector): Boolean;
-function UnProject(WindowVector: TGLVector; ViewProjMatrix: TMatrix; const viewport: TVector4i; out objectVector: TGLVector): Boolean;
+function MatrixDecompose(const M: TGLMatrix; var Tran: TTransformations): Boolean;
+function CreateLookAtMatrix(const eye, center, normUp: TGLVector): TGLMatrix;
+function CreateMatrixFromFrustum(Left, Right, Bottom, Top, ZNear, ZFar: Single): TGLMatrix;
+function CreatePerspectiveMatrix(FOV, Aspect, ZNear, ZFar: Single): TGLMatrix;
+function CreateOrthoMatrix(Left, Right, Bottom, Top, ZNear, ZFar: Single): TGLMatrix;
+function CreatePickMatrix(X, Y, deltax, deltay: Single; const viewport: TVector4i): TGLMatrix;
+function Project(objectVector: TGLVector; const ViewProjMatrix: TGLMatrix; const viewport: TVector4i; out WindowVector: TGLVector): Boolean;
+function UnProject(WindowVector: TGLVector; ViewProjMatrix: TGLMatrix; const viewport: TVector4i; out objectVector: TGLVector): Boolean;
 
 (* ----------------------------------------------------------------------------
  Plane functions
@@ -1028,11 +1026,11 @@ function QuaternionFromPoints(const V1, V2: TAffineVector): TQuaternion;
 // Converts a unit quaternion into two points on a unit sphere
 procedure QuaternionToPoints(const Q: TQuaternion; var ArcFrom, ArcTo: TAffineVector);
 // Constructs a unit quaternion from a rotation matrix
-function QuaternionFromMatrix(const mat: TMatrix): TQuaternion;
+function QuaternionFromMatrix(const mat: TGLMatrix): TQuaternion;
 (* Constructs a rotation matrix from (possibly non-unit) quaternion.
   Assumes matrix is used to multiply column vector on the left: vnew = mat vold.
   Works correctly for right-handed coordinate system and right-handed rotations *)
-function QuaternionToMatrix(quat: TQuaternion): TMatrix;
+function QuaternionToMatrix(quat: TQuaternion): TGLMatrix;
 // Constructs an affine rotation matrix from (possibly non-unit) quaternion
 function QuaternionToAffineMatrix(quat: TQuaternion): TAffineMatrix;
 // Constructs quaternion from angle (in deg) and axis
@@ -1262,17 +1260,17 @@ procedure DivMod(Dividend: Integer; Divisor: Word; var result, Remainder: Word);
 // Coordinate system manipulation functions
 
 // Rotates the given coordinate system (represented by the matrix) around its Y-axis
-function Turn(const Matrix: TMatrix; Angle: Single): TMatrix; overload;
+function Turn(const Matrix: TGLMatrix; Angle: Single): TGLMatrix; overload;
 // Rotates the given coordinate system (represented by the matrix) around MasterUp
-function Turn(const Matrix: TMatrix; const MasterUp: TAffineVector; Angle: Single): TMatrix; overload;
+function Turn(const Matrix: TGLMatrix; const MasterUp: TAffineVector; Angle: Single): TGLMatrix; overload;
 // Rotates the given coordinate system (represented by the matrix) around its X-axis
-function Pitch(const Matrix: TMatrix; Angle: Single): TMatrix; overload;
+function Pitch(const Matrix: TGLMatrix; Angle: Single): TGLMatrix; overload;
 // Rotates the given coordinate system (represented by the matrix) around MasterRight
-function Pitch(const Matrix: TMatrix; const MasterRight: TAffineVector; Angle: Single): TMatrix; overload;
+function Pitch(const Matrix: TGLMatrix; const MasterRight: TAffineVector; Angle: Single): TGLMatrix; overload;
 // Rotates the given coordinate system (represented by the matrix) around its Z-axis
-function Roll(const Matrix: TMatrix; Angle: Single): TMatrix; overload;
+function Roll(const Matrix: TGLMatrix; Angle: Single): TGLMatrix; overload;
 // Rotates the given coordinate system (represented by the matrix) around MasterDirection
-function Roll(const Matrix: TMatrix; const MasterDirection: TAffineVector; Angle: Single): TMatrix; overload;
+function Roll(const Matrix: TGLMatrix; const MasterDirection: TAffineVector; Angle: Single): TGLMatrix; overload;
 
 // Intersection functions
 
@@ -1295,7 +1293,7 @@ function IntersectTriangleBox(const p1, p2, p3, aMinExtent, aMaxExtent: TAffineV
    Up, Direction and Right must be normalized!
    Use CubDepth, CubeHeight and CubeWidth to scale TGLCube *)
 function IntersectSphereBox(const SpherePos: TGLVector;
-  const SphereRadius: Single; const BoxMatrix: TMatrix;
+  const SphereRadius: Single; const BoxMatrix: TGLMatrix;
   const BoxScale: TAffineVector; intersectPoint: PAffineVector = nil;
   normal: PAffineVector = nil; depth: PSingle = nil): Boolean;
 
@@ -1341,7 +1339,7 @@ function RectangleContains(const ACenterOfBigRect1, ACenterOfSmallRect2,
   intersection testing. *)
 function SphereVisibleRadius(distance, radius: Single): Single;
 // Extracts a TFrustum for combined modelview and projection matrices
-function ExtractFrustumFromModelViewProjection(const modelViewProj: TMatrix): TFrustum;
+function ExtractFrustumFromModelViewProjection(const modelViewProj: TGLMatrix): TFrustum;
 // Determines if volume is clipped or not
 function IsVolumeClipped(const objPos: TAffineVector; const objRadius: Single;
   const Frustum: TFrustum): Boolean; overload;
@@ -1353,22 +1351,22 @@ function IsVolumeClipped(const min, max: TAffineVector; const Frustum: TFrustum)
 
 (* Creates a parallel projection matrix.
   Transformed points will projected on the plane along the specified direction *)
-function MakeParallelProjectionMatrix(const plane: THmgPlane; const dir: TGLVector): TMatrix;
+function MakeParallelProjectionMatrix(const plane: THmgPlane; const dir: TGLVector): TGLMatrix;
 (* Creates a shadow projection matrix.
   Shadows will be projected onto the plane defined by planePoint and planeNormal,
   from lightPos *)
-function MakeShadowMatrix(const planePoint, planeNormal, lightPos: TGLVector): TMatrix;
+function MakeShadowMatrix(const planePoint, planeNormal, lightPos: TGLVector): TGLMatrix;
 (* Builds a reflection matrix for the given plane.
   Reflection matrix allow implementing planar reflectors (mirrors) *)
-function MakeReflectionMatrix(const planePoint, planeNormal: TAffineVector): TMatrix;
+function MakeReflectionMatrix(const planePoint, planeNormal: TAffineVector): TGLMatrix;
 (* Packs an homogeneous rotation matrix to 6 bytes.
   The 6:64 (or 6:36) compression ratio is achieved by computing the quaternion
   associated to the matrix and storing its Imaginary components at 16 bits
   precision each. Deviation is typically below 0.01% and around 0.1% in worst case situations.
   Note: quaternion conversion is faster and more robust than an angle decomposition *)
-function PackRotationMatrix(const mat: TMatrix): TPackedRotationMatrix;
+function PackRotationMatrix(const mat: TGLMatrix): TPackedRotationMatrix;
 // Restores a packed rotation matrix. See PackRotationMatrix
-function UnPackRotationMatrix(const packedMatrix: TPackedRotationMatrix): TMatrix;
+function UnPackRotationMatrix(const packedMatrix: TPackedRotationMatrix): TGLMatrix;
 
 (* Calculates the barycentric coordinates for the point p on the triangle
   defined by the vertices v1, v2 and v3. That is, solves
@@ -2220,7 +2218,7 @@ end;
 function VectorAngleLerp(const V1, V2: TAffineVector; T: Single): TAffineVector;
 var
   q1, q2, qR: TQuaternion;
-  M: TMatrix;
+  M: TGLMatrix;
   Tran: TTransformations;
 begin
   if VectorEquals(V1, V2) then
@@ -2396,7 +2394,7 @@ begin
     result := (stop - start) * Power(delta, DistortionDegree) + start;
 end;
 
-function MatrixLerp(const m1, m2: TMatrix; const delta: Single): TMatrix;
+function MatrixLerp(const m1, m2: TGLMatrix; const delta: Single): TGLMatrix;
 var
   i, J: Integer;
 begin
@@ -2969,7 +2967,7 @@ begin
   result := (a * c - b * b) < cColinearBias;
 end;
 
-procedure SetMatrix(var dest: THomogeneousDblMatrix; const src: TMatrix);
+procedure SetMatrix(var dest: THomogeneousDblMatrix; const src: TGLMatrix);
 var
   i: Integer;
 begin
@@ -2982,7 +2980,7 @@ begin
   end;
 end;
 
-procedure SetMatrix(var dest: TAffineMatrix; const src: TMatrix);
+procedure SetMatrix(var dest: TAffineMatrix; const src: TGLMatrix);
 begin
   dest.X.X := src.X.X;
   dest.X.Y := src.X.Y;
@@ -2995,7 +2993,7 @@ begin
   dest.Z.Z := src.Z.Z;
 end;
 
-procedure SetMatrix(var dest: TMatrix; const src: TAffineMatrix);
+procedure SetMatrix(var dest: TGLMatrix; const src: TAffineMatrix);
 begin
   dest.X.X := src.X.X;
   dest.X.Y := src.X.Y;
@@ -3015,7 +3013,7 @@ begin
   dest.W.W := 1;
 end;
 
-procedure SetMatrixRow(var dest: TMatrix; rowNb: Integer; const aRow: TGLVector);
+procedure SetMatrixRow(var dest: TGLMatrix; rowNb: Integer; const aRow: TGLVector);
 begin
   dest.X.V[rowNb] := aRow.X;
   dest.Y.V[rowNb] := aRow.Y;
@@ -3023,7 +3021,7 @@ begin
   dest.W.V[rowNb] := aRow.W;
 end;
 
-function CreateScaleMatrix(const V: TAffineVector): TMatrix;
+function CreateScaleMatrix(const V: TAffineVector): TGLMatrix;
 begin
   result := IdentityHmgMatrix;
   result.X.X := V.V[X];
@@ -3031,7 +3029,7 @@ begin
   result.Z.Z := V.V[Z];
 end;
 
-function CreateScaleMatrix(const V: TGLVector): TMatrix;
+function CreateScaleMatrix(const V: TGLVector): TGLMatrix;
 begin
   result := IdentityHmgMatrix;
   result.X.X := V.V[X];
@@ -3039,7 +3037,7 @@ begin
   result.Z.Z := V.V[Z];
 end;
 
-function CreateTranslationMatrix(const V: TAffineVector): TMatrix;
+function CreateTranslationMatrix(const V: TAffineVector): TGLMatrix;
 begin
   result := IdentityHmgMatrix;
   result.W.X := V.V[X];
@@ -3047,7 +3045,7 @@ begin
   result.W.Z := V.V[Z];
 end;
 
-function CreateTranslationMatrix(const V: TGLVector): TMatrix;
+function CreateTranslationMatrix(const V: TGLVector): TGLMatrix;
 begin
   result := IdentityHmgMatrix;
   result.W.X := V.V[X];
@@ -3055,7 +3053,7 @@ begin
   result.W.Z := V.V[Z];
 end;
 
-function CreateScaleAndTranslationMatrix(const scale, offset: TGLVector): TMatrix;
+function CreateScaleAndTranslationMatrix(const scale, offset: TGLVector): TGLMatrix;
 begin
   result := IdentityHmgMatrix;
   result.X.X := scale.V[X];
@@ -3066,7 +3064,7 @@ begin
   result.W.Z := offset.V[Z];
 end;
 
-function CreateRotationMatrixX(const sine, cosine: Single): TMatrix;
+function CreateRotationMatrixX(const sine, cosine: Single): TGLMatrix;
 begin
   result := EmptyHmgMatrix;
   result.X.X := 1;
@@ -3077,7 +3075,7 @@ begin
   result.W.W := 1;
 end;
 
-function CreateRotationMatrixX(const angle: Single): TMatrix;
+function CreateRotationMatrixX(const angle: Single): TGLMatrix;
 var
   S, c: Single;
 begin
@@ -3085,7 +3083,7 @@ begin
   result := CreateRotationMatrixX(S, c);
 end;
 
-function CreateRotationMatrixY(const sine, cosine: Single): TMatrix;
+function CreateRotationMatrixY(const sine, cosine: Single): TGLMatrix;
 begin
   result := EmptyHmgMatrix;
   result.X.X := cosine;
@@ -3096,7 +3094,7 @@ begin
   result.W.W := 1;
 end;
 
-function CreateRotationMatrixY(const angle: Single): TMatrix;
+function CreateRotationMatrixY(const angle: Single): TGLMatrix;
 var
   S, c: Single;
 begin
@@ -3104,7 +3102,7 @@ begin
   result := CreateRotationMatrixY(S, c);
 end;
 
-function CreateRotationMatrixZ(const sine, cosine: Single): TMatrix;
+function CreateRotationMatrixZ(const sine, cosine: Single): TGLMatrix;
 begin
   result := EmptyHmgMatrix;
   result.X.X := cosine;
@@ -3115,7 +3113,7 @@ begin
   result.W.W := 1;
 end;
 
-function CreateRotationMatrixZ(const angle: Single): TMatrix;
+function CreateRotationMatrixZ(const angle: Single): TGLMatrix;
 var
   S, c: Single;
 begin
@@ -3124,7 +3122,7 @@ begin
 end;
 
 function CreateRotationMatrix(const anAxis: TAffineVector;
-  angle: Single): TMatrix;
+  angle: Single): TGLMatrix;
 var
   axis: TAffineVector;
   cosine, sine, one_minus_cosine: Single;
@@ -3154,7 +3152,7 @@ begin
   result.W.W := 1;
 end;
 
-function CreateRotationMatrix(const anAxis: TGLVector; angle: Single): TMatrix;
+function CreateRotationMatrix(const anAxis: TGLVector; angle: Single): TGLMatrix;
 begin
   result := CreateRotationMatrix(PAffineVector(@anAxis)^, angle);
 end;
@@ -3195,7 +3193,7 @@ begin
   result.Z.Z := m1.Z.X * m2.X.Z + m1.Z.Y * m2.Y.Z + m1.Z.Z * m2.Z.Z;
 end;
 
-function MatrixMultiply(const m1, m2: TMatrix): TMatrix;
+function MatrixMultiply(const m1, m2: TGLMatrix): TGLMatrix;
 begin
   result.X.X := m1.X.X * m2.X.X + m1.X.Y * m2.Y.X + m1.X.Z * m2.Z.X +
     m1.X.W * m2.W.X;
@@ -3231,7 +3229,7 @@ begin
     m1.W.W * m2.W.W;
 end;
 
-procedure MatrixMultiply(const m1, m2: TMatrix; var MResult: TMatrix);
+procedure MatrixMultiply(const m1, m2: TGLMatrix; var MResult: TGLMatrix);
 begin
   MResult.X.X := m1.X.X * m2.X.X + m1.X.Y * m2.Y.X + m1.X.Z * m2.Z.X +  m1.X.W * m2.W.X;
   MResult.X.Y := m1.X.X * m2.X.Y + m1.X.Y * m2.Y.Y + m1.X.Z * m2.Z.Y +  m1.X.W * m2.W.Y;
@@ -3252,7 +3250,7 @@ begin
 
 end;
 
-function VectorTransform(const V: TGLVector; const M: TMatrix): TGLVector;
+function VectorTransform(const V: TGLVector; const M: TGLMatrix): TGLVector;
 begin
     result.V[X] := V.V[X] * M.X.X + V.V[Y] * M.Y.X + V.V[Z] * M.Z.X + V.V[W] * M.W.X;
     result.V[Y] := V.V[X] * M.X.Y + V.V[Y] * M.Y.Y + V.V[Z] * M.Z.Y + V.V[W] * M.W.Y;
@@ -3268,7 +3266,7 @@ begin
   result.W := V.W;
 end;
 
-function VectorTransform(const V: TAffineVector; const M: TMatrix)
+function VectorTransform(const V: TAffineVector; const M: TGLMatrix)
   : TAffineVector;
 begin
   result.X := V.X * M.V[X].X + V.Y * M.V[Y].X + V.Z * M.V[Z].X + M.V[W].X;
@@ -3298,7 +3296,7 @@ begin
     (a2 * b3 - a3 * b2);
 end;
 
-function MatrixDeterminant(const M: TMatrix): Single;
+function MatrixDeterminant(const M: TGLMatrix): Single;
 begin
   result := M.X.X * MatrixDetInternal(M.Y.Y, M.Z.Y, M.W.Y, M.Y.Z, M.Z.Z, M.W.Z,
     M.Y.W, M.Z.W, M.W.W) - M.X.Y * MatrixDetInternal(M.Y.X, M.Z.X, M.W.X, M.Y.Z,
@@ -3308,7 +3306,7 @@ begin
     M.Z.Z, M.W.Z);
 end;
 
-procedure AdjointMatrix(var M: TMatrix);
+procedure AdjointMatrix(var M: TGLMatrix);
 var
   a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3, d4: Single;
 begin
@@ -3389,7 +3387,7 @@ begin
   end;
 end;
 
-procedure ScaleMatrix(var M: TMatrix; const factor: Single);
+procedure ScaleMatrix(var M: TGLMatrix; const factor: Single);
 var
   i: Integer;
 begin
@@ -3402,21 +3400,21 @@ begin
   end;
 end;
 
-procedure TranslateMatrix(var M: TMatrix; const V: TAffineVector);
+procedure TranslateMatrix(var M: TGLMatrix; const V: TAffineVector);
 begin
   M.W.X := M.W.X + V.X;
   M.W.Y := M.W.Y + V.Y;
   M.W.Z := M.W.Z + V.Z;
 end;
 
-procedure TranslateMatrix(var M: TMatrix; const V: TGLVector);
+procedure TranslateMatrix(var M: TGLMatrix; const V: TGLVector);
 begin
   M.W.X := M.W.X + V.X;
   M.W.Y := M.W.Y + V.Y;
   M.W.Z := M.W.Z + V.Z;
 end;
 
-procedure NormalizeMatrix(var M: TMatrix);
+procedure NormalizeMatrix(var M: TGLMatrix);
 begin
   M.X.W := 0;
   NormalizeVector(M.X);
@@ -3442,7 +3440,7 @@ begin
   M.Z.Y := f;
 end;
 
-procedure TransposeMatrix(var M: TMatrix);
+procedure TransposeMatrix(var M: TGLMatrix);
 var
   f: Single;
 begin
@@ -3466,7 +3464,7 @@ begin
   M.W.Z := f;
 end;
 
-procedure InvertMatrix(var M: TMatrix);
+procedure InvertMatrix(var M: TGLMatrix);
 var
   det: Single;
 begin
@@ -3480,7 +3478,7 @@ begin
   end;
 end;
 
-function MatrixInvert(const M: TMatrix): TMatrix;
+function MatrixInvert(const M: TGLMatrix): TGLMatrix;
 begin
   result := M;
   InvertMatrix(result);
@@ -3506,7 +3504,7 @@ begin
   InvertMatrix(result);
 end;
 
-procedure Transpose_Scale_M33(const src: TMatrix; var dest: TMatrix;
+procedure Transpose_Scale_M33(const src: TGLMatrix; var dest: TGLMatrix;
   var scale: Single);
 begin
   dest.X.X := scale * src.X.X;
@@ -3521,7 +3519,7 @@ begin
 end;
 
 
-function AnglePreservingMatrixInvert(const mat: TMatrix): TMatrix;
+function AnglePreservingMatrixInvert(const mat: TGLMatrix): TGLMatrix;
 var
   scale: Single;
 begin
@@ -3558,10 +3556,10 @@ begin
     mat.W.Y + result.Z.Z * mat.W.Z);
 end;
 
-function MatrixDecompose(const M: TMatrix; var Tran: TTransformations): Boolean;
+function MatrixDecompose(const M: TGLMatrix; var Tran: TTransformations): Boolean;
 var
   I, J: Integer;
-  LocMat, pmat, invpmat: TMatrix;
+  LocMat, pmat, invpmat: TGLMatrix;
   prhs, psol: TGLVector;
   row0, row1, row2: TAffineVector;
   f: Single;
@@ -3694,7 +3692,7 @@ begin
   result := True;
 end;
 
-function CreateLookAtMatrix(const eye, center, normUp: TGLVector): TMatrix;
+function CreateLookAtMatrix(const eye, center, normUp: TGLVector): TGLMatrix;
 var
   XAxis, YAxis, ZAxis, negEye: TGLVector;
 begin
@@ -3717,7 +3715,7 @@ begin
 end;
 
 function CreateMatrixFromFrustum(Left, Right, Bottom, Top, ZNear,
-  ZFar: Single): TMatrix;
+  ZFar: Single): TGLMatrix;
 begin
   result.X.X := 2 * ZNear / (Right - Left);
   result.X.Y := 0;
@@ -3740,7 +3738,7 @@ begin
   result.W.W := 0;
 end;
 
-function CreatePerspectiveMatrix(FOV, Aspect, ZNear, ZFar: Single): TMatrix;
+function CreatePerspectiveMatrix(FOV, Aspect, ZNear, ZFar: Single): TGLMatrix;
 var
   X, Y: Single;
 begin
@@ -3751,7 +3749,7 @@ begin
 end;
 
 function CreateOrthoMatrix(Left, Right, Bottom, Top, ZNear,
-  ZFar: Single): TMatrix;
+  ZFar: Single): TGLMatrix;
 begin
   result.X.X := 2 / (Right - Left);
   result.X.Y := 0;
@@ -3775,7 +3773,7 @@ begin
 end;
 
 function CreatePickMatrix(X, Y, deltax, deltay: Single;
-  const viewport: TVector4i): TMatrix;
+  const viewport: TVector4i): TGLMatrix;
 begin
   if (deltax <= 0) or (deltay <= 0) then
   begin
@@ -3790,7 +3788,7 @@ begin
   result.Y.Y := viewport.W / deltay;
 end;
 
-function Project(objectVector: TGLVector; const ViewProjMatrix: TMatrix;
+function Project(objectVector: TGLVector; const ViewProjMatrix: TGLMatrix;
   const viewport: TVector4i; out WindowVector: TGLVector): Boolean;
 begin
   result := False;
@@ -3812,7 +3810,7 @@ begin
   result := True;
 end;
 
-function UnProject(WindowVector: TGLVector; ViewProjMatrix: TMatrix;
+function UnProject(WindowVector: TGLVector; ViewProjMatrix: TGLMatrix;
   const viewport: TVector4i; out objectVector: TGLVector): Boolean;
 begin
   result := False;
@@ -4415,7 +4413,7 @@ begin
   result.RealPart := Sqrt((VectorDotProduct(V1, V2) + 1) / 2);
 end;
 
-function QuaternionFromMatrix(const mat: TMatrix): TQuaternion;
+function QuaternionFromMatrix(const mat: TGLMatrix): TQuaternion;
 // the matrix must be a rotation matrix!
 var
   traceMat, S, invS: Double;
@@ -4483,7 +4481,7 @@ begin
   result := Temp;
 end;
 
-function QuaternionToMatrix(quat: TQuaternion): TMatrix;
+function QuaternionToMatrix(quat: TQuaternion): TGLMatrix;
 var
   W, X, Y, Z, xx, xy, xz, xw, yy, yz, yw, zz, zw: Single;
 begin
@@ -5678,7 +5676,7 @@ function ConvertRotation(const Angles: TAffineVector): TGLVector;
 }
 var
   Axis1, Axis2: TVector3f;
-  M, m1, m2: TMatrix;
+  M, m1, m2: TGLMatrix;
   cost, cost1, sint, s1, s2, s3: Single;
   i: Integer;
 begin
@@ -5891,41 +5889,41 @@ end;
 
 // ----------------- coordinate system manipulation functions -----------------------------------------------------------
 
-function Turn(const Matrix: TMatrix; angle: Single): TMatrix;
+function Turn(const Matrix: TGLMatrix; angle: Single): TGLMatrix;
 begin
   result := MatrixMultiply(Matrix,
     CreateRotationMatrix(AffineVectorMake(Matrix.Y.X, Matrix.Y.Y,
     Matrix.Y.Z), angle));
 end;
 
-function Turn(const Matrix: TMatrix; const MasterUp: TAffineVector;
-  angle: Single): TMatrix;
+function Turn(const Matrix: TGLMatrix; const MasterUp: TAffineVector;
+  angle: Single): TGLMatrix;
 begin
   result := MatrixMultiply(Matrix, CreateRotationMatrix(MasterUp, angle));
 end;
 
-function Pitch(const Matrix: TMatrix; angle: Single): TMatrix;
+function Pitch(const Matrix: TGLMatrix; angle: Single): TGLMatrix;
 begin
   result := MatrixMultiply(Matrix,
     CreateRotationMatrix(AffineVectorMake(Matrix.X.X, Matrix.X.Y,
     Matrix.X.Z), angle));
 end;
 
-function Pitch(const Matrix: TMatrix; const MasterRight: TAffineVector;
-  angle: Single): TMatrix; overload;
+function Pitch(const Matrix: TGLMatrix; const MasterRight: TAffineVector;
+  angle: Single): TGLMatrix; overload;
 begin
   result := MatrixMultiply(Matrix, CreateRotationMatrix(MasterRight, angle));
 end;
 
-function Roll(const Matrix: TMatrix; angle: Single): TMatrix;
+function Roll(const Matrix: TGLMatrix; angle: Single): TGLMatrix;
 begin
   result := MatrixMultiply(Matrix,
     CreateRotationMatrix(AffineVectorMake(Matrix.Z.X, Matrix.Z.Y,
     Matrix.Z.Z), angle));
 end;
 
-function Roll(const Matrix: TMatrix; const MasterDirection: TAffineVector;
-  angle: Single): TMatrix; overload;
+function Roll(const Matrix: TGLMatrix; const MasterDirection: TAffineVector;
+  angle: Single): TGLMatrix; overload;
 begin
   result := MatrixMultiply(Matrix,
     CreateRotationMatrix(MasterDirection, angle));
@@ -6269,21 +6267,21 @@ begin
 end;
 
 function IntersectSphereBox(const SpherePos: TGLVector;
-  const SphereRadius: Single; const BoxMatrix: TMatrix;
+  const SphereRadius: Single; const BoxMatrix: TGLMatrix;
   // Up Direction and Right must be normalized!
   // Use CubDepht, CubeHeight and CubeWidth
   // for scale TGLCube.
   const BoxScale: TAffineVector; intersectPoint: PAffineVector = nil;
   normal: PAffineVector = nil; depth: PSingle = nil): Boolean;
 
-  function dDOTByColumn(const V: TAffineVector; const M: TMatrix;
+  function dDOTByColumn(const V: TAffineVector; const M: TGLMatrix;
     const aColumn: Integer): Single;
   begin
     result := V.X * M.X.V[aColumn] + V.Y * M.Y.V[aColumn] + V.Z *
       M.Z.V[aColumn];
   end;
 
-  function dDotByRow(const V: TAffineVector; const M: TMatrix;
+  function dDotByRow(const V: TAffineVector; const M: TGLMatrix;
     const aRow: Integer): Single;
   begin
     // Equal with: Result := VectorDotProduct(v, AffineVectorMake(m[aRow]));
@@ -6291,7 +6289,7 @@ function IntersectSphereBox(const SpherePos: TGLVector;
       M.V[aRow].Z;
   end;
 
-  function dDotMatrByColumn(const V: TAffineVector; const M: TMatrix)
+  function dDotMatrByColumn(const V: TAffineVector; const M: TGLMatrix)
     : TAffineVector;
   begin
     result.X := dDOTByColumn(V, M, 0);
@@ -6299,7 +6297,7 @@ function IntersectSphereBox(const SpherePos: TGLVector;
     result.Z := dDOTByColumn(V, M, 2);
   end;
 
-  function dDotMatrByRow(const V: TAffineVector; const M: TMatrix)
+  function dDotMatrByRow(const V: TAffineVector; const M: TGLMatrix)
     : TAffineVector;
   begin
     result.X := dDotByRow(V, M, 0);
@@ -6397,7 +6395,7 @@ begin
   end;
 end;
 
-function ExtractFrustumFromModelViewProjection(const modelViewProj: TMatrix)
+function ExtractFrustumFromModelViewProjection(const modelViewProj: TGLMatrix)
   : TFrustum;
 begin
   with result do
@@ -6470,7 +6468,7 @@ begin
 end;
 
 function MakeParallelProjectionMatrix(const plane: THmgPlane;
-  const dir: TGLVector): TMatrix;
+  const dir: TGLVector): TGLMatrix;
 // Based on material from a course by William D. Shoaff (www.cs.fit.edu)
 var
   dot, invDot: Single;
@@ -6505,7 +6503,7 @@ begin
 end;
 
 function MakeShadowMatrix(const planePoint, planeNormal,
-  lightPos: TGLVector): TMatrix;
+  lightPos: TGLVector): TGLMatrix;
 var
   planeNormal3, dot: Single;
 begin
@@ -6539,7 +6537,7 @@ begin
 end;
 
 function MakeReflectionMatrix(const planePoint, planeNormal
-  : TAffineVector): TMatrix;
+  : TAffineVector): TGLMatrix;
 var
   pv2: Single;
 begin
@@ -6567,7 +6565,7 @@ begin
   result.W.W := 1;
 end;
 
-function PackRotationMatrix(const mat: TMatrix): TPackedRotationMatrix;
+function PackRotationMatrix(const mat: TGLMatrix): TPackedRotationMatrix;
 var
   Q: TQuaternion;
 const
@@ -6592,7 +6590,7 @@ begin
 end;
 
 function UnPackRotationMatrix(const packedMatrix
-  : TPackedRotationMatrix): TMatrix;
+  : TPackedRotationMatrix): TGLMatrix;
 var
   Q: TQuaternion;
 const

+ 4 - 4
Source/GLS.VectorLists.pas

@@ -161,10 +161,10 @@ type
     procedure CombineItem(Index: Integer; const vector: TAffineVector; const f: Single);
     (*Transforms all items by the matrix as if they were points.
       ie. the translation component of the matrix is honoured. *)
-    procedure TransformAsPoints(const matrix: TMatrix);
+    procedure TransformAsPoints(const matrix: TGLMatrix);
     (* Transforms all items by the matrix as if they were vectors.
        ie. the translation component of the matrix is not honoured. *)
-    procedure TransformAsVectors(const matrix: TMatrix); overload;
+    procedure TransformAsVectors(const matrix: TGLMatrix); overload;
     procedure TransformAsVectors(const matrix: TAffineMatrix); overload;
     procedure Normalize; override;
     procedure Lerp(const list1, list2: TBaseVectorList; lerpFactor: Single); override;
@@ -1474,7 +1474,7 @@ begin
   Inc(FRevision);
 end;
 
-procedure TAffineVectorList.TransformAsPoints(const matrix: TMatrix);
+procedure TAffineVectorList.TransformAsPoints(const matrix: TGLMatrix);
 var
   I: Integer;
 begin
@@ -1483,7 +1483,7 @@ begin
   Inc(FRevision);
 end;
 
-procedure TAffineVectorList.TransformAsVectors(const matrix: TMatrix);
+procedure TAffineVectorList.TransformAsVectors(const matrix: TGLMatrix);
 var
   m: TAffineMatrix;
 begin

+ 1 - 1
Source/GLS.VectorTypes.pas

@@ -447,7 +447,7 @@ type
       1 : (M : TMatrix4f);
   end;
 
-  PGLMatrix = ^TMatrix4f;
+  PGLMatrix = ^TGLMatrix;
   TGLMatrix = TMatrix4f;
 
 //-----------------------------------------------  

+ 2 - 2
Source/GLS.VectorTypesExt.pas

@@ -1024,7 +1024,7 @@ const
   DefaultRowCount = 3;
   DefaultColCount = 3;
   VectorTypeName = 'TGLVector';
-  MatrixTypeName = 'TMatrix';
+  MatrixTypeName = 'TGLMatrix';
 var
   RTTIContext: TRttiContext;
   Field : TRttiField;
@@ -1382,4 +1382,4 @@ begin
 end;
 
 
-end.
+end.


+ 2 - 2
Source/GLSL.ProjectedTextures.pas

@@ -56,7 +56,7 @@ type
     FUseQuadraticAttenuation: boolean;
   protected
     ProjectedTexturesObject: TGLSLProjectedTextures;
-    TexMatrix: TMatrix;
+    TexMatrix: TGLMatrix;
     procedure SetupTexMatrix;
     procedure SetStyle(val: TGLSLProjectedTexturesStyle);
     procedure SetUseAttenuation(val: boolean);
@@ -191,7 +191,7 @@ end;
 
 procedure TGLSLTextureEmitter.SetupTexMatrix;
 const
-  cBaseMat: TMatrix = (V:((X:0.5; Y:0;   Z:0; W:0),
+  cBaseMat: TGLMatrix = (V:((X:0.5; Y:0;   Z:0; W:0),
                           (X:0;   Y:0.5; Z:0; W:0),
                           (X:0;   Y:0;   Z:1; W:0),
                           (X:0.5; Y:0.5; Z:0; W:1)));

+ 4 - 4
Source/GLSL.TextureShaders.pas

@@ -45,7 +45,7 @@ type
 
   TGLTextureSharingShaderMaterial = class(TGLInterfacedCollectionItem, IGLMaterialLibrarySupported)
   private
-    FTextureMatrix: TMatrix;
+    FTextureMatrix: TGLMatrix;
     FNeedToUpdateTextureMatrix: Boolean;
     FTextureMatrixIsUnitary: Boolean;
     FLibMaterial: TGLLibMaterial;
@@ -70,7 +70,7 @@ type
     procedure SetLibMaterial(const Value: TGLLibMaterial);
     procedure SetTexOffset(const Value: TGLCoordinates2);
     procedure SetTexScale(const Value: TGLCoordinates2);
-    function GetTextureMatrix: TMatrix;
+    function GetTextureMatrix: TGLMatrix;
     function GetTextureMatrixIsUnitary: Boolean;
   protected
     procedure coordNotifychange(Sender: TObject);
@@ -85,7 +85,7 @@ type
     constructor Create(Collection: TCollection); override;
     destructor Destroy; override;
     property LibMaterial: TGLLibMaterial read FLibMaterial write SetLibMaterial;
-    property TextureMatrix: TMatrix read GetTextureMatrix;
+    property TextureMatrix: TGLMatrix read GetTextureMatrix;
     property TextureMatrixIsUnitary: Boolean read GetTextureMatrixIsUnitary;
   published
     property TexOffset: TGLCoordinates2 read FTexOffset write SetTexOffset;
@@ -376,7 +376,7 @@ begin
   Result := FMaterialLibrary;
 end;
 
-function TGLTextureSharingShaderMaterial.GetTextureMatrix: TMatrix;
+function TGLTextureSharingShaderMaterial.GetTextureMatrix: TGLMatrix;
 begin
   if FNeedToUpdateTextureMatrix then
   begin

+ 16 - 16
Source/Physics.NGDManager.pas

@@ -23,7 +23,7 @@ uses
   /// Import.Newton,    // new version
 
   GLS.VectorTypes,
-  GLS.VectorGeometry, // PGLVector TGLVector TMatrix PMatrix NullHmgVector...
+  GLS.VectorGeometry, // PGLVector TGLVector TGLMatrix PGLMatrix NullHmgVector...
   GLS.VectorLists, // TAffineVectorList for Tree
   GLS.XCollection, // TXCollection file function
   GLS.GeometryBB, // For show debug
@@ -238,7 +238,7 @@ type
     FInitialized: Boolean;
     FNewtonBody: PNewtonBody;
     FCollision: PNewtonCollision;
-    FNewtonBodyMatrix: TMatrix; // Position and Orientation
+    FNewtonBodyMatrix: TGLMatrix; // Position and Orientation
     FContinuousCollisionMode: Boolean; // Default=False
     FNGDCollisions: TGLNGDCollisions;
     FCollisionIteratorEvent: TCollisionIteratorEvent;
@@ -256,9 +256,9 @@ type
     procedure ReadFromFiler(reader: TReader); override;
     procedure Loaded; override;
     procedure SetManager(Value: TGLNGDManager);
-    procedure SetNewtonBodyMatrix(const Value: TMatrix);
+    procedure SetNewtonBodyMatrix(const Value: TGLMatrix);
     procedure SetContinuousCollisionMode(const Value: Boolean);
-    function GetNewtonBodyMatrix: TMatrix;
+    function GetNewtonBodyMatrix: TGLMatrix;
     function GetNewtonBodyAABB: TAABB;
     procedure UpdCollision; virtual;
     procedure Render; virtual;
@@ -292,7 +292,7 @@ type
     procedure Reinitialize;
     property Initialized: Boolean read FInitialized;
     class function UniqueItem: Boolean; override;
-    property NewtonBodyMatrix: TMatrix read GetNewtonBodyMatrix
+    property NewtonBodyMatrix: TGLMatrix read GetNewtonBodyMatrix
       write SetNewtonBodyMatrix;
     property NewtonBodyAABB: TAABB read GetNewtonBodyAABB;
     procedure Serialize(filename: string);
@@ -1090,7 +1090,7 @@ procedure TGLNGDManager.RebuildAllJoint(Sender: TObject);
 
   procedure BuildCustomBallAndSocket(Joint: TGLNGDJoint);
   var
-    pinAndPivot: TMatrix;
+    pinAndPivot: TGLMatrix;
   begin
     with Joint do
       if Assigned(FParentObject) and Assigned(FChildObject) then
@@ -1115,7 +1115,7 @@ procedure TGLNGDManager.RebuildAllJoint(Sender: TObject);
 
   procedure BuildCustomHinge(Joint: TGLNGDJoint);
   var
-    pinAndPivot: TMatrix;
+    pinAndPivot: TGLMatrix;
     bso: TGLBaseSceneObject;
   begin
     (* Newton wait from FPinAndPivotMatrix a structure like that:
@@ -1153,7 +1153,7 @@ procedure TGLNGDManager.RebuildAllJoint(Sender: TObject);
 
   procedure BuildCustomSlider(Joint: TGLNGDJoint);
   var
-    pinAndPivot: TMatrix;
+    pinAndPivot: TGLMatrix;
     bso: TGLBaseSceneObject;
 
   begin
@@ -1430,7 +1430,7 @@ end;
 function TGLNGDBehaviour.GetBSphereCollision: PNewtonCollision;
 var
   boundingSphere: TBSphere;
-  collisionOffsetMatrix: TMatrix;
+  collisionOffsetMatrix: TGLMatrix;
 begin
   AABBToBSphere(FOwnerBaseSceneObject.AxisAlignedBoundingBoxEx, boundingSphere);
 
@@ -1526,7 +1526,7 @@ begin
     Result := GetNullCollision;
 end;
 
-function TGLNGDBehaviour.GetNewtonBodyMatrix: TMatrix;
+function TGLNGDBehaviour.GetNewtonBodyMatrix: TGLMatrix;
 begin
   if Assigned(FManager) then
     NewtonBodyGetmatrix(FNewtonBody, @FNewtonBodyMatrix);
@@ -1561,7 +1561,7 @@ end;
 
 function TGLNGDBehaviour.GetPrimitiveCollision: PNewtonCollision;
 var
-  collisionOffsetMatrix: TMatrix; // For cone capsule and cylinder
+  collisionOffsetMatrix: TGLMatrix; // For cone capsule and cylinder
 begin
   collisionOffsetMatrix := IdentityHmgMatrix;
 
@@ -1754,7 +1754,7 @@ end;
 
 procedure TGLNGDBehaviour.Render;
 var
-  M: TMatrix;
+  M: TGLMatrix;
 begin
   // Rebuild collision in design time
   if (csDesigning in FOwnerBaseSceneObject.ComponentState) then
@@ -1849,7 +1849,7 @@ begin
   end;
 end;
 
-procedure TGLNGDBehaviour.SetNewtonBodyMatrix(const Value: TMatrix);
+procedure TGLNGDBehaviour.SetNewtonBodyMatrix(const Value: TGLMatrix);
 begin
   FNewtonBodyMatrix := Value;
   if Assigned(FManager) then
@@ -2114,7 +2114,7 @@ procedure TGLNGDDynamic.Render;
 
   function GetAbsCom(): TGLVector;
   var
-    M: TMatrix;
+    M: TGLMatrix;
   begin
     NewtonBodyGetCentreOfMass(FNewtonBody, @Result);
     M := IdentityHmgMatrix;
@@ -2413,7 +2413,7 @@ begin
     else
       // Make the Position and orientation of the glscene-Object relative to the
       // NewtonBody position and orientation.
-      FOwnerBaseSceneObject.AbsoluteMatrix := pMatrix(cmatrix)^;
+      FOwnerBaseSceneObject.AbsoluteMatrix := PGLMatrix(cmatrix)^;
 end;
 
 // ------------------------
@@ -2723,7 +2723,7 @@ procedure TGLNGDJoint.Render;
 
   procedure DrawKinematic;
   var
-    pickedMatrix: TMatrix;
+    pickedMatrix: TGLMatrix;
     size: Single;
   begin
     size := FManager.DebugOption.DotAxisSize;

+ 5 - 5
Source/Physics.NGDRagdoll.pas

@@ -30,9 +30,9 @@ type
     Actor: TGLActor;
     Bodies: TList;
     Joints: array of PNewtonJoint;
-    Norm_matrices: array of TMatrix;
+    Norm_matrices: array of TGLMatrix;
     Envelopes: array of record kind: byte;
-    Mat: TMatrix;
+    Mat: TGLMatrix;
     Pt: TVector3f;
     W, D, H, Mass: single;
   end;
@@ -122,8 +122,8 @@ var
   d: single;
   Collision: PNewtonCollision;
   CollisionBox, CollisionCylinder, CollisionSphere: PNewtonCollision;
-  Matrix: Tmatrix;
-  CollisionOffsetMatrix: TMatrix; // For cone capsule and cylinder
+  Matrix: TGLMatrix;
+  CollisionOffsetMatrix: TGLMatrix; // For cone capsule and cylinder
 begin
   collisionOffsetMatrix := IdentityHmgMatrix;
   d := 0;
@@ -256,7 +256,7 @@ end;
 procedure TNewtonRagdoll.SetEnabled;
 var
   i: integer;
-  a: TMatrix;
+  a: TGLMatrix;
   v: TVector3f;
 begin
   if FEnabled = value then

+ 30 - 30
Source/Physics.ODEManager.pas

@@ -196,7 +196,7 @@ type
     procedure Loaded; override;
     procedure SetManager(Value: TGLODEManager);
     procedure SetSurface(Value: TGLODECollisionSurface);
-    function GetAbsoluteMatrix: TMatrix;
+    function GetAbsoluteMatrix: TGLMatrix;
   public
     constructor Create(AOwner: TXCollection); override;
     destructor Destroy; override;
@@ -204,7 +204,7 @@ type
     procedure Render(var rci: TGLRenderContextInfo); virtual;
     procedure Reinitialize;
     property Initialized: Boolean read FInitialized;
-    property AbsoluteMatrix: TMatrix read GetAbsoluteMatrix;
+    property AbsoluteMatrix: TGLMatrix read GetAbsoluteMatrix;
   published
     property Manager: TGLODEManager read FManager write SetManager;
     property Surface: TGLODECollisionSurface read FSurface write SetSurface;
@@ -225,7 +225,7 @@ type
     procedure ReadFromFiler(reader: TReader); override;
     procedure SetMass(const Value: TdMass);
     function GetMass: TdMass;
-    procedure AlignBodyToMatrix(Mat: TMatrix);
+    procedure AlignBodyToMatrix(Mat: TGLMatrix);
     procedure SetEnabled(const Value: Boolean);
     function GetEnabled: Boolean;
     procedure RegisterJoint(Joint: TGLODEJointBase);
@@ -297,7 +297,7 @@ type
     FPosition, 
 	FDirection, 
 	FUp: TGLCoordinates;
-    FLocalMatrix: TMatrix;
+    FLocalMatrix: TGLMatrix;
     FRealignODE,
 	FInitialized,
 	FDynamic,
@@ -312,13 +312,13 @@ type
     procedure WriteToFiler(writer: TWriter); override;
     procedure ReadFromFiler(reader: TReader); override;
     function IsODEInitialized: Boolean;
-    procedure AlignGeomElementToMatrix(Mat: TMatrix); virtual;
+    procedure AlignGeomElementToMatrix(Mat: TGLMatrix); virtual;
     procedure SetGeomElement(aGeom: PdxGeom);
     procedure RebuildMatrix;
     procedure RebuildVectors;
     procedure SetDensity(const Value: TdReal);
-    procedure SetMatrix(const Value: TMatrix);
-    function GetMatrix: TMatrix;
+    procedure SetMatrix(const Value: TGLMatrix);
+    function GetMatrix: TGLMatrix;
     procedure SetPosition(const Value: TGLCoordinates);
     procedure SetDirection(const Value: TGLCoordinates);
     procedure SetUp(const Value: TGLCoordinates);
@@ -326,9 +326,9 @@ type
     constructor Create(AOwner: TXCollection); override;
     destructor Destroy; override;
     procedure Render(var rci: TGLRenderContextInfo); virtual;
-    function AbsoluteMatrix: TMatrix;
+    function AbsoluteMatrix: TGLMatrix;
     function AbsolutePosition: TAffineVector;
-    property Matrix: TMatrix read GetMatrix write SetMatrix;
+    property Matrix: TGLMatrix read GetMatrix write SetMatrix;
     property GeomTransform: PdxGeom read FGeomTransform;
     property Geom: PdxGeom read FGeomElement;
     property Initialized: Boolean read FInitialized;
@@ -474,7 +474,7 @@ type
     procedure Initialize; override;
     procedure WriteToFiler(writer: TWriter); override;
     procedure ReadFromFiler(reader: TReader); override;
-    procedure AlignGeomElementToMatrix(Mat: TMatrix); override;
+    procedure AlignGeomElementToMatrix(Mat: TGLMatrix); override;
   public
     class function FriendlyName: String; override;
     class function FriendlyDescription: String; override;
@@ -811,7 +811,7 @@ type
     FGeom: PdxGeom;
     FContactList,
       FContactCache: TList;
-    FTransform: TMatrix;
+    FTransform: TGLMatrix;
     FContactResolution: Single;
     FRenderContacts: Boolean;
     FContactRenderPoints: TAffineVectorList;
@@ -834,7 +834,7 @@ type
     function ApplyContacts(o1, o2: PdxGeom; flags: Integer;
       contact: PdContactGeom; skip: Integer): Integer;
     // Set the transform used that transforms contact points generated with AddContact
-    procedure SetTransform(ATransform: TMatrix);
+    procedure SetTransform(ATransform: TGLMatrix);
     procedure SetContactResolution(const Value: Single);
     procedure SetRenderContacts(const Value: Boolean);
     procedure SetPointSize(const Value: Single);
@@ -1053,7 +1053,7 @@ var
   i, j, res: Integer;
   pos: PdVector3;
   R: PdMatrix3;
-  rmat, mat: TMatrix;
+  rmat, mat: TGLMatrix;
   rad, dx, dy, dz: TdReal;
 begin
   Result := 0;
@@ -1099,7 +1099,7 @@ var
   s: TdVector3;
   pos: PdVector3;
   R: PdMatrix3;
-  mat: TMatrix;
+  mat: TGLMatrix;
 begin
   Result := 0;
   Collider := GetColliderFromGeom(o1);
@@ -1179,7 +1179,7 @@ var
   i, j, res: Integer;
   pos: PdVector3;
   R: PdMatrix3;
-  mat, rmat: TMatrix;
+  mat, rmat: TGLMatrix;
   rad, len, dx, dy, dz: TdReal;
 begin
   Result := 0;
@@ -1226,7 +1226,7 @@ var
   i, j, res: Integer;
   pos: PdVector3;
   R: PdMatrix3;
-  mat: TMatrix;
+  mat: TGLMatrix;
   rad, len, dx, dy: TdReal;
 begin
   Result := 0;
@@ -2026,7 +2026,7 @@ begin
   FSurface.Assign(Value);
 end;
 
-function TGLODEBehaviour.GetAbsoluteMatrix: TMatrix;
+function TGLODEBehaviour.GetAbsoluteMatrix: TGLMatrix;
 begin
   Result := IdentityHMGMatrix;
   if Assigned(Owner.Owner) then
@@ -2056,7 +2056,7 @@ end;
 
 procedure TGLODEDynamic.Render(var rci: TGLRenderContextInfo);
 var
-  Mat: TMatrix;
+  Mat: TGLMatrix;
 begin
   if Assigned(Owner.Owner) then
   begin
@@ -2179,7 +2179,7 @@ procedure TGLODEDynamic.AlignObject;
 var
   Pos: PdVector3;
   R: PdMatrix3;
-  m: TMatrix;
+  m: TGLMatrix;
 begin
   Pos := dBodyGetPosition(Body);
   R := dBodyGetRotation(Body);
@@ -2189,7 +2189,7 @@ begin
   OwnerBaseSceneObject.SetMatrix(m);
 end;
 
-procedure TGLODEDynamic.AlignBodyToMatrix(Mat: TMatrix);
+procedure TGLODEDynamic.AlignBodyToMatrix(Mat: TGLMatrix);
 var
   R: TdMatrix3;
 begin
@@ -2340,7 +2340,7 @@ end;
 
 procedure TGLODEStatic.Render(var rci: TGLRenderContextInfo);
 var
-  Mat: TMatrix;
+  Mat: TGLMatrix;
 begin
   if Assigned(Owner.Owner) then
   begin
@@ -2602,9 +2602,9 @@ begin
   NotifyChange(Self);
 end;
 
-function TGLODEElementBase.AbsoluteMatrix: TMatrix;
+function TGLODEElementBase.AbsoluteMatrix: TGLMatrix;
 var
-  Mat: TMatrix;
+  Mat: TGLMatrix;
 begin
   Mat := IdentityHMGMatrix;
   if Owner.Owner is TGLODEBehaviour then
@@ -2617,7 +2617,7 @@ begin
   Result := AffineVectorMake(AbsoluteMatrix.W);
 end;
 
-procedure TGLODEElementBase.AlignGeomElementToMatrix(Mat: TMatrix);
+procedure TGLODEElementBase.AlignGeomElementToMatrix(Mat: TGLMatrix);
 var
   R: TdMatrix3;
 begin
@@ -2730,7 +2730,7 @@ begin
   ODERebuild;
 end;
 
-function TGLODEElementBase.GetMatrix: TMatrix;
+function TGLODEElementBase.GetMatrix: TGLMatrix;
 begin
   Result := FLocalMatrix;
 end;
@@ -2755,7 +2755,7 @@ begin
   FDensity := Value;
 end;
 
-procedure TGLODEElementBase.SetMatrix(const Value: TMatrix);
+procedure TGLODEElementBase.SetMatrix(const Value: TGLMatrix);
 begin
   FLocalMatrix := Value;
   RebuildVectors;
@@ -3602,7 +3602,7 @@ begin
       Result := True;
 end;
 
-procedure TGLODEElementPlane.AlignGeomElementToMatrix(Mat: TMatrix);
+procedure TGLODEElementPlane.AlignGeomElementToMatrix(Mat: TGLMatrix);
 var
   d: Single;
 begin
@@ -5189,7 +5189,7 @@ begin
   end;
 end;
 
-procedure TGLODECustomCollider.SetTransform(ATransform: TMatrix);
+procedure TGLODECustomCollider.SetTransform(ATransform: TGLMatrix);
 begin
   FTransform := ATransform;
 end;
@@ -5317,7 +5317,7 @@ function TGLODEHeightField.Collide(aPos: TAffineVector; var Depth: Single;
 
   function AbsoluteToLocal(vec: TGLVector): TGLVector;
   var
-    mat: TMatrix;
+    mat: TGLMatrix;
   begin
     if Owner.Owner is TGLHeightField then
       Result := TGLHeightField(Owner.Owner).AbsoluteToLocal(vec)
@@ -5334,7 +5334,7 @@ function TGLODEHeightField.Collide(aPos: TAffineVector; var Depth: Single;
 
   function LocalToAbsolute(vec: TGLVector): TGLVector;
   var
-    mat: TMatrix;
+    mat: TGLMatrix;
   begin
     if Owner.Owner is TGLHeightField then
       Result := TGLHeightField(Owner.Owner).LocalToAbsolute(vec)

+ 95 - 86
Source/Physics.ODERagdoll.pas

@@ -27,9 +27,9 @@ type
   TGLODERagdollBone = class;
 
   TGLODERagdollCube = class(TGLCube)
-   public
-    Bone:TGLODERagdollBone; // Useful in Oncollision Event
-    Ragdoll:TGLODERagdoll;  // Useful in Oncollision Event
+  public
+    Bone: TGLODERagdollBone; // Useful in Oncollision Event
+    Ragdoll: TGLODERagdoll; // Useful in Oncollision Event
   end;
 
   TGLODERagdollWorld = class
@@ -38,11 +38,12 @@ type
     FWorld: PdxWorld;
     FContactGroup: TdJointGroupID;
     FRagdoll: TGLODERagdoll;
-    isWorldCreated : Boolean; // NEW1
+    isWorldCreated: Boolean; // NEW1
   public
     constructor Create;
     // Create the world from any existing ODE world
-    constructor CreateFrom(World: PdxWorld; Space: PdxSpace; ContactGroup: TdJointGroupID);
+    constructor CreateFrom(World: PdxWorld; Space: PdxSpace;
+      ContactGroup: TdJointGroupID);
     destructor Destroy; override;
     procedure WorldUpdate;
     property World: PdxWorld read FWorld;
@@ -54,16 +55,15 @@ type
   TGLODERagdollDummyJoint = class(TGLRagdolJoint)
   end;
 
-
   TGLODERagdollHingeJoint = class(TGLRagdolJoint)
   private
     FParamHiStop: Single;
     FParamLoStop: Single;
     FAxis: TAffineVector;
   public
-    constructor Create(Axis: TAffineVector;
-      ParamLoStop: Single; ParamHiStop: Single);
-    property Axis : TAffineVector read FAxis;
+    constructor Create(Axis: TAffineVector; ParamLoStop: Single;
+      ParamHiStop: Single);
+    property Axis: TAffineVector read FAxis;
     property ParamLoStop: Single read FParamLoStop write FParamLoStop;
     property ParamHiStop: Single read FParamHiStop write FParamHiStop;
   end;
@@ -74,28 +74,29 @@ type
     FParamLoStop2: Single;
     FAxis2: TAffineVector;
   public
-    constructor Create(Axis: TAffineVector; ParamLoStop: Single; ParamHiStop: Single;
-                       Axis2: TAffineVector; ParamLoStop2: Single; ParamHiStop2: Single);
-    property Axis2 : TAffineVector read FAxis2;
+    constructor Create(Axis: TAffineVector; ParamLoStop: Single;
+      ParamHiStop: Single; Axis2: TAffineVector; ParamLoStop2: Single;
+      ParamHiStop2: Single);
+    property Axis2: TAffineVector read FAxis2;
     property ParamLoStop2: Single read FParamLoStop2 write FParamLoStop2;
     property ParamHiStop2: Single read FParamHiStop2 write FParamHiStop2;
   end;
 
-	TGLODERagdollBone = class (TGLRagdolBone)
+  TGLODERagdollBone = class(TGLRagdolBone)
   private
     FOwner: TGLODERagdollBone;
     FRagdoll: TGLODERagdoll;
     FBody: PdxBody;
     FGeom: PdxGeom;
     FJointId: TdJointID;
-    procedure AlignBodyToMatrix(Mat: TMatrix);
+    procedure AlignBodyToMatrix(Mat: TGLMatrix);
   protected
     procedure Start; override;
     procedure Align; override;
     procedure Update; override;
     procedure Stop; override;
   public
-    constructor CreateOwned(aOwner : TGLODERagdollBone);
+    constructor CreateOwned(aOwner: TGLODERagdollBone);
     constructor Create(Ragdoll: TGLODERagdoll);
     property Body: PdxBody read FBody;
     property Geom: PdxGeom read FGeom;
@@ -106,34 +107,37 @@ type
     FODEWorld: TGLODERagdollWorld;
     FGLSceneRoot: TGLBaseSceneObject;
     FShowBoundingBoxes: Boolean;
+    FEnabled: Boolean;
   public
-    constructor Create(AOwner : TGLBaseMesh);
+    constructor Create(aOwner: TGLBaseMesh);
     property ODEWorld: TGLODERagdollWorld read FODEWorld write FODEWorld;
-    property GLSceneRoot: TGLBaseSceneObject read FGLSceneRoot write FGLSceneRoot;
-    property ShowBoundingBoxes: Boolean read FShowBoundingBoxes write FShowBoundingBoxes;
+    property GLSceneRoot: TGLBaseSceneObject read FGLSceneRoot
+      write FGLSceneRoot;
+    property ShowBoundingBoxes: Boolean read FShowBoundingBoxes
+      write FShowBoundingBoxes;
+    property Enabled: Boolean read FEnabled write FEnabled;
   end;
 
-
 var
-  vODERagdoll_cDensity : Single;
-  vODERagdoll_cMass : Single;
+  vODERagdoll_cDensity: Single;
+  vODERagdoll_cMass: Single;
 
-//----------------------------------------
+// ----------------------------------------
 implementation
-//----------------------------------------
 
-//
+//-------------------------------------
 // TGLODERagdollWorld
-//
+// ----------------------------------------
+
 constructor TGLODERagdollWorld.Create;
 begin
-  //Create default physics
+  // Create default physics
   FWorld := dWorldCreate();
   dWorldSetQuickStepNumIterations(FWorld, 8);
-  FSpace := dHashSpaceCreate (nil);
+  FSpace := dHashSpaceCreate(nil);
   FContactGroup := dJointGroupCreate(0);
   dWorldSetGravity(FWorld, 0, 0, -0.81);
-  dWorldSetCFM(FWorld, 1e-5);
+  dWorldSetCFM(FWorld, 1E-5);
   isWorldCreated := True; // NEW1
 end;
 
@@ -176,7 +180,7 @@ begin
     for i := 0 to n - 1 do
     begin
       contact[i].surface.mode := ord(dContactBounce) or ord(dContactSoftCFM) or
-	    ord(dContactSlip1) or ord(dContactSlip2);
+        ord(dContactSlip1) or ord(dContactSlip2);
       contact[i].surface.mu := 10E9;
       contact[i].surface.mu2 := 0;
       contact[i].surface.soft_cfm := 0.001;
@@ -185,8 +189,10 @@ begin
       contact[i].surface.slip1 := 0.1;
       contact[i].surface.slip2 := 0.1;
 
-      c := dJointCreateContact(TGLODERagdollWorld(Data).World, TGLODERagdollWorld(Data).ContactGroup, @contact[i]);
-      dJointAttach(c, dGeomGetBody(contact[i].Geom.g1), dGeomGetBody(contact[i].Geom.g2));
+      c := dJointCreateContact(TGLODERagdollWorld(data).World,
+        TGLODERagdollWorld(data).ContactGroup, @contact[i]);
+      dJointAttach(c, dGeomGetBody(contact[i].Geom.g1),
+        dGeomGetBody(contact[i].Geom.g2));
     end;
   end;
 
@@ -206,7 +212,8 @@ end;
 //
 // TGLODERagdollHingeJoint
 //
-constructor TGLODERagdollHingeJoint.Create(Axis: TAffineVector; ParamLoStop, ParamHiStop: Single);
+constructor TGLODERagdollHingeJoint.Create(Axis: TAffineVector;
+  ParamLoStop, ParamHiStop: Single);
 begin
   inherited Create;
   FAxis := Axis;
@@ -217,16 +224,17 @@ end;
 //
 // TGLODERagdollUniversalJoint
 //
-constructor TGLODERagdollUniversalJoint.Create(Axis: TAffineVector; ParamLoStop, ParamHiStop: Single; Axis2: TAffineVector;
+constructor TGLODERagdollUniversalJoint.Create(Axis: TAffineVector;
+  ParamLoStop, ParamHiStop: Single; Axis2: TAffineVector;
   ParamLoStop2, ParamHiStop2: Single);
 begin
   inherited Create(Axis, ParamLoStop, ParamHiStop);
-  FAxis2:= Axis2;
-  FParamLoStop:= ParamLoStop;
-  FParamHiStop:= ParamHiStop;
+  FAxis2 := Axis2;
+  FParamLoStop := ParamLoStop;
+  FParamHiStop := ParamHiStop;
 
-  FParamLoStop2:= ParamLoStop2;
-  FParamHiStop2:= ParamHiStop2;
+  FParamLoStop2 := ParamLoStop2;
+  FParamHiStop2 := ParamHiStop2;
 end;
 
 //
@@ -245,26 +253,26 @@ begin
   FRagdoll := aOwner.FRagdoll;
 end;
 
-procedure TGLODERagdollBone.AlignBodyToMatrix(Mat:TMatrix);
+procedure TGLODERagdollBone.AlignBodyToMatrix(Mat: TGLMatrix);
 var
   R: TdMatrix3;
 begin
-  if not Assigned(FBody) then
+  if not assigned(FBody) then
     exit;
-  R[0]:=Mat.X.X;
-  R[1]:=Mat.Y.X; 
-  R[2]:= Mat.Z.X;
-  R[3]:= 0;
-  R[4]:=Mat.X.Y; 
-  R[5]:=Mat.Y.Y; 
-  R[6]:= Mat.Z.Y; 
-  R[7]:= 0;
-  R[8]:=Mat.X.Z; 
-  R[9]:=Mat.Y.Z; 
-  R[10]:=Mat.Z.Z;
-  R[11]:=0;
-  dBodySetRotation(FBody,R);
-  dBodySetPosition(FBody,Mat.W.X,Mat.W.Y,Mat.W.Z);
+  R[0] := Mat.X.X;
+  R[1] := Mat.Y.X;
+  R[2] := Mat.Z.X;
+  R[3] := 0;
+  R[4] := Mat.X.Y;
+  R[5] := Mat.Y.Y;
+  R[6] := Mat.Z.Y;
+  R[7] := 0;
+  R[8] := Mat.X.Z;
+  R[9] := Mat.Y.Z;
+  R[10] := Mat.Z.Z;
+  R[11] := 0;
+  dBodySetRotation(FBody, R);
+  dBodySetPosition(FBody, Mat.W.X, Mat.W.Y, Mat.W.Z);
 end;
 
 procedure TGLODERagdollBone.Start;
@@ -275,23 +283,23 @@ var
 
   function RotateAxis(Axis: TAffineVector): TAffineVector;
   var
-    absMat: TMatrix;
+    absMat: TGLMatrix;
   begin
-    absMat:= ReferenceMatrix;
-    absMat.W:= NullHmgVector;
-    Result:= VectorNormalize(VectorTransform(Axis, absMat));
+    absMat := ReferenceMatrix;
+    absMat.W := NullHmgVector;
+    Result := VectorNormalize(VectorTransform(Axis, absMat));
   end;
 
 begin
-  FBody:= dBodyCreate(FRagdoll.ODEWorld.World);
-  boneSize.X:= Size.X*VectorLength(BoneMatrix.X);
-  boneSize.Y:= Size.Y*VectorLength(BoneMatrix.Y);
-  boneSize.Z:= Size.Z*VectorLength(BoneMatrix.Z);
+  FBody := dBodyCreate(FRagdoll.ODEWorld.World);
+  boneSize.X := Size.X * VectorLength(BoneMatrix.X);
+  boneSize.Y := Size.Y * VectorLength(BoneMatrix.Y);
+  boneSize.Z := Size.Z * VectorLength(BoneMatrix.Z);
 
   // prevent ODE 0.9 "bNormalizationResult failed" error:
-  for n:= 0 to 2 do
+  for n := 0 to 2 do
     if (boneSize.V[n] = 0) then
-      boneSize.V[n]:= 0.000001;
+      boneSize.V[n] := 0.000001;
 
   dMassSetBox(mass, vODERagdoll_cDensity, boneSize.X, boneSize.Y, boneSize.Z);
 
@@ -300,31 +308,32 @@ begin
 
   AlignBodyToMatrix(ReferenceMatrix);
 
-  FGeom:= dCreateBox(FRagdoll.ODEWorld.Space, boneSize.X, boneSize.Y, boneSize.Z);
-  FGeom.data:= FRagdoll.GLSceneRoot.AddNewChild(TGLODERagdollCube);
+  FGeom := dCreateBox(FRagdoll.ODEWorld.Space, boneSize.X, boneSize.Y,
+    boneSize.Z);
+  FGeom.data := FRagdoll.GLSceneRoot.AddNewChild(TGLODERagdollCube);
   if (Joint is TGLODERagdollDummyJoint) then
     dGeomSetBody(FGeom, FOwner.Body)
   else
     dGeomSetBody(FGeom, FBody);
   if (Owner <> nil) then
   begin
-      if (Joint is TGLODERagdollHingeJoint) then
+    if (Joint is TGLODERagdollHingeJoint) then
       with (Joint as TGLODERagdollHingeJoint) do
       begin
-        vAxis:= RotateAxis(Axis);
-        FJointId:= dJointCreateHinge(FRagdoll.ODEWorld.World, nil);
+        vAxis := RotateAxis(Axis);
+        FJointId := dJointCreateHinge(FRagdoll.ODEWorld.World, nil);
         dJointAttach(FJointId, TGLODERagdollBone(Owner).Body, FBody);
         dJointSetHingeAnchor(FJointId, Anchor.X, Anchor.Y, Anchor.Z);
         dJointSetHingeAxis(FJointId, vAxis.X, vAxis.Y, vAxis.Z);
         dJointSetHingeParam(FJointId, dParamLoStop, ParamLoStop);
         dJointSetHingeParam(FJointId, dParamHiStop, ParamHiStop);
       end;
-      if (Joint is TGLODERagdollUniversalJoint) then
+    if (Joint is TGLODERagdollUniversalJoint) then
       with (Joint as TGLODERagdollUniversalJoint) do
       begin
-        vAxis:= RotateAxis(Axis);
-        vAxis2:= RotateAxis(Axis2);
-        FJointId:= dJointCreateUniversal(FRagdoll.ODEWorld.World, nil);
+        vAxis := RotateAxis(Axis);
+        vAxis2 := RotateAxis(Axis2);
+        FJointId := dJointCreateUniversal(FRagdoll.ODEWorld.World, nil);
         dJointAttach(FJointId, TGLODERagdollBone(Owner).Body, FBody);
         dJointSetUniversalAnchor(FJointId, Anchor.X, Anchor.Y, Anchor.Z);
         dJointSetUniversalAxis1(FJointId, vAxis.X, vAxis.Y, vAxis.Z);
@@ -334,16 +343,16 @@ begin
         dJointSetUniversalParam(FJointId, dParamLoStop2, ParamLoStop2);
         dJointSetUniversalParam(FJointId, dParamHiStop2, ParamHiStop2);
       end;
-    end;
+  end;
   with TGLODERagdollCube(FGeom.data) do
   begin
     Visible := FRagdoll.ShowBoundingBoxes;
     Material.FrontProperties.Diffuse.SetColor(1, 0, 0, 0.4);
-    CubeWidth:= boneSize.X;
-    CubeHeight:= boneSize.Y;
-    CubeDepth:= boneSize.Z;
-    Bone:= Self;
-    Ragdoll:= Self.FRagdoll;
+    CubeWidth := boneSize.X;
+    CubeHeight := boneSize.Y;
+    CubeDepth := boneSize.Z;
+    Bone := Self;
+    Ragdoll := Self.FRagdoll;
   end;
 end;
 
@@ -353,7 +362,7 @@ var
 begin
   inherited;
   dBodyDestroy(FBody);
-  if Assigned(FGeom.data) then
+  if assigned(FGeom.data) then
   begin
     o := TGLBaseSceneObject(FGeom.data);
     FRagdoll.GLSceneRoot.Remove(o, False);
@@ -367,8 +376,8 @@ end;
 procedure TGLODERagdollBone.Update;
 begin
   PositionSceneObject(TGLBaseSceneObject(PdxGeom(FGeom.data)), FGeom);
-  Ragdoll.Owner.Skeleton.BoneByID(BoneID).SetGlobalMatrixForRagDoll(
-    TGLBaseSceneObject(PdxGeom(FGeom.data)).AbsoluteMatrix);
+  Ragdoll.Owner.Skeleton.BoneByID(BoneID).SetGlobalMatrixForRagDoll
+    (TGLBaseSceneObject(PdxGeom(FGeom.data)).AbsoluteMatrix);
 end;
 
 procedure TGLODERagdollBone.Align;
@@ -382,16 +391,16 @@ end;
 //
 constructor TGLODERagdoll.Create(aOwner: TGLBaseMesh);
 begin
-  inherited Create(AOwner);
+  inherited Create(aOwner);
   FShowBoundingBoxes := False;
 end;
 
-//-------------------------------------------------
+// -------------------------------------------------
 initialization
-//-------------------------------------------------
+
+// -------------------------------------------------
 
 vODERagdoll_cDensity := 20;
 vODERagdoll_cMass := 1;
 
-
 end.

+ 3 - 2
Source/Physics.ODESkeletonColliders.pas

@@ -1,7 +1,6 @@
 //
 // The graphics rendering engine GLScene http://glscene.org
 //
-
 unit Physics.ODESkeletonColliders;
 
 (* Skeleton colliders for defining and controlling ODE geoms. *)
@@ -10,6 +9,8 @@ interface
 
 uses
   System.Classes,
+
+  GLS.VectorTypes,
   GLS.PersistentClasses,
   GLS.VectorGeometry,
   GLS.VectorFileObjects,
@@ -133,7 +134,7 @@ end;
 procedure TSCODEBase.AlignCollider;
 var
   R: TdMatrix3;
-  Mat: TMatrix;
+  Mat: TGLMatrix;
 begin
   inherited;
   if Assigned(FGeom) then

+ 12 - 12
Source/Physics.ODEUtils.pas

@@ -35,10 +35,10 @@ procedure DrawBox(Sides: TdVector3);
 procedure setTransform(pos: TdVector3; R: TdMatrix3);
 procedure dsDrawBox(pos: PdVector3; R: PdMatrix3; Sides: TdVector3); overload;
 procedure dsDrawBox(pos: TdVector3; R: TdMatrix3; Sides: TdVector3); overload;
-procedure ODERToGLSceneMatrix(var m: TMatrix; R: TdMatrix3; pos: TdVector3); overload;
-procedure ODERToGLSceneMatrix(var m: TMatrix; R: PdMatrix3; pos: PdVector3); overload;
-procedure ODERToGLSceneMatrix(var m: TMatrix; R: TdMatrix3_As3x4; pos:  TdVector3); overload;
-function GLSceneMatrixToODER(m: TMatrix): TdMatrix3;
+procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: TdMatrix3; pos: TdVector3); overload;
+procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: PdMatrix3; pos: PdVector3); overload;
+procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: TdMatrix3_As3x4; pos:  TdVector3); overload;
+function GLSceneMatrixToODER(m: TGLMatrix): TdMatrix3;
 
 // Converting between ODE and GLScene formats
 function ConvertdVector3ToVector3f(R: TdVector3): TVector3f; overload;
@@ -73,7 +73,7 @@ function CreateTriMeshFromBaseMesh(
   var Vertices: PdVector3Array;
   var Indices: PdIntegerArray): PdxGeom;
 
-function GLMatrixFromGeom(Geom: PdxGeom): TMatrix;
+function GLMatrixFromGeom(Geom: PdxGeom): TGLMatrix;
 function GLDirectionFromGeom(Geom: PdxGeom): TGLVector;
 function CreateODEPlaneFromGLPlane(Plane: TGLPlane; Space: PdxSpace): PdxGeom;
 procedure RenderGeomList(GeomList: TGeomList);
@@ -85,7 +85,7 @@ function RandomColorVector: TGLVector;
 implementation
 //---------------------------------------------------------------------------
 
-procedure ODERToGLSceneMatrix(var m: TMatrix; R: TdMatrix3_As3x4; pos: TdVector3); overload;
+procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: TdMatrix3_As3x4; pos: TdVector3); overload;
 begin
   m.X.X := r[0][0];
   m.X.Y := r[0][1];
@@ -108,12 +108,12 @@ begin
   m.W.W := 1; //}
 end;
 
-procedure ODERToGLSceneMatrix(var m: TMatrix; R: PdMatrix3; pos: PdVector3);
+procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: PdMatrix3; pos: PdVector3);
 begin
   ODERToGLSceneMatrix(m, TdMatrix3_As3x4(R^), pos^);
 end;
 
-procedure ODERToGLSceneMatrix(var m: TMatrix; R: TdMatrix3; pos: TdVector3);
+procedure ODERToGLSceneMatrix(var m: TGLMatrix; R: TdMatrix3; pos: TdVector3);
 begin
   ODERToGLSceneMatrix(m, TdMatrix3_As3x4(R), pos);
 end;
@@ -163,7 +163,7 @@ begin
   gl.End_();
 end;
 
-function GLSceneMatrixToODER(m: TMatrix): TdMatrix3;
+function GLSceneMatrixToODER(m: TGLMatrix): TdMatrix3;
 begin
   TransposeMatrix(m);
   Result[0] := m.X.X;
@@ -302,7 +302,7 @@ begin
     PositionSceneObject(TGLBaseSceneObject(Geom.Data), Geom);
 end;
 
-function GLMatrixFromGeom(Geom: PdxGeom): TMatrix;
+function GLMatrixFromGeom(Geom: PdxGeom): TGLMatrix;
 var
   pos, Pos2: PdVector3;
   R, R2: PdMatrix3;
@@ -346,7 +346,7 @@ end;
 
 function GLDirectionFromGeom(Geom: PdxGeom): TGLVector;
 var
-  m: TMatrix;
+  m: TGLMatrix;
 begin
   m := GLMatrixFromGeom(Geom);
 
@@ -376,7 +376,7 @@ end;
 procedure CopyPosFromGeomToGL(Geom: PdxGeom; GLBaseSceneObject: TGLBaseSceneObject);
 var
   v: TGLVector;
-  m: TMatrix;
+  m: TGLMatrix;
 
   R: PdMatrix3;
   pos: PdVector3;

+ 3 - 3
Source/Physics.SPIInertias.pas

@@ -158,7 +158,7 @@ type
     class function FriendlyName: String; override;
     class function FriendlyDescription: String; override;
     class function UniqueItem: Boolean; override;
-    // function Star(Vector:TAffineVector):TMatrix;
+    // function Star(Vector:TAffineVector):TGLMatrix;
     function QuaternionToString(Quat: TQuaternion): String;
     procedure RemoveForces(); override;
     procedure SetTorque(x, y, z: Real);
@@ -700,7 +700,7 @@ begin
 end;
 
 (*
- function TGLRigidBodyInertia.Star(Vector:TAffineVector):TMatrix;
+ function TGLRigidBodyInertia.Star(Vector:TAffineVector):TGLMatrix;
   begin
   Result.X.X:=0;             Result[0][1]:=-Vector[2];  Result[0][2]:=Vector[1];  Result[0][3]:=0;
   Result[1][0]:=Vector[2];   Result[1][1]:=0;           Result[1][2]:=-Vector[0]; Result[1][3]:=0;
@@ -792,7 +792,7 @@ var
   IRt: TAffineMAtrix;
   Rt: TAffineMAtrix;
   Scale: TAffineVector;
-  RMatrix: TMatrix;
+  RMatrix: TGLMatrix;
 begin
   // TODO: sort this out
   fBodyInverseInertiaTensor := IdentityMatrix;

+ 2 - 2
Source/Physics.SPIJoints.pas

@@ -1,7 +1,6 @@
 //
 // The graphics rendering engine GLScene http://glscene.org
 //
-
 unit Physics.SPIJoints;
 
 (*
@@ -12,6 +11,7 @@ unit Physics.SPIJoints;
 interface
 
 uses
+  GLS.VectorTypes,
   GLS.Scene,
   GLS.VectorGeometry;
 
@@ -71,7 +71,7 @@ type
     // [    0               0                            0                 1         ]
     //
 *)
-    A: TMatrix;
+    A: TGLMatrix;
     constructor Create(LinkLength, TwistAngle, LinkAngle, LinkDistance: Real);
     // constructor Create();virtual;
   end;

+ 1 - 0
Source/Sounds.OpenAL.pas

@@ -28,6 +28,7 @@ uses
   Vcl.Forms,
   Vcl.Dialogs,
 
+  GLS.VectorTypes,
   GLS.Scene,
   GLS.VectorGeometry,
   GLS.Sound,