Procházet zdrojové kódy

Upgraded VerletTypes

GLScene před 4 roky
rodič
revize
ed64c83bba
51 změnil soubory, kde provedl 1081 přidání a 1092 odebrání
  1. 1 1
      AdvDemos/Delphi/TextureTB/FTTBMain.pas
  2. 0 1
      CleanRelease.bat
  3. binární
      Demos/Delphi/meshes/ActorProxy.jpg
  4. binární
      Demos/Delphi/meshes/ActorTwocam.jpg
  5. 3 0
      Demos/Delphi/meshes/Actorms3dFm.pas
  6. binární
      Demos/Delphi/meshes/Centering.jpg
  7. binární
      Demos/Delphi/meshes/Csg.jpg
  8. binární
      Demos/Delphi/meshes/Ducky.jpg
  9. 0 1
      Demos/Delphi/meshes/DuckyFm.dfm
  10. 9 0
      Demos/Delphi/meshes/ExPolygon.dproj
  11. binární
      Demos/Delphi/meshes/ExPolygon.jpg
  12. 0 1
      Demos/Delphi/meshes/ExPolygonFm.dfm
  13. binární
      Demos/Delphi/meshes/Formula.jpg
  14. binární
      Demos/Delphi/meshes/Mushroom.jpg
  15. binární
      Demos/Delphi/meshes/Portal.jpg
  16. binární
      Demos/Delphi/meshes/ShadedTerrain.jpg
  17. 3 3
      Demos/Delphi/meshes/Skeletal.dpr
  18. 1 3
      Demos/Delphi/meshes/Skeletal.dproj
  19. binární
      Demos/Delphi/meshes/Skeletal.jpg
  20. 7 7
      Demos/Delphi/meshes/Subdivide.dpr
  21. 1 3
      Demos/Delphi/meshes/Subdivide.dproj
  22. binární
      Demos/Delphi/meshes/Subdivide.jpg
  23. binární
      Demos/Delphi/meshes/SynthTerrain.jpg
  24. binární
      Demos/Delphi/meshes/Terrain.jpg
  25. binární
      Demos/Delphi/meshes/Tiles.jpg
  26. binární
      Demos/Delphi/meshes/Tree.jpg
  27. 0 1
      Demos/Delphi/meshes/TreeFm.dfm
  28. 1 1
      Demos/Delphi/meshes/TreeFm.pas
  29. 168 66
      Demos/Delphi/meshes/aMeshes.htm
  30. 64 77
      Demos/Delphi/physics/ClothActorFm.pas
  31. binární
      Demos/media/TRINITYrage.glsc
  32. 4 4
      Source/GLS.BaseClasses.pas
  33. 2 2
      Source/GLS.Blur.pas
  34. 1 1
      Source/GLS.BumpmapHDS.pas
  35. 0 1
      Source/GLS.Coordinates.pas
  36. 7 7
      Source/GLS.FileBMP.pas
  37. 52 53
      Source/GLS.Graphics.pas
  38. 0 4
      Source/GLS.Gui.pas
  39. 0 1
      Source/GLS.Objects.pas
  40. 1 1
      Source/GLS.ParticleFX.pas
  41. 1 1
      Source/GLS.PerlinPFX.pas
  42. 1 1
      Source/GLS.ProcTextures.pas
  43. 0 2
      Source/GLS.ProjectedTextures.pas
  44. 1 2
      Source/GLS.ShadowHDS.pas
  45. 39 117
      Source/GLS.SpacePartition.pas
  46. 320 354
      Source/GLS.VerletClothify.pas
  47. 83 83
      Source/GLS.VerletHairClasses.pas
  48. 73 75
      Source/GLS.VerletSkeletonColliders.pas
  49. 234 214
      Source/GLS.VerletTypes.pas
  50. 1 1
      Source/GLS.zBuffer.pas
  51. 3 3
      Source/Physics.ODEUtils.pas

+ 1 - 1
AdvDemos/Delphi/TextureTB/FTTBMain.pas

@@ -246,7 +246,7 @@ var
    bmp : TBitmap;
    bmp : TBitmap;
    bmp32 : TGLBitmap32;
    bmp32 : TGLBitmap32;
    x, y : Integer;
    x, y : Integer;
-   pSrc : PPixel32Array;
+   pSrc : PGLPixel32Array;
    pDest : PIntegerArray;
    pDest : PIntegerArray;
    c : Integer;
    c : Integer;
 begin
 begin

+ 0 - 1
CleanRelease.bat

@@ -19,7 +19,6 @@ del *.rst /s
 del *.s /s
 del *.s /s
 del *.a /s
 del *.a /s
 del *.map /s
 del *.map /s
-del *.rsm /s
 del *.drc /s
 del *.drc /s
 del *.local /s
 del *.local /s
 
 

binární
Demos/Delphi/meshes/ActorProxy.jpg


binární
Demos/Delphi/meshes/ActorTwocam.jpg


+ 3 - 0
Demos/Delphi/meshes/Actorms3dFm.pas

@@ -139,6 +139,9 @@ begin
   GLSArchiveManager1.Archives[0].LoadFromFile('ActorMS3D.zlib');
   GLSArchiveManager1.Archives[0].LoadFromFile('ActorMS3D.zlib');
 
 
 //  MatLib.TextureByName('floor_parquet').Image.LoadFromFile('ashwood.jpg');
 //  MatLib.TextureByName('floor_parquet').Image.LoadFromFile('ashwood.jpg');
+//  MatLib.LibMaterialByName('floor_parquet').Material.Texture.Image.LoadFromFile('beigemarble.jpg');
+//  MatLib.TextureByName('floor_parquet').Image.LoadFromFile('beigemarble.jpg');
+
   LoadTexture('floor_parquet', 'JPG');
   LoadTexture('floor_parquet', 'JPG');
   LoadTexture('Chair', 'PNG');
   LoadTexture('Chair', 'PNG');
   LoadTexture('Hair', 'PNG');
   LoadTexture('Hair', 'PNG');

binární
Demos/Delphi/meshes/Centering.jpg


binární
Demos/Delphi/meshes/Csg.jpg


binární
Demos/Delphi/meshes/Ducky.jpg


+ 0 - 1
Demos/Delphi/meshes/DuckyFm.dfm

@@ -12,7 +12,6 @@ object FormDucky: TFormDucky
   Font.Style = []
   Font.Style = []
   OldCreateOrder = False
   OldCreateOrder = False
   Position = poScreenCenter
   Position = poScreenCenter
-  WindowState = wsMaximized
   OnCreate = FormCreate
   OnCreate = FormCreate
   PixelsPerInch = 96
   PixelsPerInch = 96
   TextHeight = 13
   TextHeight = 13

+ 9 - 0
Demos/Delphi/meshes/ExPolygon.dproj

@@ -28,6 +28,12 @@
         <CfgParent>Base</CfgParent>
         <CfgParent>Base</CfgParent>
         <Base>true</Base>
         <Base>true</Base>
     </PropertyGroup>
     </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
+        <Cfg_1_Win32>true</Cfg_1_Win32>
+        <CfgParent>Cfg_1</CfgParent>
+        <Cfg_1>true</Cfg_1>
+        <Base>true</Base>
+    </PropertyGroup>
     <PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win64)'!=''">
     <PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win64)'!=''">
         <Cfg_1_Win64>true</Cfg_1_Win64>
         <Cfg_1_Win64>true</Cfg_1_Win64>
         <CfgParent>Cfg_1</CfgParent>
         <CfgParent>Cfg_1</CfgParent>
@@ -89,6 +95,9 @@
         <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
         <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
         <DCC_DebugInformation>0</DCC_DebugInformation>
         <DCC_DebugInformation>0</DCC_DebugInformation>
     </PropertyGroup>
     </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
+        <BT_BuildType>Debug</BT_BuildType>
+    </PropertyGroup>
     <PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
     <PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
         <AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
         <AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
         <AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
         <AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>

binární
Demos/Delphi/meshes/ExPolygon.jpg


+ 0 - 1
Demos/Delphi/meshes/ExPolygonFm.dfm

@@ -11,7 +11,6 @@ object FormExPolygon: TFormExPolygon
   Font.Name = 'MS Sans Serif'
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   Font.Style = []
   OldCreateOrder = False
   OldCreateOrder = False
-  WindowState = wsMaximized
   OnShow = FormShow
   OnShow = FormShow
   PixelsPerInch = 96
   PixelsPerInch = 96
   TextHeight = 13
   TextHeight = 13

binární
Demos/Delphi/meshes/Formula.jpg


binární
Demos/Delphi/meshes/Mushroom.jpg


binární
Demos/Delphi/meshes/Portal.jpg


binární
Demos/Delphi/meshes/ShadedTerrain.jpg


+ 3 - 3
Demos/Delphi/meshes/Skeletal.dpr

@@ -1,4 +1,4 @@
-{: Basic Skeletal Animation sample.
+(* Basic Skeletal Animation sample.
 
 
    This demo loads a SMD model and 3 of its animation (SMD are part of and
    This demo loads a SMD model and 3 of its animation (SMD are part of and
    Half-Life MDL file, and may be extracted to individual files with tools
    Half-Life MDL file, and may be extracted to individual files with tools
@@ -23,12 +23,12 @@
 
 
    Model Author: Neal 'Guplik' Corbett, edited by ~A.u.s.t.i.n. ([email protected])<br>
    Model Author: Neal 'Guplik' Corbett, edited by ~A.u.s.t.i.n. ([email protected])<br>
    Thanks!
    Thanks!
-}
+*)
 program Skeletal;
 program Skeletal;
 
 
 uses
 uses
   Forms,
   Forms,
-  SkeletalFm in 'SkeletalFm.pas' {FormSkeletal};
+  SkeletalFm in 'SkeletalFm.pas';
 
 
 {$R *.RES}
 {$R *.RES}
 
 

+ 1 - 3
Demos/Delphi/meshes/Skeletal.dproj

@@ -114,9 +114,7 @@
         <DelphiCompile Include="$(MainSource)">
         <DelphiCompile Include="$(MainSource)">
             <MainSource>MainSource</MainSource>
             <MainSource>MainSource</MainSource>
         </DelphiCompile>
         </DelphiCompile>
-        <DCCReference Include="SkeletalFm.pas">
-            <Form>FormSkeletal</Form>
-        </DCCReference>
+        <DCCReference Include="SkeletalFm.pas"/>
         <BuildConfiguration Include="Debug">
         <BuildConfiguration Include="Debug">
             <Key>Cfg_2</Key>
             <Key>Cfg_2</Key>
             <CfgParent>Base</CfgParent>
             <CfgParent>Base</CfgParent>

binární
Demos/Delphi/meshes/Skeletal.jpg


+ 7 - 7
Demos/Delphi/meshes/Subdivide.dpr

@@ -1,14 +1,14 @@
-{: Early mesh subdivision refinement demo.
-
-   Yes, it's slow, the edge data construction is not optimized, and the MD2
-   format isn't really suited for refinement (that's approx 200 frames we have
-   to subdivide and keep in memory... but it's good for benchmarking!).
-}
+(*
+  Early mesh subdivision refinement demo.
+  Yes, it's slow, the edge data construction is not optimized, and the MD2
+  format isn't really suited for refinement (that's approx 200 frames we have
+  to subdivide and keep in memory... but it's good for benchmarking!).
+*)
 program Subdivide;
 program Subdivide;
 
 
 uses
 uses
   Forms,
   Forms,
-  SubdivideFm in 'SubdivideFm.pas' {FormSubdivide};
+  SubdivideFm in 'SubdivideFm.pas';
 
 
 {$R *.res}
 {$R *.res}
 
 

+ 1 - 3
Demos/Delphi/meshes/Subdivide.dproj

@@ -88,9 +88,7 @@
         <DelphiCompile Include="$(MainSource)">
         <DelphiCompile Include="$(MainSource)">
             <MainSource>MainSource</MainSource>
             <MainSource>MainSource</MainSource>
         </DelphiCompile>
         </DelphiCompile>
-        <DCCReference Include="SubdivideFm.pas">
-            <Form>FormSubdivide</Form>
-        </DCCReference>
+        <DCCReference Include="SubdivideFm.pas"/>
         <BuildConfiguration Include="Debug">
         <BuildConfiguration Include="Debug">
             <Key>Cfg_2</Key>
             <Key>Cfg_2</Key>
             <CfgParent>Base</CfgParent>
             <CfgParent>Base</CfgParent>

binární
Demos/Delphi/meshes/Subdivide.jpg


binární
Demos/Delphi/meshes/SynthTerrain.jpg


binární
Demos/Delphi/meshes/Terrain.jpg


binární
Demos/Delphi/meshes/Tiles.jpg


binární
Demos/Delphi/meshes/Tree.jpg


+ 0 - 1
Demos/Delphi/meshes/TreeFm.dfm

@@ -13,7 +13,6 @@ object FormTree: TFormTree
   Menu = MainMenu1
   Menu = MainMenu1
   OldCreateOrder = False
   OldCreateOrder = False
   Position = poScreenCenter
   Position = poScreenCenter
-  WindowState = wsMaximized
   OnCreate = FormCreate
   OnCreate = FormCreate
   PixelsPerInch = 96
   PixelsPerInch = 96
   TextHeight = 13
   TextHeight = 13

+ 1 - 1
Demos/Delphi/meshes/TreeFm.pas

@@ -347,7 +347,7 @@ end;
 
 
 procedure TFormTree.Exit1Click(Sender: TObject);
 procedure TFormTree.Exit1Click(Sender: TObject);
 begin
 begin
-  Form1.Close;
+  FormTree.Close;
 end;
 end;
 
 
 procedure TFormTree.LeafFrontTexture1Click(Sender: TObject);
 procedure TFormTree.LeafFrontTexture1Click(Sender: TObject);

+ 168 - 66
Demos/Delphi/meshes/aMeshes.htm

@@ -8,9 +8,6 @@
 <!--
 <!--
  /* Font Definitions */
  /* Font Definitions */
  @font-face
  @font-face
-	{font-family:Wingdings;
-	panose-1:5 0 0 0 0 0 0 0 0 0;}
-@font-face
 	{font-family:"Cambria Math";
 	{font-family:"Cambria Math";
 	panose-1:2 4 5 3 5 4 6 3 2 4;}
 	panose-1:2 4 5 3 5 4 6 3 2 4;}
 @font-face
 @font-face
@@ -44,6 +41,12 @@ span.a
 	{mso-style-name:"\0422\0435\043A\0441\0442 \0417\043D\0430\043A";
 	{mso-style-name:"\0422\0435\043A\0441\0442 \0417\043D\0430\043A";
 	mso-style-link:\0422\0435\043A\0441\0442;
 	mso-style-link:\0422\0435\043A\0441\0442;
 	font-family:Consolas;}
 	font-family:Consolas;}
+p.msochpdefault, li.msochpdefault, div.msochpdefault
+	{mso-style-name:msochpdefault;
+	margin-right:0cm;
+	margin-left:0cm;
+	font-size:10.0pt;
+	font-family:"Times New Roman",serif;}
 .MsoChpDefault
 .MsoChpDefault
 	{font-size:10.0pt;}
 	{font-size:10.0pt;}
 @page WordSection1
 @page WordSection1
@@ -68,10 +71,10 @@ ul
 <p class=MsoPlainText><b><span lang=FR style='font-size:13.5pt;font-family:
 <p class=MsoPlainText><b><span lang=FR style='font-size:13.5pt;font-family:
 "Courier New"'>Meshes&nbsp;:</span></b></p>
 "Courier New"'>Meshes&nbsp;:</span></b></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="actor/actor.dpr"><b>actor</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
-  <li class=MsoNormal><span lang=FR>using the TActor object to load Quake II
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="actor/actor.dpr"><b>Actor</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
+  <li class=MsoNormal><span lang=FR>using the TGLActor object to load Quake II
       model (.md2)</span></li>
       model (.md2)</span></li>
   <li class=MsoNormal><span lang=FR>displaying an actor's frame names</span></li>
   <li class=MsoNormal><span lang=FR>displaying an actor's frame names</span></li>
   <li class=MsoNormal><span lang=FR>animating an actor (morph animation)</span></li>
   <li class=MsoNormal><span lang=FR>animating an actor (morph animation)</span></li>
@@ -80,18 +83,25 @@ ul
 
 
 <p class=MsoNormal><img border=0 width=521 height=362 src=Actor.jpg></p>
 <p class=MsoNormal><img border=0 width=521 height=362 src=Actor.jpg></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="actorms3d/actorms3d.dpr"><b>actor</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
-  <li class=MsoNormal><span lang=FR>using the TActor object to load Quake II
-      model (.md2)</span></li>
-  <li class=MsoNormal><span lang=FR>displaying an actor's frame names</span></li>
-  <li class=MsoNormal><span lang=FR>animating an actor (morph animation)</span></li>
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="actorms3d/actorms3d.dpr"><b>Actor
+     Proxy</b></a> <b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
+  <li class=MsoNormal><span lang=FR>using the TGLActorProxy object to load
+      Quake II model (.md2)</span></li>
+  <li class=MsoNormal><span lang=FR>animating actors</span></li>
  </ul>
  </ul>
- <li class=MsoNormal><span lang=FR><a href="actortwocam/actortwocam.dpr"><b>actortwocam</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
-  <li class=MsoNormal><span lang=FR>moving a TActor (Quake II model with wepon)
-      in a small scenery</span></li>
+</ul>
+
+<p class=MsoNormal><img border=0 width=518 height=410 src=ActorProxy.jpg></p>
+
+<p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>
+
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="actortwocam/actortwocam.dpr"><b>ActorTwocam</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
+  <li class=MsoNormal><span lang=FR>moving a TGLActor (Quake II model with
+      wepon) in a small scenery</span></li>
   <li class=MsoNormal><span lang=FR>doom-like (keyboard only) movement, with
   <li class=MsoNormal><span lang=FR>doom-like (keyboard only) movement, with
       walk/run, turn/strafe</span></li>
       walk/run, turn/strafe</span></li>
   <li class=MsoNormal><span lang=FR>switching between first-person and
   <li class=MsoNormal><span lang=FR>switching between first-person and
@@ -99,21 +109,41 @@ ul
  </ul>
  </ul>
 </ul>
 </ul>
 
 
-<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+<p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span><img border=0 width=576
+height=375 src=ActorTwocam.jpg></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="centering/centering.dpr"><b>centering</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+<p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>
+
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="centering/centering.dpr"><b>Centering</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>using AutoCentering for a TFreeForm's mesh</span></li>
   <li class=MsoNormal><span lang=FR>using AutoCentering for a TFreeForm's mesh</span></li>
   <li class=MsoNormal><span lang=FR>effects of various AutoCentering options</span></li>
   <li class=MsoNormal><span lang=FR>effects of various AutoCentering options</span></li>
  </ul>
  </ul>
 </ul>
 </ul>
 
 
+<p class=MsoNormal><span lang=FR>&nbsp;</span><img border=0 width=445
+height=294 src=Centering.jpg></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="csg/csg.dpr"><b>csg</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+<p class=MsoNormal>&nbsp;</p>
+
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="csg/csg.dpr"><b>Csg</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>Constructive Solid Geometry.</span></li>
   <li class=MsoNormal><span lang=FR>Constructive Solid Geometry.</span></li>
   <li class=MsoNormal><span lang=FR>The CSG system uses BSP to optimize what
   <li class=MsoNormal><span lang=FR>The CSG system uses BSP to optimize what
       triangles it considers.</span></li>
       triangles it considers.</span></li>
@@ -124,9 +154,13 @@ ul
 
 
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="ducky/ducky.dpr"><b>ducky</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+<p class=MsoNormal><img border=0 width=486 height=409 src=Csg.jpg></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="ducky/ducky.dpr"><b>Ducky</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>Loading NURBS into a GLScene FreeForm/Actor
   <li class=MsoNormal><span lang=FR>Loading NURBS into a GLScene FreeForm/Actor
       object.</span></li>
       object.</span></li>
   <li class=MsoNormal><span lang=FR>Use the resolution slider to increase or
   <li class=MsoNormal><span lang=FR>Use the resolution slider to increase or
@@ -134,12 +168,21 @@ ul
  </ul>
  </ul>
 </ul>
 </ul>
 
 
+<p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span><img border=0 width=458
+height=300 src=Ducky.jpg></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 
 
-<ul type=disc>
+<ul style='margin-top:0cm' type=disc>
  <li class=MsoNormal><span lang=FR><a href="expolygon/expolygon.dpr"><strong>expolygon</strong></a>
  <li class=MsoNormal><span lang=FR><a href="expolygon/expolygon.dpr"><strong>expolygon</strong></a>
      :</span></li>
      :</span></li>
- <ul type=circle>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>using TMultiPolygon for rendering complex
   <li class=MsoNormal><span lang=FR>using TMultiPolygon for rendering complex
       polygons</span></li>
       polygons</span></li>
   <li class=MsoNormal><span lang=FR>automatic tesselation of polygons with
   <li class=MsoNormal><span lang=FR>automatic tesselation of polygons with
@@ -149,9 +192,11 @@ ul
 
 
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="feedback/feedback.dpr"><b>feedback</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+<p class=MsoNormal><img border=0 width=449 height=338 src=ExPolygon.jpg></p>
+
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="feedback/feedback.dpr"><b>Feedback</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>This demo shows how to use a GLFeedback
   <li class=MsoNormal><span lang=FR>This demo shows how to use a GLFeedback
       object to extract mesh data from regular GLScene objects.</span></li>
       object to extract mesh data from regular GLScene objects.</span></li>
   <li class=MsoNormal><span lang=FR>The GLFeedback object</span></li>
   <li class=MsoNormal><span lang=FR>The GLFeedback object</span></li>
@@ -160,9 +205,9 @@ ul
 
 
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="formula/formula.dpr"><b>formula</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="formula/formula.dpr"><b>Formula</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>using the TMesh object to plot a formula in
   <li class=MsoNormal><span lang=FR>using the TMesh object to plot a formula in
       3D</span></li>
       3D</span></li>
   <li class=MsoNormal><span lang=FR>triangle and triangle-strip meshes to make
   <li class=MsoNormal><span lang=FR>triangle and triangle-strip meshes to make
@@ -170,11 +215,23 @@ ul
  </ul>
  </ul>
 </ul>
 </ul>
 
 
+<p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>
+
+<p class=MsoNormal><img border=0 width=537 height=280 src=Formula.jpg></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="mushroom/mushroom.dpr"><b>mushroom</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
+<p class=MsoNormal><span lang=EN-US>&nbsp;</span></p>
+
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="mushroom/mushroom.dpr"><b>Mushroom</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>using the TFreeForm to load a 3DStudio
   <li class=MsoNormal><span lang=FR>using the TFreeForm to load a 3DStudio
       (.3DS) mesh</span></li>
       (.3DS) mesh</span></li>
   <li class=MsoNormal><span lang=FR>using TGLProxyObject to duplicate an object</span></li>
   <li class=MsoNormal><span lang=FR>using TGLProxyObject to duplicate an object</span></li>
@@ -184,9 +241,11 @@ ul
 
 
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 <p class=MsoNormal><span lang=FR>&nbsp;</span></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="portal/portal.dpr"><b>portal</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+<p class=MsoNormal><img border=0 width=415 height=291 src=Mushroom.jpg></p>
+
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="portal/portal.dpr"><b>Portal</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>using the TPortal object to render indoor
   <li class=MsoNormal><span lang=FR>using the TPortal object to render indoor
       scenes</span></li>
       scenes</span></li>
   <li class=MsoNormal><span lang=FR>basic wolfenstein-like &quot;level
   <li class=MsoNormal><span lang=FR>basic wolfenstein-like &quot;level
@@ -194,22 +253,24 @@ ul
  </ul>
  </ul>
 </ul>
 </ul>
 
 
-<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+<p class=MsoNormal><span lang=FR>&nbsp;</span><img border=0 width=621
+height=392 src=Portal.jpg></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="skeletal/skeletal.dpr"><b>skeletal</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="skeletal/skeletal.dpr"><b>Skeletal</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>using the TActor object to an Half-Life
   <li class=MsoNormal><span lang=FR>using the TActor object to an Half-Life
       model (.smd)</span></li>
       model (.smd)</span></li>
   <li class=MsoNormal><span lang=FR>animating an actor (skeletal animation)</span></li>
   <li class=MsoNormal><span lang=FR>animating an actor (skeletal animation)</span></li>
  </ul>
  </ul>
 </ul>
 </ul>
 
 
-<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+<p class=MsoNormal><span lang=FR>&nbsp;</span><img border=0 width=452
+height=378 src=Skeletal.jpg></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="shadedterrain/shadedterrain.dpr"><b>shadedterrain</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="shadedterrain/shadedterrain.dpr"><b>Shadedterrain</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>Shaded terrain rendering demo.</span></li>
   <li class=MsoNormal><span lang=FR>Shaded terrain rendering demo.</span></li>
   <li class=MsoNormal><span lang=FR>...</span></li>
   <li class=MsoNormal><span lang=FR>...</span></li>
  </ul>
  </ul>
@@ -217,34 +278,69 @@ ul
 
 
 <p class=MsoNormal><img border=0 width=610 height=390 src=ShadedTerrain.jpg></p>
 <p class=MsoNormal><img border=0 width=610 height=390 src=ShadedTerrain.jpg></p>
 
 
-<ul type=disc>
- <li class=MsoNormal><span lang=FR><a href="subdivide/subdivide.dpr"><b>subdivide</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+<p class=MsoNormal>&nbsp;</p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="subdivide/subdivide.dpr"><b>Subdivide</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>Early mesh subdivision refinement demo</span></li>
   <li class=MsoNormal><span lang=FR>Early mesh subdivision refinement demo</span></li>
   <li class=MsoNormal><span lang=FR>MD2 format isn't really suited for
   <li class=MsoNormal><span lang=FR>MD2 format isn't really suited for
       refinement</span></li>
       refinement</span></li>
  </ul>
  </ul>
- <li class=MsoNormal><span lang=FR><a href="synthterr/synthterr.dpr"><b>synthterr</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+</ul>
+
+<p class=MsoNormal><img border=0 width=546 height=389 src=Subdivide.jpg></p>
+
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="synthterr/synthterr.dpr"><b>Synthterr</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>using TTerrainRender and TGLCustomHDS</span></li>
   <li class=MsoNormal><span lang=FR>using TTerrainRender and TGLCustomHDS</span></li>
   <li class=MsoNormal><span lang=FR>1D textures</span></li>
   <li class=MsoNormal><span lang=FR>1D textures</span></li>
  </ul>
  </ul>
- <li class=MsoNormal><span lang=FR><a href="terrain/terrain.dpr"><b>terrain</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+</ul>
+
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
+<p class=MsoNormal><img border=0 width=480 height=374 src=SynthTerrain.jpg></p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<ul style='margin-top:0cm' type=disc>
+ <li class=MsoNormal><span lang=FR><a href="terrain/terrain.dpr"><b>Terrain</b></a><b>&nbsp;:</b></span></li>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>using TTerrainRender and TGLBitmapHDS to
   <li class=MsoNormal><span lang=FR>using TTerrainRender and TGLBitmapHDS to
       render a simple landscape</span></li>
       render a simple landscape</span></li>
   <li class=MsoNormal><span lang=FR>Full-screen mode and using
   <li class=MsoNormal><span lang=FR>Full-screen mode and using
       THUDText/TBitmapFont for a FPS counter</span></li>
       THUDText/TBitmapFont for a FPS counter</span></li>
   <li class=MsoNormal><span lang=FR>Positional 3D sounds</span></li>
   <li class=MsoNormal><span lang=FR>Positional 3D sounds</span></li>
  </ul>
  </ul>
- <li class=MsoNormal><span lang=FR><a href="tiles/tiles.dpr"><b>Tile Plane</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
-  <li class=MsoNormal><span lang=FR>Illustrates the use of TGLTilePlane to
-      render an area made of tiled textures placed in a grid.</span></li>
-  <li class=MsoNormal><span lang=FR>...</span></li>
- </ul>
+</ul>
+
+<p class=MsoNormal><img border=0 width=573 height=404 src=Terrain.jpg></p>
+
+<p class=MsoNormal>&nbsp;</p>
+
+<ul style='margin-top:0cm' type=disc>
  <li class=MsoNormal><span lang=FR><a href="tiles/tiles.dpr"><b>Tiles</b></a><b>&nbsp;:</b></span></li>
  <li class=MsoNormal><span lang=FR><a href="tiles/tiles.dpr"><b>Tiles</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>Illustrates the use of TGLTilePlane to
   <li class=MsoNormal><span lang=FR>Illustrates the use of TGLTilePlane to
       render an area made of tiled textures placed in a grid.</span></li>
       render an area made of tiled textures placed in a grid.</span></li>
   <li class=MsoNormal><span lang=FR>The TGLTilePlane object</span></li>
   <li class=MsoNormal><span lang=FR>The TGLTilePlane object</span></li>
@@ -253,15 +349,21 @@ ul
 
 
 <p class=MsoNormal><img border=0 width=518 height=375 src=Tiles.jpg></p>
 <p class=MsoNormal><img border=0 width=518 height=375 src=Tiles.jpg></p>
 
 
-<ul type=disc>
+<p class=MsoNormal>&nbsp;</p>
+
+<ul style='margin-top:0cm' type=disc>
  <li class=MsoNormal><span lang=FR><a href="tree/tree.dpr"><b>tree</b></a><b>&nbsp;:</b></span></li>
  <li class=MsoNormal><span lang=FR><a href="tree/tree.dpr"><b>tree</b></a><b>&nbsp;:</b></span></li>
- <ul type=circle>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>GLTree Editor.</span></li>
   <li class=MsoNormal><span lang=FR>GLTree Editor.</span></li>
   <li class=MsoNormal><span lang=FR>Interactive parameter changes display tree
   <li class=MsoNormal><span lang=FR>Interactive parameter changes display tree
       variations.</span></li>
       variations.</span></li>
  </ul>
  </ul>
 </ul>
 </ul>
 
 
+<p class=MsoNormal><span lang=FR>&nbsp;</span></p>
+
+<p class=MsoNormal><img border=0 width=504 height=425 src=Tree.jpg></p>
+
 <p class=MsoNormal><span lang=FR><a href="../demos.htm">Back</a></span></p>
 <p class=MsoNormal><span lang=FR><a href="../demos.htm">Back</a></span></p>
 
 
 </div>
 </div>

+ 64 - 77
Demos/Delphi/physics/ClothActorFm.pas

@@ -72,8 +72,8 @@ type
   public
   public
     mx, my: Integer;
     mx, my: Integer;
     VerletWorld: TGLVerletWorld;
     VerletWorld: TGLVerletWorld;
-    EdgeDetector: TEdgeDetector;
-    AirResistance: TVFAirResistance;
+    EdgeDetector: TGLEdgeDetector;
+    AirResistance: TGLAirResistanceVF;
   end;
   end;
 
 
 var
 var
@@ -122,9 +122,7 @@ begin
   for i := 0 to BaseMesh.MeshObjects.Count - 1 do
   for i := 0 to BaseMesh.MeshObjects.Count - 1 do
   begin
   begin
     mo := BaseMesh.MeshObjects[i];
     mo := BaseMesh.MeshObjects[i];
-
     FillChar(mo.Normals.List[0], SizeOf(TAffineVector) * mo.Normals.Count, 0);
     FillChar(mo.Normals.List[0], SizeOf(TAffineVector) * mo.Normals.Count, 0);
-
     for j := 0 to mo.FaceGroups.Count - 1 do
     for j := 0 to mo.FaceGroups.Count - 1 do
     begin
     begin
       if mo.FaceGroups[j] is TFGVertexIndexList then
       if mo.FaceGroups[j] is TFGVertexIndexList then
@@ -139,18 +137,18 @@ begin
           mo.Normals.TranslateItem(fg.VertexIndices.List[k], n);
           mo.Normals.TranslateItem(fg.VertexIndices.List[k], n);
           mo.Normals.TranslateItem(fg.VertexIndices.List[k + 1], n);
           mo.Normals.TranslateItem(fg.VertexIndices.List[k + 1], n);
           mo.Normals.TranslateItem(fg.VertexIndices.List[k + 2], n); // }
           mo.Normals.TranslateItem(fg.VertexIndices.List[k + 2], n); // }
-
           Inc(k, 3);
           Inc(k, 3);
         end;
         end;
       end;
       end;
     end;
     end;
     mo.Normals.Normalize;
     mo.Normals.Normalize;
   end;
   end;
-
   BaseMesh.StructureChanged;
   BaseMesh.StructureChanged;
 end;
 end;
 
 
 procedure TFormClothActor.FormCreate(Sender: TObject);
 procedure TFormClothActor.FormCreate(Sender: TObject);
+var
+  FloorVC: TGLFloorVC;
 begin
 begin
   SetGLSceneMediaDir();
   SetGLSceneMediaDir();
   Randomize;
   Randomize;
@@ -182,39 +180,34 @@ begin
   VerletWorld.Iterations := 3;
   VerletWorld.Iterations := 3;
 
 
   // 'Clothify' the cape and add it to the verlet world
   // 'Clothify' the cape and add it to the verlet world
-  EdgeDetector := TEdgeDetector.Create(Cape);
+  EdgeDetector := TGLEdgeDetector.Create(Cape);
   EdgeDetector.ProcessMesh;
   EdgeDetector.ProcessMesh;
   EdgeDetector.AddEdgesAsSticks(VerletWorld, 0.15);
   EdgeDetector.AddEdgesAsSticks(VerletWorld, 0.15);
   EdgeDetector.AddEdgesAsSolidEdges(VerletWorld);
   EdgeDetector.AddEdgesAsSolidEdges(VerletWorld);
   // EdgeDetector.AddOuterEdgesAsSolidEdges(VerletWorld);
   // EdgeDetector.AddOuterEdgesAsSolidEdges(VerletWorld);
 
 
   // Set up verlet gravity and add the floor as a constraint
   // Set up verlet gravity and add the floor as a constraint
-  with TVFGravity.Create(VerletWorld) do
-    Gravity := AffineVectorMake(0, -98.1, 0);
-  with TVCFloor.Create(VerletWorld) do
-  begin
-    Normal := GLPlane1.Direction.AsAffineVector;
-    Location := VectorAdd(GLPlane1.Position.AsAffineVector,
+  TGLGravityVF.Create(VerletWorld).Gravity := AffineVectorMake(0, -98.1, 0);
+  FloorVC := TGLFloorVC.Create(VerletWorld);
+  FloorVC.Normal := GLPlane1.Direction.AsAffineVector;
+  FloorVC.Location := VectorAdd(GLPlane1.Position.AsAffineVector,
       VectorScale(GLPlane1.Direction.AsAffineVector, 0.1));
       VectorScale(GLPlane1.Direction.AsAffineVector, 0.1));
-  end;
-
   // Load the skeleton colliders. Skeleton colliders define an
   // Load the skeleton colliders. Skeleton colliders define an
   // approximate collision boundary for actors and are controlled
   // approximate collision boundary for actors and are controlled
   // by the actor's skeleton.
   // by the actor's skeleton.
-  with GLActor1.Skeleton.Colliders do
-  begin
-    LoadFromFile('trinityRAGE.glsc');
-    AlignColliders;
-  end;
+  GLActor1.Skeleton.Colliders.LoadFromFile('trinityRAGE.glsc');
+  GLActor1.Skeleton.Colliders.AlignColliders;
 
 
   // Add the collider's verlet constraints to the verlet world
   // Add the collider's verlet constraints to the verlet world
   AddSCVerletConstriantsToVerletWorld(GLActor1.Skeleton.Colliders, VerletWorld);
   AddSCVerletConstriantsToVerletWorld(GLActor1.Skeleton.Colliders, VerletWorld);
-
-  (* AirResistance := TVFAirResistance.Create(VerletWorld);
-    AirResistance.DragCoeff := 0.001;
-    AirResistance.WindDirection := AffineVectorMake(0,0,1);
-    AirResistance.WindMagnitude := 15;
-    AirResistance.WindChaos := 2;// *)
+  (*
+  AirResistance := TGLAirResistanceVF.Create(VerletWorld);
+  AirResistance.DragCoeff := 0.001;
+  AirResistance.WindDirection := AffineVectorMake(0,0,1);
+  AirResistance.WindMagnitude := 15;
+  AirResistance.WindChaos := 2;
+  // *)
+  FloorVC.Free;
 end;
 end;
 
 
 procedure TFormClothActor.FormDestroy(Sender: TObject);
 procedure TFormClothActor.FormDestroy(Sender: TObject);
@@ -229,73 +222,67 @@ var
 begin
 begin
   // Step the verlet world (this is where the magic happens)
   // Step the verlet world (this is where the magic happens)
   VerletWorld.Progress(deltaTime, newTime);
   VerletWorld.Progress(deltaTime, newTime);
-
   // Recalculate the cape's normals
   // Recalculate the cape's normals
   RecalcMeshNormals(Cape);
   RecalcMeshNormals(Cape);
-
   // Cycle the floor texture to make it look like it's moving
   // Cycle the floor texture to make it look like it's moving
   GLPlane1.YOffset := GLPlane1.YOffset - 0.25 * deltaTime;
   GLPlane1.YOffset := GLPlane1.YOffset - 0.25 * deltaTime;
   if GLPlane1.YOffset < 0 then
   if GLPlane1.YOffset < 0 then
     GLPlane1.YOffset := GLPlane1.YOffset + 1;
     GLPlane1.YOffset := GLPlane1.YOffset + 1;
-
   // Orbit the light (to show off the pretty shadow volumes)
   // Orbit the light (to show off the pretty shadow volumes)
   GLLightSource1.MoveObjectAround(GLActor1, 0, -deltaTime * 20);
   GLLightSource1.MoveObjectAround(GLActor1, 0, -deltaTime * 20);
   GLLightSource1.PointTo(GLActor1, YHMGVector);
   GLLightSource1.PointTo(GLActor1, YHMGVector);
 end;
 end;
 
 
-procedure TFormClothActor.OctreeRendererRender(Sender: TObject;
-  var rci: TGLRenderContextInfo);
-  procedure RenderAABB(AABB: TAABB; w, r, g, b: single);
-  begin
-    glColor3f(r, g, b);
-    glLineWidth(w);
-
-    glBegin(GL_LINE_STRIP);
-    glVertex3f(AABB.min.X, AABB.min.Y, AABB.min.Z);
-    glVertex3f(AABB.min.X, AABB.max.Y, AABB.min.Z);
-    glVertex3f(AABB.max.X, AABB.max.Y, AABB.min.Z);
-    glVertex3f(AABB.max.X, AABB.min.Y, AABB.min.Z);
-    glVertex3f(AABB.min.X, AABB.min.Y, AABB.min.Z);
-
-    glVertex3f(AABB.min.X, AABB.min.Y, AABB.max.Z);
-    glVertex3f(AABB.min.X, AABB.max.Y, AABB.max.Z);
-    glVertex3f(AABB.max.X, AABB.max.Y, AABB.max.Z);
-    glVertex3f(AABB.max.X, AABB.min.Y, AABB.max.Z);
-    glVertex3f(AABB.min.X, AABB.min.Y, AABB.max.Z);
-    glEnd;
-
-    glBegin(GL_LINES);
-    glVertex3f(AABB.min.X, AABB.max.Y, AABB.min.Z);
-    glVertex3f(AABB.min.X, AABB.max.Y, AABB.max.Z);
-
-    glVertex3f(AABB.max.X, AABB.max.Y, AABB.min.Z);
-    glVertex3f(AABB.max.X, AABB.max.Y, AABB.max.Z);
-
-    glVertex3f(AABB.max.X, AABB.min.Y, AABB.min.Z);
-    glVertex3f(AABB.max.X, AABB.min.Y, AABB.max.Z);
-    glEnd;
-  end;
+procedure RenderAABB(AABB: TAABB; w, r, g, b: single);
+begin
+  glColor3f(r, g, b);
+  glLineWidth(w);
+
+  glBegin(GL_LINE_STRIP);
+  glVertex3f(AABB.min.X, AABB.min.Y, AABB.min.Z);
+  glVertex3f(AABB.min.X, AABB.max.Y, AABB.min.Z);
+  glVertex3f(AABB.max.X, AABB.max.Y, AABB.min.Z);
+  glVertex3f(AABB.max.X, AABB.min.Y, AABB.min.Z);
+  glVertex3f(AABB.min.X, AABB.min.Y, AABB.min.Z);
+  glVertex3f(AABB.min.X, AABB.min.Y, AABB.max.Z);
+  glVertex3f(AABB.min.X, AABB.max.Y, AABB.max.Z);
+  glVertex3f(AABB.max.X, AABB.max.Y, AABB.max.Z);
+  glVertex3f(AABB.max.X, AABB.min.Y, AABB.max.Z);
+  glVertex3f(AABB.min.X, AABB.min.Y, AABB.max.Z);
+  glEnd;
+
+  glBegin(GL_LINES);
+  glVertex3f(AABB.min.X, AABB.max.Y, AABB.min.Z);
+  glVertex3f(AABB.min.X, AABB.max.Y, AABB.max.Z);
+  glVertex3f(AABB.max.X, AABB.max.Y, AABB.min.Z);
+  glVertex3f(AABB.max.X, AABB.max.Y, AABB.max.Z);
+  glVertex3f(AABB.max.X, AABB.min.Y, AABB.min.Z);
+  glVertex3f(AABB.max.X, AABB.min.Y, AABB.max.Z);
+  glEnd;
+end;
 
 
-  procedure RenderOctreeNode(Node: TSectorNode);
-  var
-    i: Integer;
-    AABB: TAABB;
+procedure RenderOctreeNode(Node: TSectorNode);
+var
+  i: Integer;
+  AABB: TAABB;
+begin
+  if Node.NoChildren then
   begin
   begin
-    if Node.NoChildren then
-    begin
-      AABB := Node.AABB;
-      if Node.RecursiveLeafCount > 0 then
-        RenderAABB(AABB, 1, 0, 0, 0)
-      else
-        RenderAABB(AABB, 1, 0.8, 0.8, 0.8) // }
-    end
+    AABB := Node.AABB;
+    if Node.RecursiveLeafCount > 0 then
+      RenderAABB(AABB, 1, 0, 0, 0)
     else
     else
-    begin
-      for i := 0 to Node.ChildCount - 1 do
-        RenderOctreeNode(Node.Children[i]);
-    end;
+      RenderAABB(AABB, 1, 0.8, 0.8, 0.8) // }
+  end
+  else
+  begin
+    for i := 0 to Node.ChildCount - 1 do
+      RenderOctreeNode(Node.Children[i]);
   end;
   end;
+end;
 
 
+procedure TFormClothActor.OctreeRendererRender(Sender: TObject;
+  var rci: TGLRenderContextInfo);
 begin
 begin
   if cbShowOctree.Checked then
   if cbShowOctree.Checked then
   begin
   begin

binární
Demos/media/TRINITYrage.glsc


+ 4 - 4
Source/GLS.BaseClasses.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.BaseClasses;
 unit GLS.BaseClasses;
 
 
 (* Base classes *)
 (* Base classes *)
@@ -17,14 +16,15 @@ uses
 
 
 type
 type
 
 
-  TGLProgressTimes = record
-    deltaTime, newTime: Double
+  TGLProgressTimes = packed record
+    DeltaTime, NewTime: Double;
+    SqrDeltaTime, InvSqrDeltaTime: Single;
   end;
   end;
 
 
   (* Progression event for time-base animations/simulations.
   (* Progression event for time-base animations/simulations.
      deltaTime is the time delta since last progress and newTime is the new
      deltaTime is the time delta since last progress and newTime is the new
      time after the progress event is completed. *)
      time after the progress event is completed. *)
-  TGLProgressEvent = procedure(Sender: TObject; const deltaTime, newTime: Double) of object;
+  TGLProgressEvent = procedure(Sender: TObject; const DeltaTime, NewTime: Double) of object;
 
 
   IGLNotifyAble = interface(IInterface)
   IGLNotifyAble = interface(IInterface)
     ['{00079A6C-D46E-4126-86EE-F9E2951B4593}']
     ['{00079A6C-D46E-4126-86EE-F9E2951B4593}']

+ 2 - 2
Source/GLS.Blur.pas

@@ -246,7 +246,7 @@ var
   refsiz: single;
   refsiz: single;
   BMP: TGLImage;
   BMP: TGLImage;
   x, y: integer;
   x, y: integer;
-  line: PPixel32Array;
+  line: PGLPixel32Array;
   by: Integer;
   by: Integer;
   bp: Integer;
   bp: Integer;
   DoBlur: Boolean;
   DoBlur: Boolean;
@@ -255,7 +255,7 @@ var
   var
   var
     t: integer;
     t: integer;
     x, y: integer;
     x, y: integer;
-    lin, linu, lind, linuu, lindd: PPixel32Array;
+    lin, linu, lind, linuu, lindd: PGLPixel32Array;
     r, g, b: single;
     r, g, b: single;
 
 
     procedure ApplyBlurClampAndSetPixel;
     procedure ApplyBlurClampAndSetPixel;

+ 1 - 1
Source/GLS.BumpmapHDS.pas

@@ -281,7 +281,7 @@ var
   X, Y: Integer;
   X, Y: Integer;
   scaleVec: TAffineVector;
   scaleVec: TAffineVector;
   vec: TAffineVector;
   vec: TAffineVector;
-  nmRow: PPixel32Array;
+  nmRow: PGLPixel32Array;
   px, py: Integer;
   px, py: Integer;
 begin
 begin
   HD := heightData;
   HD := heightData;

+ 0 - 1
Source/GLS.Coordinates.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.Coordinates;
 unit GLS.Coordinates;
 
 
 (* Coordinate related classes and functions *)
 (* Coordinate related classes and functions *)

+ 7 - 7
Source/GLS.FileBMP.pas

@@ -35,7 +35,7 @@ type
     FDeltaY: Integer;
     FDeltaY: Integer;
     function CountBits(Value: byte): shortint;
     function CountBits(Value: byte): shortint;
     function ShiftCount(Mask: longword): shortint;
     function ShiftCount(Mask: longword): shortint;
-    function ExpandColor(Value: longword): TPixel32;
+    function ExpandColor(Value: longword): TGLPixel32;
     procedure ExpandRLE4ScanLine(Row: Integer; Stream: TStream);
     procedure ExpandRLE4ScanLine(Row: Integer; Stream: TStream);
     procedure ExpandRLE8ScanLine(Row: Integer; Stream: TStream);
     procedure ExpandRLE8ScanLine(Row: Integer; Stream: TStream);
     function Monochrome(N: Integer): Integer;
     function Monochrome(N: Integer): Integer;
@@ -173,7 +173,7 @@ begin
   Result := tmp;
   Result := tmp;
 end;
 end;
 
 
-function TGLBMPImage.ExpandColor(Value: longword): TPixel32;
+function TGLBMPImage.ExpandColor(Value: longword): TGLPixel32;
 var
 var
   tmpr, tmpg, tmpb: longword;
   tmpr, tmpg, tmpb: longword;
 begin
 begin
@@ -220,7 +220,7 @@ var
   BitCount, LineSize: Integer;
   BitCount, LineSize: Integer;
   Row: Integer;
   Row: Integer;
   nPalette: Integer;
   nPalette: Integer;
-  LPalette: array of TPixel32;
+  LPalette: array of TGLPixel32;
   BitShiftFunc: TBitShiftFunc;
   BitShiftFunc: TBitShiftFunc;
 
 
   procedure ReadScanLine;
   procedure ReadScanLine;
@@ -231,7 +231,7 @@ var
     begin
     begin
       Stream.Read(FLineBuffer[0], FReadSize);
       Stream.Read(FLineBuffer[0], FReadSize);
       for I := LInfo.Width - 1 downto 0 do
       for I := LInfo.Width - 1 downto 0 do
-        PPixel32Array(Ptr)[I] := LPalette[BitShiftFunc(I)];
+        PGLPixel32Array(Ptr)[I] := LPalette[BitShiftFunc(I)];
     end
     end
     else if LInfo.Compression = BI_RLE8 then
     else if LInfo.Compression = BI_RLE8 then
     begin
     begin
@@ -247,7 +247,7 @@ var
     begin
     begin
       Stream.Read(FLineBuffer[0], FReadSize);
       Stream.Read(FLineBuffer[0], FReadSize);
       for I := LInfo.Width - 1 downto 0 do
       for I := LInfo.Width - 1 downto 0 do
-        PPixel32Array(Ptr)[I] := ExpandColor(PWordArray(FLineBuffer)[I]);
+        PGLPixel32Array(Ptr)[I] := ExpandColor(PWordArray(FLineBuffer)[I]);
     end
     end
     else
     else
       Stream.Read(Ptr^, FReadSize);
       Stream.Read(Ptr^, FReadSize);
@@ -305,9 +305,9 @@ begin
     nPalette := 1 shl LInfo.BitCount;
     nPalette := 1 shl LInfo.BitCount;
     SetLength(LPalette, nPalette);
     SetLength(LPalette, nPalette);
     if LInfo.ClrUsed > 0 then
     if LInfo.ClrUsed > 0 then
-      Stream.Read(LPalette[0], LInfo.ClrUsed * SizeOf(TPixel32))
+      Stream.Read(LPalette[0], LInfo.ClrUsed * SizeOf(TGLPixel32))
     else // Seems to me that this is dangerous.
     else // Seems to me that this is dangerous.
-      Stream.Read(LPalette[0], nPalette * SizeOf(TPixel32));
+      Stream.Read(LPalette[0], nPalette * SizeOf(TGLPixel32));
   end
   end
   else if LInfo.ClrUsed > 0 then { Skip palette }
   else if LInfo.ClrUsed > 0 then { Skip palette }
     Stream.Position := Stream.Position + LInfo.ClrUsed * 3;
     Stream.Position := Stream.Position + LInfo.ClrUsed * 3;

+ 52 - 53
Source/GLS.Graphics.pas

@@ -31,7 +31,7 @@ uses
   {$IFDEF USE_GRAPHICS32} GR32, {$ENDIF}
   {$IFDEF USE_GRAPHICS32} GR32, {$ENDIF}
 
 
   GLS.VectorTypes,
   GLS.VectorTypes,
-  GLS.OpenGLTokens,
+//  GLS.OpenGLTokens,
   GLS.State,
   GLS.State,
   GLS.ApplicationFileIO,
   GLS.ApplicationFileIO,
   GLS.PersistentClasses,
   GLS.PersistentClasses,
@@ -47,19 +47,18 @@ uses
 {$DEFINE PRF_HACK_PASSES}
 {$DEFINE PRF_HACK_PASSES}
 
 
 type
 type
-
-  TPixel24 = packed record
+  TGLPixel24 = packed record
     r, g, b: Byte;
     r, g, b: Byte;
   end;
   end;
-  PPixel24 = ^TPixel24;
+  PGLPixel24 = ^TGLPixel24;
 
 
-  TPixel32 = packed record
+  TGLPixel32 = packed record
     r, g, b, a: Byte;
     r, g, b, a: Byte;
   end;
   end;
-  PPixel32 = ^TPixel32;
+  PGLPixel32 = ^TGLPixel32;
 
 
-  TPixel32Array = array[0..MaxInt shr 3] of TPixel32;
-  PPixel32Array = ^TPixel32Array;
+  TGLPixel32Array = array[0..MaxInt shr 3] of TGLPixel32;
+  PGLPixel32Array = ^TGLPixel32Array;
 
 
   TGLLODStreamingState = (ssKeeping, ssLoading, ssLoaded, ssTransfered);
   TGLLODStreamingState = (ssKeeping, ssLoading, ssLoaded, ssTransfered);
 
 
@@ -88,7 +87,7 @@ type
     procedure ImageStreamingTask; stdcall;
     procedure ImageStreamingTask; stdcall;
 {$ENDIF}
 {$ENDIF}
   protected
   protected
-    fData: PPixel32Array;
+    fData: PGLPixel32Array;
     FLOD: TGLImagePiramid;
     FLOD: TGLImagePiramid;
     fLevelCount: TGLImageLODRange;
     fLevelCount: TGLImageLODRange;
     fColorFormat: Cardinal;
     fColorFormat: Cardinal;
@@ -97,7 +96,7 @@ type
     fElementSize: Integer;
     fElementSize: Integer;
     fCubeMap: Boolean;
     fCubeMap: Boolean;
     fTextureArray: Boolean;
     fTextureArray: Boolean;
-    function GetData: PPixel32Array; virtual;
+    function GetData: PGLPixel32Array; virtual;
     function GetWidth: Integer;
     function GetWidth: Integer;
     function GetHeight: Integer;
     function GetHeight: Integer;
     function GetDepth: Integer;
     function GetDepth: Integer;
@@ -153,7 +152,7 @@ type
     // Leave top level and remove other
     // Leave top level and remove other
     procedure UnMipmap; virtual;
     procedure UnMipmap; virtual;
     // Direct Access to image data
     // Direct Access to image data
-    property Data: PPixel32Array read GetData;
+    property Data: PGLPixel32Array read GetData;
     // Set image of error.
     // Set image of error.
     procedure SetErrorImage;
     procedure SetErrorImage;
     // Recalculate levels information based on first level.
     // Recalculate levels information based on first level.
@@ -206,7 +205,7 @@ type
     procedure SetBlank(const Value: Boolean);
     procedure SetBlank(const Value: Boolean);
     procedure SetCubeMap(const val: Boolean);
     procedure SetCubeMap(const val: Boolean);
     procedure SetArray(const val: Boolean);
     procedure SetArray(const val: Boolean);
-    function GetScanLine(index: Integer): PPixel32Array;
+    function GetScanLine(index: Integer): PGLPixel32Array;
     procedure AssignFrom24BitsBitmap(aBitmap: TBitmap);
     procedure AssignFrom24BitsBitmap(aBitmap: TBitmap);
     procedure AssignFrom32BitsBitmap(aBitmap: TBitmap);
     procedure AssignFrom32BitsBitmap(aBitmap: TBitmap);
 {$IFDEF USE_GRAPHICS32}
 {$IFDEF USE_GRAPHICS32}
@@ -254,7 +253,7 @@ type
     (* Access to a specific Bitmap ScanLine. index should be in the [0; Height[ range.
     (* Access to a specific Bitmap ScanLine. index should be in the [0; Height[ range.
       Warning : this function is NOT protected against invalid indexes,
       Warning : this function is NOT protected against invalid indexes,
       and invoking it is invalid if the bitmap is Empty. *)
       and invoking it is invalid if the bitmap is Empty. *)
-    property ScanLine[index: Integer]: PPixel32Array read GetScanLine;
+    property ScanLine[index: Integer]: PGLPixel32Array read GetScanLine;
     property VerticalReverseOnAssignFromBitmap: Boolean read
     property VerticalReverseOnAssignFromBitmap: Boolean read
       FVerticalReverseOnAssignFromBitmap write
       FVerticalReverseOnAssignFromBitmap write
       FVerticalReverseOnAssignFromBitmap;
       FVerticalReverseOnAssignFromBitmap;
@@ -270,8 +269,8 @@ type
       This makes pixels of given color totally transparent while the others
       This makes pixels of given color totally transparent while the others
       are completely opaque. *)
       are completely opaque. *)
     procedure SetAlphaTransparentForColor(const aColor: TColor); overload;
     procedure SetAlphaTransparentForColor(const aColor: TColor); overload;
-    procedure SetAlphaTransparentForColor(const aColor: TPixel32); overload;
-    procedure SetAlphaTransparentForColor(const aColor: TPixel24); overload;
+    procedure SetAlphaTransparentForColor(const aColor: TGLPixel32); overload;
+    procedure SetAlphaTransparentForColor(const aColor: TGLPixel24); overload;
     // Set Alpha channel values to given byte value.
     // Set Alpha channel values to given byte value.
     procedure SetAlphaToValue(const aValue: Byte);
     procedure SetAlphaToValue(const aValue: Byte);
     // Set Alpha channel values to given float [0..1] value.
     // Set Alpha channel values to given float [0..1] value.
@@ -314,7 +313,7 @@ type
 
 
   TGLBitmap32 = TGLImage;
   TGLBitmap32 = TGLImage;
 
 
-  TRasterFileFormat = class
+  TGLRasterFileFormat = class
   public
   public
     BaseImageClass: TGLBaseImageClass;
     BaseImageClass: TGLBaseImageClass;
     Extension: string;
     Extension: string;
@@ -323,7 +322,7 @@ type
   end;
   end;
 
 
   // Stores registered raster file formats.
   // Stores registered raster file formats.
-  TRasterFileFormatsList = class(TPersistentObjectList)
+  TGLRasterFileFormatsList = class(TPersistentObjectList)
   public
   public
     destructor Destroy; override;
     destructor Destroy; override;
     procedure Add(const Ext, Desc: string; DescID: Integer; AClass:
     procedure Add(const Ext, Desc: string; DescID: Integer; AClass:
@@ -351,7 +350,7 @@ procedure BGRA32ToRGBA32(src, dest: Pointer; pixelCount: Integer);
 procedure GammaCorrectRGBArray(base: Pointer; pixelCount: Integer; gamma: Single);
 procedure GammaCorrectRGBArray(base: Pointer; pixelCount: Integer; gamma: Single);
 procedure BrightenRGBArray(base: Pointer; pixelCount: Integer; factor: Single);
 procedure BrightenRGBArray(base: Pointer; pixelCount: Integer; factor: Single);
 // Read access to the list of registered vector file formats
 // Read access to the list of registered vector file formats
-function GetRasterFileFormats: TRasterFileFormatsList;
+function GetRasterFileFormats: TGLRasterFileFormatsList;
 (* Returns an extension by its index
 (* Returns an extension by its index
    in the internal image files dialogs filter.
    in the internal image files dialogs filter.
    Use InternalImageFileFormatsFilter to obtain the filter. *)
    Use InternalImageFileFormatsFilter to obtain the filter. *)
@@ -379,14 +378,14 @@ implementation
 // ------------------------------------------------------------------
 // ------------------------------------------------------------------
 
 
 var
 var
-  vRasterFileFormats: TRasterFileFormatsList;
+  vRasterFileFormats: TGLRasterFileFormatsList;
 
 
 // ------------------------------ Raster File Registries
 // ------------------------------ Raster File Registries
 
 
-function GetRasterFileFormats: TRasterFileFormatsList;
+function GetRasterFileFormats: TGLRasterFileFormatsList;
 begin
 begin
   if not Assigned(vRasterFileFormats) then
   if not Assigned(vRasterFileFormats) then
-    vRasterFileFormats := TRasterFileFormatsList.Create;
+    vRasterFileFormats := TGLRasterFileFormatsList.Create;
   Result := vRasterFileFormats;
   Result := vRasterFileFormats;
 end;
 end;
 
 
@@ -408,18 +407,18 @@ begin
   Result := GetRasterFileFormats.FindExtByIndex(index);
   Result := GetRasterFileFormats.FindExtByIndex(index);
 end;
 end;
 
 
-destructor TRasterFileFormatsList.Destroy;
+destructor TGLRasterFileFormatsList.Destroy;
 begin
 begin
   Clean;
   Clean;
   inherited;
   inherited;
 end;
 end;
 
 
-procedure TRasterFileFormatsList.Add(const Ext, Desc: string; DescID: Integer;
+procedure TGLRasterFileFormatsList.Add(const Ext, Desc: string; DescID: Integer;
   AClass: TGLBaseImageClass);
   AClass: TGLBaseImageClass);
 var
 var
-  newRec: TRasterFileFormat;
+  newRec: TGLRasterFileFormat;
 begin
 begin
-  newRec := TRasterFileFormat.Create;
+  newRec := TGLRasterFileFormat.Create;
   with newRec do
   with newRec do
   begin
   begin
     Extension := AnsiLowerCase(Ext);
     Extension := AnsiLowerCase(Ext);
@@ -430,13 +429,13 @@ begin
   inherited Add(newRec);
   inherited Add(newRec);
 end;
 end;
 
 
-function TRasterFileFormatsList.FindExt(Ext: string): TGLBaseImageClass;
+function TGLRasterFileFormatsList.FindExt(Ext: string): TGLBaseImageClass;
 var
 var
   i: Integer;
   i: Integer;
 begin
 begin
   Ext := AnsiLowerCase(Ext);
   Ext := AnsiLowerCase(Ext);
   for i := Count - 1 downto 0 do
   for i := Count - 1 downto 0 do
-    with TRasterFileFormat(Items[i]) do
+    with TGLRasterFileFormat(Items[i]) do
     begin
     begin
       if Extension = Ext then
       if Extension = Ext then
       begin
       begin
@@ -447,7 +446,7 @@ begin
   Result := nil;
   Result := nil;
 end;
 end;
 
 
-function TRasterFileFormatsList.FindFromFileName(const fileName: string):
+function TGLRasterFileFormatsList.FindFromFileName(const fileName: string):
   TGLBaseImageClass;
   TGLBaseImageClass;
 var
 var
   Ext: string;
   Ext: string;
@@ -460,7 +459,7 @@ begin
       [Ext, 'GLFile' + UpperCase(Ext)]);
       [Ext, 'GLFile' + UpperCase(Ext)]);
 end;
 end;
 
 
-function TRasterFileFormatsList.FindFromStream(const AStream: TStream): TGLBaseImageClass;
+function TGLRasterFileFormatsList.FindFromStream(const AStream: TStream): TGLBaseImageClass;
 var
 var
   Ext: string;
   Ext: string;
   magic: array [0 .. 1] of LongWord;
   magic: array [0 .. 1] of LongWord;
@@ -487,32 +486,32 @@ begin
       [Ext, 'GLFile' + UpperCase(Ext)]);
       [Ext, 'GLFile' + UpperCase(Ext)]);
 end;
 end;
 
 
-procedure TRasterFileFormatsList.Remove(AClass: TGLBaseImageClass);
+procedure TGLRasterFileFormatsList.Remove(AClass: TGLBaseImageClass);
 var
 var
   i: Integer;
   i: Integer;
 begin
 begin
   for i := Count - 1 downto 0 do
   for i := Count - 1 downto 0 do
   begin
   begin
-    if TRasterFileFormat(Items[i]).BaseImageClass.InheritsFrom(AClass) then
+    if TGLRasterFileFormat(Items[i]).BaseImageClass.InheritsFrom(AClass) then
       DeleteAndFree(i);
       DeleteAndFree(i);
   end;
   end;
 end;
 end;
 
 
-procedure TRasterFileFormatsList.BuildFilterStrings(
+procedure TGLRasterFileFormatsList.BuildFilterStrings(
   imageFileClass: TGLBaseImageClass;
   imageFileClass: TGLBaseImageClass;
   var descriptions, filters: string;
   var descriptions, filters: string;
   formatsThatCanBeOpened: Boolean = True;
   formatsThatCanBeOpened: Boolean = True;
   formatsThatCanBeSaved: Boolean = False);
   formatsThatCanBeSaved: Boolean = False);
 var
 var
   k, i: Integer;
   k, i: Integer;
-  p: TRasterFileFormat;
+  p: TGLRasterFileFormat;
 begin
 begin
   descriptions := '';
   descriptions := '';
   filters := '';
   filters := '';
   k := 0;
   k := 0;
   for i := 0 to Count - 1 do
   for i := 0 to Count - 1 do
   begin
   begin
-    p := TRasterFileFormat(Items[i]);
+    p := TGLRasterFileFormat(Items[i]);
     if p.BaseImageClass.InheritsFrom(imageFileClass) and (p.Extension <> '')
     if p.BaseImageClass.InheritsFrom(imageFileClass) and (p.Extension <> '')
       and ((formatsThatCanBeOpened and (dfcRead in
       and ((formatsThatCanBeOpened and (dfcRead in
       p.BaseImageClass.Capabilities))
       p.BaseImageClass.Capabilities))
@@ -539,19 +538,19 @@ begin
       [sAllFilter, filters, descriptions]);
       [sAllFilter, filters, descriptions]);
 end;
 end;
 
 
-function TRasterFileFormatsList.FindExtByIndex(index: Integer;
+function TGLRasterFileFormatsList.FindExtByIndex(index: Integer;
   formatsThatCanBeOpened: Boolean = True;
   formatsThatCanBeOpened: Boolean = True;
   formatsThatCanBeSaved: Boolean = False): string;
   formatsThatCanBeSaved: Boolean = False): string;
 var
 var
   i: Integer;
   i: Integer;
-  p: TRasterFileFormat;
+  p: TGLRasterFileFormat;
 begin
 begin
   Result := '';
   Result := '';
   if index > 0 then
   if index > 0 then
   begin
   begin
     for i := 0 to Count - 1 do
     for i := 0 to Count - 1 do
     begin
     begin
-      p := TRasterFileFormat(Items[i]);
+      p := TGLRasterFileFormat(Items[i]);
       if (formatsThatCanBeOpened and (dfcRead in p.BaseImageClass.Capabilities))
       if (formatsThatCanBeOpened and (dfcRead in p.BaseImageClass.Capabilities))
         or (formatsThatCanBeSaved and (dfcWrite in
         or (formatsThatCanBeSaved and (dfcWrite in
         p.BaseImageClass.Capabilities)) then
         p.BaseImageClass.Capabilities)) then
@@ -1363,7 +1362,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TGLBaseImage.GetData: PPixel32Array;
+function TGLBaseImage.GetData: PGLPixel32Array;
 begin
 begin
   Result := fData;
   Result := fData;
 end;
 end;
@@ -2390,7 +2389,7 @@ procedure TGLImage.AssignFromPngImage(aPngImage: TPngImage);
 var
 var
   i, j: Integer;
   i, j: Integer;
   SourceScan: PRGBLine;
   SourceScan: PRGBLine;
-  DestScan: PPixel32Array;
+  DestScan: PGLPixel32Array;
   AlphaScan: VCL.Imaging.Pngimage.PByteArray;
   AlphaScan: VCL.Imaging.Pngimage.PByteArray;
   Pixel: Integer;
   Pixel: Integer;
 begin
 begin
@@ -2619,10 +2618,10 @@ begin
   DataConvertTask;
   DataConvertTask;
 end;
 end;
 
 
-function TGLImage.GetScanLine(index: Integer): PPixel32Array;
+function TGLImage.GetScanLine(index: Integer): PGLPixel32Array;
 begin
 begin
   Narrow;
   Narrow;
-  Result := PPixel32Array(@fData[index * GetWidth]);
+  Result := PGLPixel32Array(@fData[index * GetWidth]);
 end;
 end;
 
 
 procedure TGLImage.SetAlphaFromIntensity;
 procedure TGLImage.SetAlphaFromIntensity;
@@ -2637,7 +2636,7 @@ end;
 
 
 procedure TGLImage.SetAlphaTransparentForColor(const aColor: TColor);
 procedure TGLImage.SetAlphaTransparentForColor(const aColor: TColor);
 var
 var
-  color: TPixel24;
+  color: TGLPixel24;
 begin
 begin
   color.r := GetRValue(aColor);
   color.r := GetRValue(aColor);
   color.g := GetGValue(aColor);
   color.g := GetGValue(aColor);
@@ -2645,9 +2644,9 @@ begin
   SetAlphaTransparentForColor(color);
   SetAlphaTransparentForColor(color);
 end;
 end;
 
 
-procedure TGLImage.SetAlphaTransparentForColor(const aColor: TPixel32);
+procedure TGLImage.SetAlphaTransparentForColor(const aColor: TGLPixel32);
 var
 var
-  color: TPixel24;
+  color: TGLPixel24;
 begin
 begin
   color.r := aColor.r;
   color.r := aColor.r;
   color.g := aColor.g;
   color.g := aColor.g;
@@ -2655,7 +2654,7 @@ begin
   SetAlphaTransparentForColor(color);
   SetAlphaTransparentForColor(color);
 end;
 end;
 
 
-procedure TGLImage.SetAlphaTransparentForColor(const aColor: TPixel24);
+procedure TGLImage.SetAlphaTransparentForColor(const aColor: TGLPixel24);
 var
 var
   i: Integer;
   i: Integer;
   intCol: Integer;
   intCol: Integer;
@@ -2724,10 +2723,10 @@ end;
 
 
 procedure TGLImage.DownSampleByFactor2;
 procedure TGLImage.DownSampleByFactor2;
 type
 type
-  T2Pixel32 = packed array[0..1] of TPixel32;
+  T2Pixel32 = packed array[0..1] of TGLPixel32;
   P2Pixel32 = ^T2Pixel32;
   P2Pixel32 = ^T2Pixel32;
 
 
-  procedure ProcessRowPascal(pDest: PPixel32; pLineA, pLineB: P2Pixel32; n:
+  procedure ProcessRowPascal(pDest: PGLPixel32; pLineA, pLineB: P2Pixel32; n:
     Integer);
     Integer);
   var
   var
     i: Integer;
     i: Integer;
@@ -2750,7 +2749,7 @@ type
 
 
 var
 var
   y, w2, h2: Integer;
   y, w2, h2: Integer;
-  pDest: PPixel32;
+  pDest: PGLPixel32;
   pLineA, pLineB: P2Pixel32;
   pLineA, pLineB: P2Pixel32;
 begin
 begin
   if (GetWidth <= 1) or (GetHeight <= 1) then
   if (GetWidth <= 1) or (GetHeight <= 1) then
@@ -2806,9 +2805,9 @@ var
   dcx, dcy: Single;
   dcx, dcy: Single;
   invLen: Single;
   invLen: Single;
   maskX, maskY: Integer;
   maskX, maskY: Integer;
-  curRow, nextRow, prevRow: PPixel32Array;
-  normalMapBuffer: PPixel32Array;
-  p: PPixel32;
+  curRow, nextRow, prevRow: PGLPixel32Array;
+  normalMapBuffer: PGLPixel32Array;
+  p: PGLPixel32;
 begin
 begin
   if Assigned(FData) then
   if Assigned(FData) then
   begin
   begin
@@ -2875,8 +2874,8 @@ var
   x, y: Integer;
   x, y: Integer;
   sr, sg, sb: Single;
   sr, sg, sb: Single;
   invLen: Single;
   invLen: Single;
-  curRow: PPixel32Array;
-  p: PPixel32;
+  curRow: PGLPixel32Array;
+  p: PGLPixel32;
 const
 const
   cInv128: Single = 1 / 128;
   cInv128: Single = 1 / 128;
 begin
 begin

+ 0 - 4
Source/GLS.Gui.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.Gui;
 unit GLS.Gui;
 
 
 (* Windows management classes and structures *)
 (* Windows management classes and structures *)
@@ -118,7 +117,6 @@ type
   end;
   end;
 
 
   TGLGuiComponentName = string;
   TGLGuiComponentName = string;
-
   TGLGuiComponentList = class;
   TGLGuiComponentList = class;
 
 
   TGLGuiComponent = class(TCollectionItem)
   TGLGuiComponent = class(TCollectionItem)
@@ -572,7 +570,6 @@ begin
     begin
     begin
       TmpComponent := FGuiComponents.Items[xc];
       TmpComponent := FGuiComponents.Items[xc];
       Data.WriteString(TmpComponent.FName);
       Data.WriteString(TmpComponent.FName);
-
       Data.WriteInteger(TmpComponent.FElements.Count);
       Data.WriteInteger(TmpComponent.FElements.Count);
 
 
       for YC := 0 to TmpComponent.FElements.Count - 1 do
       for YC := 0 to TmpComponent.FElements.Count - 1 do
@@ -601,7 +598,6 @@ begin
         end;
         end;
 
 
         Data.WriteInteger(Alignments);
         Data.WriteInteger(Alignments);
-
         for TmpAlignment := GLAlTopLeft to GLAlBorder do
         for TmpAlignment := GLAlTopLeft to GLAlBorder do
         begin
         begin
           if TmpAlignment = TmpElement.FAlign then
           if TmpAlignment = TmpElement.FAlign then

+ 0 - 1
Source/GLS.Objects.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.Objects;
 unit GLS.Objects;
 
 
 (*
 (*

+ 1 - 1
Source/GLS.ParticleFX.pas

@@ -2852,7 +2852,7 @@ var
   s: Integer;
   s: Integer;
   x, y, d, h2: Integer;
   x, y, d, h2: Integer;
   ih2, f, fy: Single;
   ih2, f, fy: Single;
-  scanLine1, scanLine2: PPixel32Array;
+  scanLine1, scanLine2: PGLPixel32Array;
 begin
 begin
   s := (1 shl TexMapSize);
   s := (1 shl TexMapSize);
   bmp32.Width := s;
   bmp32.Width := s;

+ 1 - 1
Source/GLS.PerlinPFX.pas

@@ -212,7 +212,7 @@ procedure TGLPerlinPFXManager.PrepareImage(bmp32: TGLBitmap32; var texFormat: In
     x, y, d: Integer;
     x, y, d: Integer;
     is2, f, fy, pf, nBase, nAmp, df, dfg: Single;
     is2, f, fy, pf, nBase, nAmp, df, dfg: Single;
     invGamma: Single;
     invGamma: Single;
-    scanLine: PPixel32Array;
+    scanLine: PGLPixel32Array;
     gotIntensityCorrection: Boolean;
     gotIntensityCorrection: Boolean;
   begin
   begin
     s2 := s shr 1;
     s2 := s shr 1;

+ 1 - 1
Source/GLS.ProcTextures.pas

@@ -119,7 +119,7 @@ end;
 procedure TGLProcTextureNoise.UpdateNoise;
 procedure TGLProcTextureNoise.UpdateNoise;
 var
 var
   X, Y, C: Integer;
   X, Y, C: Integer;
-  Line: PPixel32Array;
+  Line: PGLPixel32Array;
   nf: Single;
   nf: Single;
   n: Byte;
   n: Byte;
 
 

+ 0 - 2
Source/GLS.ProjectedTextures.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.ProjectedTextures;
 unit GLS.ProjectedTextures;
 
 
 (* Implements projected textures through an object. *)
 (* Implements projected textures through an object. *)
@@ -145,7 +144,6 @@ end;
 // ------------------ TGLTextureEmitterItem ------------------
 // ------------------ TGLTextureEmitterItem ------------------
 // ------------------
 // ------------------
 
 
-
 constructor TGLTextureEmitterItem.Create(ACollection: TCollection);
 constructor TGLTextureEmitterItem.Create(ACollection: TCollection);
 begin
 begin
   inherited Create(ACollection);
   inherited Create(ACollection);

+ 1 - 2
Source/GLS.ShadowHDS.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.ShadowHDS;
 unit GLS.ShadowHDS;
 
 
 (*
 (*
@@ -588,7 +587,7 @@ var
   sh, h: single;
   sh, h: single;
   HD: TGLHeightData;
   HD: TGLHeightData;
   Size: integer;
   Size: integer;
-  nmRow: PPixel32Array;
+  nmRow: PGLPixel32Array;
   ctr: integer;
   ctr: integer;
   px, py: integer;
   px, py: integer;
   lum: byte;
   lum: byte;

+ 39 - 117
Source/GLS.SpacePartition.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.SpacePartition;
 unit GLS.SpacePartition;
 
 
 (*
 (*
@@ -58,7 +57,7 @@ type
   TBaseSpacePartition = class;
   TBaseSpacePartition = class;
 
 
   // Describes a cone, and is used for cone collision
   // Describes a cone, and is used for cone collision
-  TSPCone = record
+  TGLConeSP = record
     // The base of the cone
     // The base of the cone
     Base: TAffineVector;
     Base: TAffineVector;
     // The axis of the cone
     // The axis of the cone
@@ -70,7 +69,7 @@ type
   end;
   end;
 
 
   // Extended frustum, used for fast intersection testing
   // Extended frustum, used for fast intersection testing
-  TExtendedFrustum = record
+  TGLExtendedFrustum = record
     Frustum: TFrustum;
     Frustum: TFrustum;
     BSphere: TBSphere;
     BSphere: TBSphere;
     // SPCone : TSPCone;
     // SPCone : TSPCone;
@@ -126,7 +125,7 @@ type
   private
   private
     FCullingMode: TCullingMode;
     FCullingMode: TCullingMode;
     // Query space for Leaves that intersect a cone, result is returned through QueryResult
     // Query space for Leaves that intersect a cone, result is returned through QueryResult
-    function QueryCone(const ACone: TSPCone): Integer; virtual;
+    function QueryCone(const ACone: TGLConeSP): Integer; virtual;
   protected
   protected
     FQueryResult: TSpacePartitionLeafList;
     FQueryResult: TSpacePartitionLeafList;
     FQueryInterObjectTests: Integer;
     FQueryInterObjectTests: Integer;
@@ -163,7 +162,7 @@ type
     (* Query space for Leaves that intersect an extended frustum. Result is
     (* Query space for Leaves that intersect an extended frustum. Result is
       returned through QueryResult. Extended frustum is slightly faster than the
       returned through QueryResult. Extended frustum is slightly faster than the
       regular frustum because it uses a bounding sphere for the frustum *)
       regular frustum because it uses a bounding sphere for the frustum *)
-    function QueryFrustumEx(const ExtendedFrustum: TExtendedFrustum): Integer; virtual;
+    function QueryFrustumEx(const ExtendedFrustum: TGLExtendedFrustum): Integer; virtual;
     (* Once a query has been run, this number tells of how many inter object
     (* Once a query has been run, this number tells of how many inter object
       tests that were run. This value must be set by all that override the queries *)
       tests that were run. This value must be set by all that override the queries *)
     property QueryInterObjectTests: Integer read FQueryInterObjectTests;
     property QueryInterObjectTests: Integer read FQueryInterObjectTests;
@@ -183,7 +182,7 @@ type
   private
   private
     FLeaves: TSpacePartitionLeafList;
     FLeaves: TSpacePartitionLeafList;
     // Query space for Leaves that intersect a cone, result is returned through QueryResult
     // Query space for Leaves that intersect a cone, result is returned through QueryResult
-    function QueryCone(const ACone: TSPCone): Integer; override;
+    function QueryCone(const ACone: TGLConeSP): Integer; override;
   public
   public
     // Clear all internal storage Leaves
     // Clear all internal storage Leaves
     procedure Clear; override;
     procedure Clear; override;
@@ -305,7 +304,7 @@ type
     // Query the node and its children for leaves that match the Frustum
     // Query the node and its children for leaves that match the Frustum
     procedure QueryFrustum(const Frustum: TFrustum; const QueryResult: TSpacePartitionLeafList);
     procedure QueryFrustum(const Frustum: TFrustum; const QueryResult: TSpacePartitionLeafList);
     // Query the node and its children for leaves that match the extended frustum
     // Query the node and its children for leaves that match the extended frustum
-    procedure QueryFrustumEx(const ExtendedFrustum: TExtendedFrustum; const QueryResult: TSpacePartitionLeafList);
+    procedure QueryFrustumEx(const ExtendedFrustum: TGLExtendedFrustum; const QueryResult: TSpacePartitionLeafList);
     (* Adds all leaves to query result without testing if they intersect, and
     (* Adds all leaves to query result without testing if they intersect, and
       then do the same for all children. This is used when QueryAABB or
       then do the same for all children. This is used when QueryAABB or
       QueryBSphere determines that a node fits completely in the searched space *)
       QueryBSphere determines that a node fits completely in the searched space *)
@@ -367,7 +366,7 @@ type
     function QueryFrustum(const Frustum: TFrustum): Integer; override;
     function QueryFrustum(const Frustum: TFrustum): Integer; override;
     (* Query space for Leaves that intersect an extended frustum. Result is
     (* Query space for Leaves that intersect an extended frustum. Result is
       returned through QueryResult *)
       returned through QueryResult *)
-    function QueryFrustumEx(const ExtendedFrustum: TExtendedFrustum): Integer; override;
+    function QueryFrustumEx(const ExtendedFrustum: TGLExtendedFrustum): Integer; override;
     (* After a query has been run, this value will contain the number of nodes
     (* After a query has been run, this value will contain the number of nodes
       that were checked during the query *)
       that were checked during the query *)
     property QueryNodeTests: Integer read FQueryNodeTests;
     property QueryNodeTests: Integer read FQueryNodeTests;
@@ -479,10 +478,10 @@ procedure RenderSpatialPartitioning(var rci: TGLRenderContextInfo;
 (*Create an extended frustum from a GLSceneViewer - this makes the unit
 (*Create an extended frustum from a GLSceneViewer - this makes the unit
   specific to the windows platform!*)
   specific to the windows platform!*)
 function ExtendedFrustumMakeFromSceneViewer(const AFrustum: TFrustum;
 function ExtendedFrustumMakeFromSceneViewer(const AFrustum: TFrustum;
-  const vWidth, vHeight: integer; AGLCamera: TGLCamera): TExtendedFrustum; overload;
+  const vWidth, vHeight: integer; AGLCamera: TGLCamera): TGLExtendedFrustum; overload;
 
 
 function ExtendedFrustumMakeFromSceneViewer(const AFrustum: TFrustum;
 function ExtendedFrustumMakeFromSceneViewer(const AFrustum: TFrustum;
-  const AGLSceneViewer: TGLSceneViewer): TExtendedFrustum; overload;
+  const AGLSceneViewer: TGLSceneViewer): TGLExtendedFrustum; overload;
 
 
 // Renders an AABB as a line
 // Renders an AABB as a line
 procedure RenderAABB(var rci: TGLRenderContextInfo; const AABB: TAABB; w, r, g, b: single); overload;
 procedure RenderAABB(var rci: TGLRenderContextInfo; const AABB: TAABB; w, r, g, b: single); overload;
@@ -490,13 +489,13 @@ procedure RenderAABB(var rci: TGLRenderContextInfo; const AABB: TAABB); overload
 
 
 
 
 // Determines to which extent one Cone contains an BSphere
 // Determines to which extent one Cone contains an BSphere
-function ConeContainsBSphere(const Cone: TSPCone; const BSphere: TBSphere): TSpaceContains;
+function ConeContainsBSphere(const Cone: TGLConeSP; const BSphere: TBSphere): TSpaceContains;
 // Determines if a extended frustum intersects an BSphere
 // Determines if a extended frustum intersects an BSphere
-function ExtendedFrustumIntersectsBSphere(const AExtendedFrustum: TExtendedFrustum; const ABSphere: TBSphere): Boolean;
+function ExtendedFrustumIntersectsBSphere(const AExtendedFrustum: TGLExtendedFrustum; const ABSphere: TBSphere): Boolean;
 // Create an extended frustum from a number of values
 // Create an extended frustum from a number of values
 function ExtendedFrustumMake(const AFrustum: TFrustum; const ANearDist, AFarDist, AFieldOfViewRadians: Single;
 function ExtendedFrustumMake(const AFrustum: TFrustum; const ANearDist, AFarDist, AFieldOfViewRadians: Single;
   const ACameraPosition, ALookVector: TAffineVector { ;
   const ACameraPosition, ALookVector: TAffineVector { ;
-  const AScreenWidth, AScreenHeight : integer { } ): TExtendedFrustum;
+  const AScreenWidth, AScreenHeight : integer { } ): TGLExtendedFrustum;
 
 
 //---------------------------------------------------
 //---------------------------------------------------
 implementation
 implementation
@@ -531,7 +530,7 @@ const
     (CMAX, CMID, CMID) // Lower Back Right
     (CMAX, CMID, CMID) // Lower Back Right
     );
     );
 
 
-function ConeContainsBSphere(const Cone: TSPCone; const BSphere: TBSphere): TSpaceContains;
+function ConeContainsBSphere(const Cone: TGLConeSP; const BSphere: TBSphere): TSpaceContains;
 var
 var
   U, D: TAffineVector;
   U, D: TAffineVector;
   E, Dsqr: Single;
   E, Dsqr: Single;
@@ -575,7 +574,7 @@ begin
     Result := ScNoOverlap;
     Result := ScNoOverlap;
 end; // }
 end; // }
 
 
-function ExtendedFrustumIntersectsBSphere(const AExtendedFrustum: TExtendedFrustum; const ABSphere: TBSphere): Boolean;
+function ExtendedFrustumIntersectsBSphere(const AExtendedFrustum: TGLExtendedFrustum; const ABSphere: TBSphere): Boolean;
 begin
 begin
   // Test if the bounding sphere of the node intersect the bounding sphere of the
   // Test if the bounding sphere of the node intersect the bounding sphere of the
   // frustum? This test is exremely fast
   // frustum? This test is exremely fast
@@ -592,7 +591,7 @@ end;
 
 
 function ExtendedFrustumMake(const AFrustum: TFrustum; const ANearDist, AFarDist, AFieldOfViewRadians: Single;
 function ExtendedFrustumMake(const AFrustum: TFrustum; const ANearDist, AFarDist, AFieldOfViewRadians: Single;
   const ACameraPosition, ALookVector: TAffineVector { ;
   const ACameraPosition, ALookVector: TAffineVector { ;
-    const AScreenWidth, AScreenHeight : integer{ } ): TExtendedFrustum;
+    const AScreenWidth, AScreenHeight : integer{ } ): TGLExtendedFrustum;
 var
 var
   ViewLen: Single;
   ViewLen: Single;
   Height, Width: Single;
   Height, Width: Single;
@@ -762,7 +761,7 @@ begin
   Result := 0;
   Result := 0;
 end;
 end;
 
 
-function TBaseSpacePartition.QueryCone(const ACone: TSPCone): Integer;
+function TBaseSpacePartition.QueryCone(const ACone: TGLConeSP): Integer;
 begin
 begin
   // Virtual
   // Virtual
   Result := 0;
   Result := 0;
@@ -793,7 +792,7 @@ begin
   Result := 0;
   Result := 0;
 end;
 end;
 
 
-function TBaseSpacePartition.QueryFrustumEx(const ExtendedFrustum: TExtendedFrustum): Integer;
+function TBaseSpacePartition.QueryFrustumEx(const ExtendedFrustum: TGLExtendedFrustum): Integer;
 begin
 begin
   // Virtual
   // Virtual
   Result := 0;
   Result := 0;
@@ -880,11 +879,10 @@ begin
     if Distance2 < Sqr(Leaf.FCachedBSphere.Radius + ABSphere.Radius) then
     if Distance2 < Sqr(Leaf.FCachedBSphere.Radius + ABSphere.Radius) then
       FQueryResult.Add(Leaf);
       FQueryResult.Add(Leaf);
   end;
   end;
-
   Result := FQueryResult.Count;
   Result := FQueryResult.Count;
 end;
 end;
 
 
-function TLeavedSpacePartition.QueryCone(const ACone: TSPCone): Integer;
+function TLeavedSpacePartition.QueryCone(const ACone: TGLConeSP): Integer;
 var
 var
   I: Integer;
   I: Integer;
 begin
 begin
@@ -898,7 +896,6 @@ begin
     if ConeContainsBSphere(ACone, Leaves[I].FCachedBSphere) <> ScNoOverlap then
     if ConeContainsBSphere(ACone, Leaves[I].FCachedBSphere) <> ScNoOverlap then
       FQueryResult.Add(Leaves[I]);
       FQueryResult.Add(Leaves[I]);
   end;
   end;
-
   Result := FQueryResult.Count;
   Result := FQueryResult.Count;
 end;
 end;
 
 
@@ -910,26 +907,22 @@ var
 begin
 begin
   // Very brute force!
   // Very brute force!
   FlushQueryResult;
   FlushQueryResult;
-
   for I := 0 to Leaves.Count - 1 do
   for I := 0 to Leaves.Count - 1 do
   begin
   begin
     Inc(FQueryInterObjectTests);
     Inc(FQueryInterObjectTests);
-
     Leaf := Leaves[I];
     Leaf := Leaves[I];
-
     CurrentPenetrationDepth := -(PointPlaneDistance(Leaf.FCachedBSphere.Center, FLocation, FNormal) -
     CurrentPenetrationDepth := -(PointPlaneDistance(Leaf.FCachedBSphere.Center, FLocation, FNormal) -
       Leaf.FCachedBSphere.Radius);
       Leaf.FCachedBSphere.Radius);
-
     // Correct the node location
     // Correct the node location
     if CurrentPenetrationDepth > 0 then
     if CurrentPenetrationDepth > 0 then
       FQueryResult.Add(Leaves[I]);
       FQueryResult.Add(Leaves[I]);
   end; // }
   end; // }
-
   Result := FQueryResult.Count;
   Result := FQueryResult.Count;
 end;
 end;
 
 
-{ TSectorNode }
-
+//-------------------------------------
+// TSectorNode
+//-------------------------------------
 function TSectorNode.AABBFitsInNode(const AAABB: TAABB): Boolean;
 function TSectorNode.AABBFitsInNode(const AAABB: TAABB): Boolean;
 begin
 begin
   Result := ContainsAABB(AAABB) in [ScContainsFully];
   Result := ContainsAABB(AAABB) in [ScContainsFully];
@@ -1048,18 +1041,14 @@ begin
   for I := 0 to FChildCount - 1 do
   for I := 0 to FChildCount - 1 do
   begin
   begin
     FChildren[I].CollapseNode;
     FChildren[I].CollapseNode;
-
     for J := 0 to FChildren[I].FLeaves.Count - 1 do
     for J := 0 to FChildren[I].FLeaves.Count - 1 do
     begin
     begin
       FChildren[I].FLeaves[J].FPartitionTag := Self;
       FChildren[I].FLeaves[J].FPartitionTag := Self;
       FLeaves.Add(FChildren[I].FLeaves[J]);
       FLeaves.Add(FChildren[I].FLeaves[J]);
     end;
     end;
-
     FChildren[I].FLeaves.Clear;
     FChildren[I].FLeaves.Clear;
-
     FreeAndNil(FChildren[I]);
     FreeAndNil(FChildren[I]);
   end;
   end;
-
   FChildCount := 0;
   FChildCount := 0;
 end;
 end;
 
 
@@ -1080,7 +1069,6 @@ var
   I: Integer;
   I: Integer;
 begin
 begin
   Result := 1;
   Result := 1;
-
   for I := 0 to FChildCount - 1 do
   for I := 0 to FChildCount - 1 do
     Result := Result + FChildren[I].GetNodeCount;
     Result := Result + FChildren[I].GetNodeCount;
 end;
 end;
@@ -1091,13 +1079,11 @@ var
 begin
 begin
   // Which child does it fit in?
   // Which child does it fit in?
   ChildNode := GetChildForAABB(ALeaf.FCachedAABB);
   ChildNode := GetChildForAABB(ALeaf.FCachedAABB);
-
   if ChildNode <> nil then
   if ChildNode <> nil then
   begin
   begin
     Result := ChildNode.AddLeaf(ALeaf);
     Result := ChildNode.AddLeaf(ALeaf);
     Exit;
     Exit;
   end; // }
   end; // }
-
   // Doesn't fit the any child
   // Doesn't fit the any child
   ALeaf.FPartitionTag := Self;
   ALeaf.FPartitionTag := Self;
   FLeaves.Add(ALeaf);
   FLeaves.Add(ALeaf);
@@ -1126,7 +1112,6 @@ begin
       for I := 0 to FLeaves.Count - 1 do
       for I := 0 to FLeaves.Count - 1 do
       begin
       begin
         Inc(FSectoredSpacePartition.FQueryInterObjectTests);
         Inc(FSectoredSpacePartition.FQueryInterObjectTests);
-
         if IntersectAABBsAbsolute(FLeaves[I].FCachedAABB, AAABB) then
         if IntersectAABBsAbsolute(FLeaves[I].FCachedAABB, AAABB) then
           QueryResult.Add(FLeaves[I]);
           QueryResult.Add(FLeaves[I]);
       end;
       end;
@@ -1136,7 +1121,6 @@ begin
       for I := 0 to FLeaves.Count - 1 do
       for I := 0 to FLeaves.Count - 1 do
         QueryResult.Add(FLeaves[I]);
         QueryResult.Add(FLeaves[I]);
     end;
     end;
-
     // Recursively let the children add their leaves
     // Recursively let the children add their leaves
     for I := 0 to FChildCount - 1 do
     for I := 0 to FChildCount - 1 do
       FChildren[I].QueryAABB(AAABB, QueryResult);
       FChildren[I].QueryAABB(AAABB, QueryResult);
@@ -1149,9 +1133,7 @@ var
   SpaceContains: TSpaceContains;
   SpaceContains: TSpaceContains;
 begin
 begin
   Inc(FSectoredSpacePartition.FQueryNodeTests);
   Inc(FSectoredSpacePartition.FQueryNodeTests);
-
   SpaceContains := BSphereContainsSector(ABSphere);
   SpaceContains := BSphereContainsSector(ABSphere);
-
   if SpaceContains = ScContainsFully then
   if SpaceContains = ScContainsFully then
   begin
   begin
     AddAllLeavesRecursive(QueryResult);
     AddAllLeavesRecursive(QueryResult);
@@ -1171,7 +1153,6 @@ begin
     else
     else
       for I := 0 to FLeaves.Count - 1 do
       for I := 0 to FLeaves.Count - 1 do
         QueryResult.Add(FLeaves[I]);
         QueryResult.Add(FLeaves[I]);
-
     // Recursively let the children add their leaves
     // Recursively let the children add their leaves
     for I := 0 to FChildCount - 1 do
     for I := 0 to FChildCount - 1 do
       FChildren[I].QueryBSphere(ABSphere, QueryResult);
       FChildren[I].QueryBSphere(ABSphere, QueryResult);
@@ -1184,9 +1165,7 @@ var
   SpaceContains: TSpaceContains;
   SpaceContains: TSpaceContains;
 begin
 begin
   Inc(FSectoredSpacePartition.FQueryNodeTests);
   Inc(FSectoredSpacePartition.FQueryNodeTests);
-
   SpaceContains := PlaneContainsBSphere(Location, Normal, FBSphere);
   SpaceContains := PlaneContainsBSphere(Location, Normal, FBSphere);
-
   if SpaceContains = ScContainsFully then
   if SpaceContains = ScContainsFully then
   begin
   begin
     AddAllLeavesRecursive(QueryResult);
     AddAllLeavesRecursive(QueryResult);
@@ -1211,7 +1190,8 @@ begin
 
 
       FChildren[I].QueryPlane(Location, Normal, QueryResult);
       FChildren[I].QueryPlane(Location, Normal, QueryResult);
     end;
     end;
-  end; // }
+  end;
+  // *)
 end;
 end;
 
 
 function TSectorNode.RemoveLeaf(ALeaf: TSpacePartitionLeaf; OwnerByThis: Boolean): Boolean;
 function TSectorNode.RemoveLeaf(ALeaf: TSpacePartitionLeaf; OwnerByThis: Boolean): Boolean;
@@ -1232,7 +1212,6 @@ begin
     CollapseNode;
     CollapseNode;
     Result := True;
     Result := True;
   end;
   end;
-
   if Parent <> nil then
   if Parent <> nil then
     Parent.RemoveLeaf(ALeaf, False);
     Parent.RemoveLeaf(ALeaf, False);
 end;
 end;
@@ -1246,7 +1225,6 @@ begin
     Result := Format('Node at depth %d mismatches, %d<>%d!', [FNodeDepth, FRecursiveLeafCount, CalcRecursiveLeafCount]);
     Result := Format('Node at depth %d mismatches, %d<>%d!', [FNodeDepth, FRecursiveLeafCount, CalcRecursiveLeafCount]);
     Exit;
     Exit;
   end;
   end;
-
   for I := 0 to FChildCount - 1 do
   for I := 0 to FChildCount - 1 do
   begin
   begin
     Result := FChildren[I].VerifyRecursiveLeafCount;
     Result := FChildren[I].VerifyRecursiveLeafCount;
@@ -1283,7 +1261,6 @@ end;
 procedure TSectorNode.SetAABB(const Value: TAABB);
 procedure TSectorNode.SetAABB(const Value: TAABB);
 begin
 begin
   FAABB := Value;
   FAABB := Value;
-
   AABBToBSphere(FAABB, FBSphere);
   AABBToBSphere(FAABB, FBSphere);
 end;
 end;
 
 
@@ -1297,27 +1274,19 @@ begin
   // Instead of looping through all children, we simply determine on which
   // Instead of looping through all children, we simply determine on which
   // side of the center node the child is located
   // side of the center node the child is located
   ChildNodeIndex := 0;
   ChildNodeIndex := 0;
-
   Location := AABB.Min;
   Location := AABB.Min;
-
   // Upper / Lower
   // Upper / Lower
   if Location.Y < FBSphere.Center.Y then
   if Location.Y < FBSphere.Center.Y then
     ChildNodeIndex := 4;
     ChildNodeIndex := 4;
-
   // Left / Right
   // Left / Right
   if Location.Z < FBSphere.Center.Z then
   if Location.Z < FBSphere.Center.Z then
     ChildNodeIndex := ChildNodeIndex or 2;
     ChildNodeIndex := ChildNodeIndex or 2;
-
   // Fore / Back
   // Fore / Back
   if Location.X > FBSphere.Center.X then
   if Location.X > FBSphere.Center.X then
     ChildNodeIndex := ChildNodeIndex or 1;
     ChildNodeIndex := ChildNodeIndex or 1;
-
   Assert((ChildNodeIndex >= 0) and (ChildNodeIndex <= 8), Format('ChildNodeIndex is out of range (%d)!', [ChildNodeIndex]));
   Assert((ChildNodeIndex >= 0) and (ChildNodeIndex <= 8), Format('ChildNodeIndex is out of range (%d)!', [ChildNodeIndex]));
-
   ChildNode := FChildren[ChildNodeIndex];
   ChildNode := FChildren[ChildNodeIndex];
-
   Assert(Assigned(ChildNode), 'ChildNode not assigned');
   Assert(Assigned(ChildNode), 'ChildNode not assigned');
-
   if ChildNode.AABBFitsInNode(AABB) then
   if ChildNode.AABBFitsInNode(AABB) then
     Result := ChildNode
     Result := ChildNode
   else
   else
@@ -1341,7 +1310,6 @@ begin
     SpaceContains := FrustumContainsAABB(Frustum, AABB)
     SpaceContains := FrustumContainsAABB(Frustum, AABB)
   else
   else
     SpaceContains := ScNoOverlap;
     SpaceContains := ScNoOverlap;
-
   // If the frustum fully contains the leaf, then we need not check every piece,
   // If the frustum fully contains the leaf, then we need not check every piece,
   // just add them all
   // just add them all
   if SpaceContains = ScContainsFully then
   if SpaceContains = ScContainsFully then
@@ -1349,7 +1317,6 @@ begin
     AddAllLeavesRecursive(QueryResult);
     AddAllLeavesRecursive(QueryResult);
   end
   end
   else
   else
-
     // If the frustum partiall contains the leaf, then we should add the leaves
     // If the frustum partiall contains the leaf, then we should add the leaves
     // that intersect the frustum and recurse for all children
     // that intersect the frustum and recurse for all children
     if SpaceContains = ScContainsPartially then
     if SpaceContains = ScContainsPartially then
@@ -1361,7 +1328,6 @@ begin
         if not IsVolumeClipped(FLeaves[I].FCachedBSphere.Center, FLeaves[I].FCachedBSphere.Radius, Frustum) then
         if not IsVolumeClipped(FLeaves[I].FCachedBSphere.Center, FLeaves[I].FCachedBSphere.Radius, Frustum) then
           QueryResult.Add(FLeaves[I]);
           QueryResult.Add(FLeaves[I]);
       end;
       end;
-
       // Recursively let the children add their leaves
       // Recursively let the children add their leaves
       for I := 0 to FChildCount - 1 do
       for I := 0 to FChildCount - 1 do
         FChildren[I].QueryFrustum(Frustum, QueryResult);
         FChildren[I].QueryFrustum(Frustum, QueryResult);
@@ -1373,21 +1339,18 @@ begin
   // Do nothing in the basic case
   // Do nothing in the basic case
 end;
 end;
 
 
-procedure TSectorNode.QueryFrustumEx(const ExtendedFrustum: TExtendedFrustum; const QueryResult: TSpacePartitionLeafList);
+procedure TSectorNode.QueryFrustumEx(const ExtendedFrustum: TGLExtendedFrustum; const QueryResult: TSpacePartitionLeafList);
 var
 var
   SpaceContains: TSpaceContains;
   SpaceContains: TSpaceContains;
   I: Integer;
   I: Integer;
 begin
 begin
   Inc(FSectoredSpacePartition.FQueryNodeTests);
   Inc(FSectoredSpacePartition.FQueryNodeTests);
-
   // Does the extended frustum intersect the bsphere at all?
   // Does the extended frustum intersect the bsphere at all?
   if not ExtendedFrustumIntersectsBSphere(ExtendedFrustum, BSphere) then
   if not ExtendedFrustumIntersectsBSphere(ExtendedFrustum, BSphere) then
     SpaceContains := ScNoOverlap
     SpaceContains := ScNoOverlap
-
   else
   else
     // Test if the bounding frustum intersects the AABB of the node
     // Test if the bounding frustum intersects the AABB of the node
     SpaceContains := FrustumContainsAABB(ExtendedFrustum.Frustum, AABB); // }
     SpaceContains := FrustumContainsAABB(ExtendedFrustum.Frustum, AABB); // }
-
   // If the frustum fully contains the leaf, then we need not check every piece,
   // If the frustum fully contains the leaf, then we need not check every piece,
   // just add them all
   // just add them all
   if SpaceContains = ScContainsFully then
   if SpaceContains = ScContainsFully then
@@ -1395,7 +1358,6 @@ begin
     AddAllLeavesRecursive(QueryResult);
     AddAllLeavesRecursive(QueryResult);
   end
   end
   else
   else
-
     // If the frustum partially contains the leaf, then we should add the leaves
     // If the frustum partially contains the leaf, then we should add the leaves
     // that intersect the frustum and recurse for all children
     // that intersect the frustum and recurse for all children
     if SpaceContains = ScContainsPartially then
     if SpaceContains = ScContainsPartially then
@@ -1405,21 +1367,19 @@ begin
         // Early out 1
         // Early out 1
         if not BSphereIntersectsBSphere(FLeaves[I].FCachedBSphere, ExtendedFrustum.BSphere) then
         if not BSphereIntersectsBSphere(FLeaves[I].FCachedBSphere, ExtendedFrustum.BSphere) then
           Continue;
           Continue;
-
         Inc(FSectoredSpacePartition.FQueryInterObjectTests);
         Inc(FSectoredSpacePartition.FQueryInterObjectTests);
-
         if not IsVolumeClipped(FLeaves[I].FCachedBSphere.Center, FLeaves[I].FCachedBSphere.Radius, ExtendedFrustum.Frustum) then
         if not IsVolumeClipped(FLeaves[I].FCachedBSphere.Center, FLeaves[I].FCachedBSphere.Radius, ExtendedFrustum.Frustum) then
           QueryResult.Add(FLeaves[I]);
           QueryResult.Add(FLeaves[I]);
       end;
       end;
-
       // Recursively let the children add their leaves
       // Recursively let the children add their leaves
       for I := 0 to FChildCount - 1 do
       for I := 0 to FChildCount - 1 do
         FChildren[I].QueryFrustumEx(ExtendedFrustum, QueryResult);
         FChildren[I].QueryFrustumEx(ExtendedFrustum, QueryResult);
     end;
     end;
 end;
 end;
 
 
-{ TSectoredSpacePartition }
-
+//-------------------------------------
+// TSectoredSpacePartition
+//-------------------------------------
 procedure TSectoredSpacePartition.AddLeaf(ALeaf: TSpacePartitionLeaf);
 procedure TSectoredSpacePartition.AddLeaf(ALeaf: TSpacePartitionLeaf);
 begin
 begin
   inherited;
   inherited;
@@ -1448,9 +1408,7 @@ begin
 
 
   FRootNode := CreateNewNode(nil);
   FRootNode := CreateNewNode(nil);
   FGrowMethod := gmIncreaseToFitAll;
   FGrowMethod := gmIncreaseToFitAll;
-
   FGrowGravy := COctree_GROW_GRAVY;
   FGrowGravy := COctree_GROW_GRAVY;
-
   inherited Create;
   inherited Create;
 end;
 end;
 
 
@@ -1495,9 +1453,7 @@ begin
   // If the leaf still fits in the old node, leave it there - or in one of the
   // If the leaf still fits in the old node, leave it there - or in one of the
   // children
   // children
   Node := TSectorNode(ALeaf.FPartitionTag);
   Node := TSectorNode(ALeaf.FPartitionTag);
-
   Assert(Node <> nil, 'No leaf node could be found!');
   Assert(Node <> nil, 'No leaf node could be found!');
-
   if Node.AABBFitsInNode(ALeaf.FCachedAABB) then
   if Node.AABBFitsInNode(ALeaf.FCachedAABB) then
   begin
   begin
     // If the node has children, try to add the leaf to them - otherwise just
     // If the node has children, try to add the leaf to them - otherwise just
@@ -1512,7 +1468,6 @@ begin
   else
   else
   begin
   begin
     Node.RemoveLeaf(ALeaf, True);
     Node.RemoveLeaf(ALeaf, True);
-
     // Does this leaf still fit in the Octree?
     // Does this leaf still fit in the Octree?
     if not FRootNode.AABBFitsInNode(ALeaf.FCachedAABB) then
     if not FRootNode.AABBFitsInNode(ALeaf.FCachedAABB) then
     begin
     begin
@@ -1559,17 +1514,13 @@ begin
 
 
   Node := TSectorNode(ALeaf.FPartitionTag);
   Node := TSectorNode(ALeaf.FPartitionTag);
   FlushQueryResult;
   FlushQueryResult;
-
   // First, query downwards!
   // First, query downwards!
   Node.QueryAABB(ALeaf.FCachedAABB, QueryResult);
   Node.QueryAABB(ALeaf.FCachedAABB, QueryResult);
-
   // Now, query parents and upwards!
   // Now, query parents and upwards!
   Node := Node.Parent;
   Node := Node.Parent;
-
   while Node <> nil do
   while Node <> nil do
   begin
   begin
     Inc(FQueryNodeTests);
     Inc(FQueryNodeTests);
-
     // Add all leaves that overlap
     // Add all leaves that overlap
     for I := 0 to Node.FLeaves.Count - 1 do
     for I := 0 to Node.FLeaves.Count - 1 do
     begin
     begin
@@ -1578,13 +1529,10 @@ begin
       if IntersectAABBsAbsolute(TestLeaf.FCachedAABB, ALeaf.FCachedAABB) then
       if IntersectAABBsAbsolute(TestLeaf.FCachedAABB, ALeaf.FCachedAABB) then
         QueryResult.Add(TestLeaf);
         QueryResult.Add(TestLeaf);
     end;
     end;
-
     // Try the parent
     // Try the parent
     Node := Node.Parent;
     Node := Node.Parent;
   end;
   end;
-
   QueryResult.Remove(ALeaf);
   QueryResult.Remove(ALeaf);
-
   Result := QueryResult.Count;
   Result := QueryResult.Count;
 end;
 end;
 
 
@@ -1626,7 +1574,6 @@ begin
 
 
   for I := 0 to OldLeaves.Count - 1 do
   for I := 0 to OldLeaves.Count - 1 do
     AddLeaf(OldLeaves[I]);
     AddLeaf(OldLeaves[I]);
-
   OldLeaves.Free;
   OldLeaves.Free;
   FGrowMethod := TempGrowMethod;
   FGrowMethod := TempGrowMethod;
 end;
 end;
@@ -1639,7 +1586,6 @@ begin
   // Creates the new extents for the Octree
   // Creates the new extents for the Octree
   MaxAABB := GetAABB;
   MaxAABB := GetAABB;
   AABBSize := VectorSubtract(MaxAABB.Max, MaxAABB.Min);
   AABBSize := VectorSubtract(MaxAABB.Max, MaxAABB.Min);
-
   if FGrowMethod = gmBestFit then
   if FGrowMethod = gmBestFit then
   begin
   begin
     NewAABB.Min := VectorSubtract(MaxAABB.Min, VectorScale(AABBSize, Gravy));
     NewAABB.Min := VectorSubtract(MaxAABB.Min, VectorScale(AABBSize, Gravy));
@@ -1659,7 +1605,6 @@ end;
 procedure TSectoredSpacePartition.FlushQueryResult;
 procedure TSectoredSpacePartition.FlushQueryResult;
 begin
 begin
   inherited;
   inherited;
-
   FQueryNodeTests := 0;
   FQueryNodeTests := 0;
 end;
 end;
 
 
@@ -1670,15 +1615,16 @@ begin
   Result := FQueryResult.Count;
   Result := FQueryResult.Count;
 end;
 end;
 
 
-function TSectoredSpacePartition.QueryFrustumEx(const ExtendedFrustum: TExtendedFrustum): Integer;
+function TSectoredSpacePartition.QueryFrustumEx(const ExtendedFrustum: TGLExtendedFrustum): Integer;
 begin
 begin
   FlushQueryResult;
   FlushQueryResult;
   FRootNode.QueryFrustumEx(ExtendedFrustum, FQueryResult);
   FRootNode.QueryFrustumEx(ExtendedFrustum, FQueryResult);
   Result := FQueryResult.Count;
   Result := FQueryResult.Count;
 end;
 end;
 
 
-{ TSPOctreeNode }
-
+//-------------------------------------
+// TSPOctreeNode
+//-------------------------------------
 function TSPOctreeNode.AABBFitsInNode(const AAABB: TAABB): Boolean;
 function TSPOctreeNode.AABBFitsInNode(const AAABB: TAABB): Boolean;
 begin
 begin
   // Faster than inherited method
   // Faster than inherited method
@@ -1736,18 +1682,17 @@ begin
   for I := 0 to 7 do
   for I := 0 to 7 do
   begin
   begin
     FChildren[I] := FSectoredSpacePartition.CreateNewNode(Self);
     FChildren[I] := FSectoredSpacePartition.CreateNewNode(Self);
-
     // Generate new extents based on parent's extents
     // Generate new extents based on parent's extents
     AABB.Min := GetExtent(COctFlagMIN[I]);
     AABB.Min := GetExtent(COctFlagMIN[I]);
     AABB.Max := GetExtent(COctFlagMax[I]);
     AABB.Max := GetExtent(COctFlagMax[I]);
     FChildren[I].AABB := AABB;
     FChildren[I].AABB := AABB;
   end;
   end;
-
   FChildCount := 8;
   FChildCount := 8;
 end;
 end;
 
 
-{ TOctreeSpacePartition }
-
+//-------------------------------------
+// TOctreeSpacePartition
+//-------------------------------------
 function TOctreeSpacePartition.CreateNewNode(AParent: TSectorNode): TSectorNode;
 function TOctreeSpacePartition.CreateNewNode(AParent: TSectorNode): TSectorNode;
 begin
 begin
   Result := TSPOctreeNode.Create(Self, AParent);
   Result := TSPOctreeNode.Create(Self, AParent);
@@ -1759,12 +1704,12 @@ var
 begin
 begin
   AABB.Min := Min;
   AABB.Min := Min;
   AABB.Max := Max;
   AABB.Max := Max;
-
   RebuildTree(AABB);
   RebuildTree(AABB);
 end;
 end;
 
 
-{ TSPQuadtreeNode }
-
+//-------------------------------------
+// TSPQuadtreeNode
+//-------------------------------------
 function TSPQuadtreeNode.AABBFitsInNode(const AAABB: TAABB): Boolean;
 function TSPQuadtreeNode.AABBFitsInNode(const AAABB: TAABB): Boolean;
 begin
 begin
   Result := (AAABB.Min.X >= FAABB.Min.X) and
   Result := (AAABB.Min.X >= FAABB.Min.X) and
@@ -1797,7 +1742,6 @@ var
   NewMin, NewMax: Single;
   NewMin, NewMax: Single;
 begin
 begin
   inherited;
   inherited;
-
   // Establish a baseline
   // Establish a baseline
   if Leaves.Count > 0 then
   if Leaves.Count > 0 then
   begin
   begin
@@ -1805,7 +1749,6 @@ begin
     NewMax := Leaves[0].FCachedAABB.Max.Y;
     NewMax := Leaves[0].FCachedAABB.Max.Y;
   end
   end
   else
   else
-
     if FChildCount > 0 then
     if FChildCount > 0 then
   begin
   begin
     NewMin := FChildren[0].AABB.Min.Y;
     NewMin := FChildren[0].AABB.Min.Y;
@@ -1817,7 +1760,6 @@ begin
     NewMin := 1E9;
     NewMin := 1E9;
     NewMax := -1E9;
     NewMax := -1E9;
   end;
   end;
-
   for I := 0 to Leaves.Count - 1 do
   for I := 0 to Leaves.Count - 1 do
   begin
   begin
     NewMin := Min(NewMin, Leaves[I].FCachedAABB.Min.Y);
     NewMin := Min(NewMin, Leaves[I].FCachedAABB.Min.Y);
@@ -1834,7 +1776,6 @@ begin
   begin
   begin
     FAABB.Max.Y := NewMax;
     FAABB.Max.Y := NewMax;
     FAABB.Min.Y := NewMin;
     FAABB.Min.Y := NewMin;
-
     // Make sure the parent updates it's bounds as well
     // Make sure the parent updates it's bounds as well
     if Assigned(Parent) then
     if Assigned(Parent) then
       Parent.ChildrenChanged; // }
       Parent.ChildrenChanged; // }
@@ -1850,11 +1791,9 @@ begin
   for ChildNodeIndex := 0 to 3 do
   for ChildNodeIndex := 0 to 3 do
   begin
   begin
     FChildren[ChildNodeIndex] := FSectoredSpacePartition.CreateNewNode(Self);
     FChildren[ChildNodeIndex] := FSectoredSpacePartition.CreateNewNode(Self);
-
     // Y is ignored so it's set to a very large number
     // Y is ignored so it's set to a very large number
     AABB.Min.Y := FAABB.Min.Y;
     AABB.Min.Y := FAABB.Min.Y;
     AABB.Max.Y := FAABB.Max.Y;
     AABB.Max.Y := FAABB.Max.Y;
-
     // Generate new extents based on parent's extents
     // Generate new extents based on parent's extents
     if ((ChildNodeIndex and 1) > 0) then
     if ((ChildNodeIndex and 1) > 0) then
       X := 1
       X := 1
@@ -1864,7 +1803,6 @@ begin
       Z := 1
       Z := 1
     else
     else
       Z := 0;
       Z := 0;
-
     if X = 0 then
     if X = 0 then
     begin
     begin
       AABB.Min.X := FAABB.Min.X + (FAABB.Max.X + FAABB.Min.X) / 2 * X;
       AABB.Min.X := FAABB.Min.X + (FAABB.Max.X + FAABB.Min.X) / 2 * X;
@@ -1875,7 +1813,6 @@ begin
       AABB.Min.X := (FAABB.Max.X + FAABB.Min.X) / 2;
       AABB.Min.X := (FAABB.Max.X + FAABB.Min.X) / 2;
       AABB.Max.X := FAABB.Max.X;
       AABB.Max.X := FAABB.Max.X;
     end;
     end;
-
     if Z = 0 then
     if Z = 0 then
     begin
     begin
       AABB.Min.Z := FAABB.Min.Z;
       AABB.Min.Z := FAABB.Min.Z;
@@ -1886,10 +1823,8 @@ begin
       AABB.Min.Z := (FAABB.Max.Z + FAABB.Min.Z) / 2;
       AABB.Min.Z := (FAABB.Max.Z + FAABB.Min.Z) / 2;
       AABB.Max.Z := FAABB.Max.Z;
       AABB.Max.Z := FAABB.Max.Z;
     end;
     end;
-
     FChildren[ChildNodeIndex].AABB := AABB;
     FChildren[ChildNodeIndex].AABB := AABB;
   end;
   end;
-
   FChildCount := 4;
   FChildCount := 4;
 end;
 end;
 
 
@@ -1902,33 +1837,26 @@ begin
   // Instead of looping through all children, we simply determine on which
   // Instead of looping through all children, we simply determine on which
   // side of the center node the child is located
   // side of the center node the child is located
   ChildNodeIndex := 0;
   ChildNodeIndex := 0;
-
   Location := AABB.Min;
   Location := AABB.Min;
-
   // Fore / Back
   // Fore / Back
   if Location.X > FBSphere.Center.X then
   if Location.X > FBSphere.Center.X then
     ChildNodeIndex := ChildNodeIndex or 1;
     ChildNodeIndex := ChildNodeIndex or 1;
-
   // Left / Right
   // Left / Right
   if Location.Z > FBSphere.Center.Z then
   if Location.Z > FBSphere.Center.Z then
     ChildNodeIndex := ChildNodeIndex or 2;
     ChildNodeIndex := ChildNodeIndex or 2;
-
   Assert(ChildNodeIndex < ChildCount, 'Bad ChildNodeIndex!');
   Assert(ChildNodeIndex < ChildCount, 'Bad ChildNodeIndex!');
   ChildNode := FChildren[ChildNodeIndex];
   ChildNode := FChildren[ChildNodeIndex];
-
   if ChildNode.AABBFitsInNode(AABB) then
   if ChildNode.AABBFitsInNode(AABB) then
   begin
   begin
     Result := ChildNode;
     Result := ChildNode;
     Exit;
     Exit;
   end;
   end;
-
   Result := nil;
   Result := nil;
 end;
 end;
 
 
 //-----------------------------------
 //-----------------------------------
 // TQuadtreeSpacePartition
 // TQuadtreeSpacePartition
 //-----------------------------------
 //-----------------------------------
-
 function TQuadtreeSpacePartition.CreateNewNode(AParent: TSectorNode): TSectorNode;
 function TQuadtreeSpacePartition.CreateNewNode(AParent: TSectorNode): TSectorNode;
 begin
 begin
   Result := TSPQuadtreeNode.Create(Self, AParent);
   Result := TSPQuadtreeNode.Create(Self, AParent);
@@ -1940,7 +1868,6 @@ var
 begin
 begin
   AABB.Min := Min;
   AABB.Min := Min;
   AABB.Max := Max;
   AABB.Max := Max;
-
   RebuildTree(AABB);
   RebuildTree(AABB);
 end;
 end;
 
 
@@ -1960,7 +1887,6 @@ begin
   gl.Vertex3f(AABB.max.X, AABB.max.Y, AABB.min.Z);
   gl.Vertex3f(AABB.max.X, AABB.max.Y, AABB.min.Z);
   gl.Vertex3f(AABB.max.X, AABB.min.Y, AABB.min.Z);
   gl.Vertex3f(AABB.max.X, AABB.min.Y, AABB.min.Z);
   gl.Vertex3f(AABB.min.X, AABB.min.Y, AABB.min.Z);
   gl.Vertex3f(AABB.min.X, AABB.min.Y, AABB.min.Z);
-
   gl.Vertex3f(AABB.min.X, AABB.min.Y, AABB.max.Z);
   gl.Vertex3f(AABB.min.X, AABB.min.Y, AABB.max.Z);
   gl.Vertex3f(AABB.min.X, AABB.max.Y, AABB.max.Z);
   gl.Vertex3f(AABB.min.X, AABB.max.Y, AABB.max.Z);
   gl.Vertex3f(AABB.max.X, AABB.max.Y, AABB.max.Z);
   gl.Vertex3f(AABB.max.X, AABB.max.Y, AABB.max.Z);
@@ -1971,10 +1897,8 @@ begin
   gl.Begin_(GL_LINES);
   gl.Begin_(GL_LINES);
   gl.Vertex3f(AABB.min.X, AABB.max.Y, AABB.min.Z);
   gl.Vertex3f(AABB.min.X, AABB.max.Y, AABB.min.Z);
   gl.Vertex3f(AABB.min.X, AABB.max.Y, AABB.max.Z);
   gl.Vertex3f(AABB.min.X, AABB.max.Y, AABB.max.Z);
-
   gl.Vertex3f(AABB.max.X, AABB.max.Y, AABB.min.Z);
   gl.Vertex3f(AABB.max.X, AABB.max.Y, AABB.min.Z);
   gl.Vertex3f(AABB.max.X, AABB.max.Y, AABB.max.Z);
   gl.Vertex3f(AABB.max.X, AABB.max.Y, AABB.max.Z);
-
   gl.Vertex3f(AABB.max.X, AABB.min.Y, AABB.min.Z);
   gl.Vertex3f(AABB.max.X, AABB.min.Y, AABB.min.Z);
   gl.Vertex3f(AABB.max.X, AABB.min.Y, AABB.max.Z);
   gl.Vertex3f(AABB.max.X, AABB.min.Y, AABB.max.Z);
   gl.End_;
   gl.End_;
@@ -1996,7 +1920,6 @@ procedure RenderSpatialPartitioning(var rci: TGLRenderContextInfo;
         RenderAABB(rci, AABB, 1, 0, 0, 0)
         RenderAABB(rci, AABB, 1, 0, 0, 0)
       else
       else
         RenderAABB(rci, AABB, 1, 0.8, 0.8, 0.8) //}
         RenderAABB(rci, AABB, 1, 0.8, 0.8, 0.8) //}
-
     end
     end
     else
     else
     begin
     begin
@@ -2010,7 +1933,7 @@ begin
 end;
 end;
 
 
 function ExtendedFrustumMakeFromSceneViewer(const AFrustum: TFrustum;
 function ExtendedFrustumMakeFromSceneViewer(const AFrustum: TFrustum;
-  const AGLSceneViewer: TGLSceneViewer): TExtendedFrustum; //old version
+  const AGLSceneViewer: TGLSceneViewer): TGLExtendedFrustum; //old version
 begin
 begin
   Assert(Assigned(AGLSceneViewer.Camera), 'GLSceneViewer must have camera specified!');
   Assert(Assigned(AGLSceneViewer.Camera), 'GLSceneViewer must have camera specified!');
   result := ExtendedFrustumMake(AFrustum,
   result := ExtendedFrustumMake(AFrustum,
@@ -2022,7 +1945,7 @@ begin
 end;
 end;
 
 
 function ExtendedFrustumMakeFromSceneViewer(const AFrustum: TFrustum;
 function ExtendedFrustumMakeFromSceneViewer(const AFrustum: TFrustum;
-  const vWidth, vHeight: integer; AGLCamera: TGLCamera): TExtendedFrustum; //changed version
+  const vWidth, vHeight: integer; AGLCamera: TGLCamera): TGLExtendedFrustum; //changed version
 var
 var
   buffov: single;
   buffov: single;
 begin
 begin
@@ -2061,5 +1984,4 @@ begin
   FCachedBSphere.Center := AffineVectorMake(Obj.AbsolutePosition);
   FCachedBSphere.Center := AffineVectorMake(Obj.AbsolutePosition);
 end;
 end;
 
 
-
 end.
 end.

+ 320 - 354
Source/GLS.VerletClothify.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.VerletClothify;
 unit GLS.VerletClothify;
 
 
 (* Methods for turning a TGLBaseMesh into a Verlet cloth / jelly *)
 (* Methods for turning a TGLBaseMesh into a Verlet cloth / jelly *)
@@ -27,150 +26,157 @@ uses
   GLS.PersistentClasses,
   GLS.PersistentClasses,
   GLS.Context;
   GLS.Context;
 
 
-
 type
 type
-  (* Class that represents a face. This structure
-     is not used for rendering, but for extracting info from meshes *)
-  TFace = class
+  (*
+    Class that represents a face. This structure
+    is not used for rendering, but for extracting info from meshes
+  *)
+  TGLFace = class
   public
   public
-    Vertices : array[0..2] of integer;
-    Normal : TAffineVector;
-    MeshObject : TMeshObject;
-    Active : boolean;
+    Vertices: array [0 .. 2] of integer;
+    Normal: TAffineVector;
+    MeshObject: TMeshObject;
+    Active: boolean;
     procedure UpdateNormal;
     procedure UpdateNormal;
-    constructor Create(aMeshObject : TMeshObject);
+    constructor Create(aMeshObject: TMeshObject);
   end;
   end;
 
 
   // List of faces
   // List of faces
-  TFaceList = class(TList)
+  TGLFaceList = class(TList)
   private
   private
-    function GetItems(i: integer): TFace;
-    procedure SetItems(i: integer; const Value: TFace);
+    function GetItems(i: integer): TGLFace;
+    procedure SetItems(i: integer; const Value: TGLFace);
   public
   public
-    property Items[i : integer] : TFace read GetItems write SetItems; default;
+    property Items[i: integer]: TGLFace read GetItems write SetItems; default;
   end;
   end;
 
 
   // Class that extracts faces from a GLBaseMesh
   // Class that extracts faces from a GLBaseMesh
-  TFaceExtractor = class
+  TGLFaceExtractor = class
   private
   private
-    FFaceList : TFaceList;
-    FGLBaseMesh : TGLBaseMesh;
-    FNodeList : TVerletNodeList;
+    FFaceList: TGLFaceList;
+    FGLBaseMesh: TGLBaseMesh;
+    FNodeList: TGLVerletNodeList;
     FWeldDistance: single;
     FWeldDistance: single;
-    FEdgeDoublesSkipped : integer;
+    FEdgeDoublesSkipped: integer;
     procedure SetWeldDistance(const Value: single);
     procedure SetWeldDistance(const Value: single);
   protected
   protected
-    procedure ProcessMeshObject(const MeshObject : TMeshObject); virtual;
+    procedure ProcessMeshObject(const MeshObject: TMeshObject); virtual;
   public
   public
-    procedure ExtractFacesFromVertexIndexList(
-      const FaceGroup : TFGVertexIndexList; const MeshObject : TMeshObject);
-    property FaceList : TFaceList read FFaceList;
+    procedure ExtractFacesFromVertexIndexList(const FaceGroup
+      : TFGVertexIndexList; const MeshObject: TMeshObject);
+    property FaceList: TGLFaceList read FFaceList;
     procedure Clear; virtual;
     procedure Clear; virtual;
     procedure ProcessMesh; virtual;
     procedure ProcessMesh; virtual;
-    property WeldDistance : single read FWeldDistance write SetWeldDistance;
-    property EdgeDoublesSkipped : integer read FEdgeDoublesSkipped;
-    property GLBaseMesh : TGLBaseMesh read FGLBaseMesh;
-    property NodeList : TVerletNodeList read FNodeList;
-    function AddFace(const Vi0, Vi1, Vi2 : integer; const MeshObject : TMeshObject) : TFace; virtual;
-    constructor Create(const aGLBaseMesh : TGLBaseMesh); virtual;
+    property WeldDistance: single read FWeldDistance write SetWeldDistance;
+    property EdgeDoublesSkipped: integer read FEdgeDoublesSkipped;
+    property GLBaseMesh: TGLBaseMesh read FGLBaseMesh;
+    property NodeList: TGLVerletNodeList read FNodeList;
+    function AddFace(const Vi0, Vi1, Vi2: integer;
+      const MeshObject: TMeshObject): TGLFace; virtual;
+    constructor Create(const aGLBaseMesh: TGLBaseMesh); virtual;
     destructor Destroy; override;
     destructor Destroy; override;
   end;
   end;
 
 
-  TEdgeDetector = class;
-  TEdge = class
+  TGLEdgeDetector = class;
+
+  TGLEdge = class
   private
   private
     FSolid: boolean;
     FSolid: boolean;
     FLength: single;
     FLength: single;
     FMeshObject: TMeshObject;
     FMeshObject: TMeshObject;
-    FOwner: TEdgeDetector;
+    FOwner: TGLEdgeDetector;
   public
   public
-    Vertices : array[0..1] of integer;
-    Faces : array[0..1] of TFace;
+    Vertices: array [0 .. 1] of integer;
+    Faces: array [0 .. 1] of TGLFace;
     procedure Contract;
     procedure Contract;
-    property Owner : TEdgeDetector read FOwner;
-    property MeshObject : TMeshObject read FMeshObject write FMeshObject;
-    property Length : single read FLength write FLength;
-    property Solid : boolean read FSolid write FSolid;
+    property Owner: TGLEdgeDetector read FOwner;
+    property MeshObject: TMeshObject read FMeshObject write FMeshObject;
+    property Length: single read FLength write FLength;
+    property Solid: boolean read FSolid write FSolid;
     procedure UpdateEdgeLength;
     procedure UpdateEdgeLength;
-    constructor Create(const AOwner: TEdgeDetector; AVi0, AVi1 : integer;
-      AFace0, AFace1 : TFace; AMeshObject : TMeshObject; ASolid : boolean);
+    constructor Create(const AOwner: TGLEdgeDetector; AVi0, AVi1: integer;
+      AFace0, AFace1: TGLFace; aMeshObject: TMeshObject; ASolid: boolean);
   end;
   end;
 
 
-  TEdgeList = class(TList)
+  TGLEdgeList = class(TList)
   private
   private
-    function GetItems(i: integer): TEdge;
-    procedure SetItems(i: integer; const Value: TEdge);
+    function GetItems(i: integer): TGLEdge;
+    procedure SetItems(i: integer; const Value: TGLEdge);
   public
   public
-    property Items[i : integer] : TEdge read GetItems write SetItems; default;
+    property Items[i: integer]: TGLEdge read GetItems write SetItems; default;
     procedure SortByLength;
     procedure SortByLength;
-    function InsertSorted(AEdge : TEdge) : integer;
+    function InsertSorted(AEdge: TGLEdge): integer;
   end;
   end;
 
 
-  TEdgeDetector = class(TFaceExtractor)
+  TGLEdgeDetector = class(TGLFaceExtractor)
   private
   private
-    FEdgeList : TEdgeList;
-    FCurrentNodeOffset : integer;
-    FNodesAdded : boolean;
+    FEdgeList: TGLEdgeList;
+    FCurrentNodeOffset: integer;
+    FNodesAdded: boolean;
     procedure BuildOpposingEdges;
     procedure BuildOpposingEdges;
   protected
   protected
-    FCalcEdgeLength : boolean;
+    FCalcEdgeLength: boolean;
   public
   public
-    property EdgeList : TEdgeList read FEdgeList;
+    property EdgeList: TGLEdgeList read FEdgeList;
     procedure Clear; override;
     procedure Clear; override;
     procedure ProcessMesh; override;
     procedure ProcessMesh; override;
-    function AddEdge(const Vi0, Vi1 : integer; const Face : TFace; const AMeshObject : TMeshObject) : TEdge;
-    function AddFace(const Vi0, Vi1, Vi2 : integer; const MeshObject : TMeshObject) : TFace; override;
-    function AddNode(const VerletWorld : TGLVerletWorld; const MeshObject : TMeshObject; const VertexIndex : integer) : TVerletNode; virtual;
-    procedure AddNodes(const VerletWorld : TGLVerletWorld);
-    procedure AddEdgesAsSticks(const VerletWorld : TGLVerletWorld; const Slack : single);
-    procedure AddEdgesAsSprings(const VerletWorld : TGLVerletWorld; const Strength, Damping, Slack : single);
-    procedure AddEdgesAsSolidEdges(const VerletWorld : TGLVerletWorld);
-    procedure AddOuterEdgesAsSolidEdges(const VerletWorld : TGLVerletWorld);
-    procedure RenderEdges(var rci : TGLRenderContextInfo);
-    property CurrentNodeOffset : integer read FCurrentNodeOffset;
-    property NodesAdded : boolean read FNodesAdded;
-    procedure ReplaceVertexIndex(const ViRemove, ViReplaceWith : integer);
-    constructor Create(const aGLBaseMesh : TGLBaseMesh); override;
+    function AddEdge(const Vi0, Vi1: integer; const Face: TGLFace;
+      const aMeshObject: TMeshObject): TGLEdge;
+    function AddFace(const Vi0, Vi1, Vi2: integer;
+      const MeshObject: TMeshObject): TGLFace; override;
+    function AddNode(const VerletWorld: TGLVerletWorld;
+      const MeshObject: TMeshObject; const VertexIndex: integer)
+      : TGLVerletNode; virtual;
+    procedure AddNodes(const VerletWorld: TGLVerletWorld);
+    procedure AddEdgesAsSticks(const VerletWorld: TGLVerletWorld;
+      const Slack: single);
+    procedure AddEdgesAsSprings(const VerletWorld: TGLVerletWorld;
+      const Strength, Damping, Slack: single);
+    procedure AddEdgesAsSolidEdges(const VerletWorld: TGLVerletWorld);
+    procedure AddOuterEdgesAsSolidEdges(const VerletWorld: TGLVerletWorld);
+    procedure RenderEdges(var rci: TGLRenderContextInfo);
+    property CurrentNodeOffset: integer read FCurrentNodeOffset;
+    property NodesAdded: boolean read FNodesAdded;
+    procedure ReplaceVertexIndex(const ViRemove, ViReplaceWith: integer);
+    constructor Create(const aGLBaseMesh: TGLBaseMesh); override;
     destructor Destroy; override;
     destructor Destroy; override;
   end;
   end;
 
 
-  TMeshObjectVerletNode = class(TVerletNode)
+  TGLMeshObjectVerletNode = class(TGLVerletNode)
   private
   private
-    MeshObject : TMeshObject;
-    VertexIndices : TIntegerList;
+    MeshObject: TMeshObject;
+    VertexIndices: TIntegerList;
   public
   public
     procedure AfterProgress; override;
     procedure AfterProgress; override;
-    constructor CreateOwned(const aOwner : TGLVerletWorld); override;
+    constructor CreateOwned(const AOwner: TGLVerletWorld); override;
     destructor Destroy; override;
     destructor Destroy; override;
   end;
   end;
 
 
-//----------------------------------------------------  
+// ----------------------------------------------------
 implementation
 implementation
-//----------------------------------------------------
+// ----------------------------------------------------
 
 
-//------------------
-// TFaceExtractor
-//------------------
-
-procedure TFaceExtractor.Clear;
+// ------------------
+// TGLFaceExtractor
+// ------------------
+procedure TGLFaceExtractor.Clear;
 var
 var
-  i : integer;
+  i: integer;
 begin
 begin
-  for i := 0 to FaceList.Count-1 do
+  for i := 0 to FaceList.Count - 1 do
     FaceList[i].Free;
     FaceList[i].Free;
-
   FaceList.Clear;
   FaceList.Clear;
 end;
 end;
 
 
-constructor TFaceExtractor.Create(const aGLBaseMesh : TGLBaseMesh);
+constructor TGLFaceExtractor.Create(const aGLBaseMesh: TGLBaseMesh);
 begin
 begin
-  FFaceList := TFaceList.Create;
+  FFaceList := TGLFaceList.Create;
   FGLBaseMesh := aGLBaseMesh;
   FGLBaseMesh := aGLBaseMesh;
-  FNodeList := TVerletNodeList.Create;
+  FNodeList := TGLVerletNodeList.Create;
   FWeldDistance := 0.01;
   FWeldDistance := 0.01;
 end;
 end;
 
 
-destructor TFaceExtractor.Destroy;
+destructor TGLFaceExtractor.Destroy;
 begin
 begin
   Clear;
   Clear;
   FreeAndNil(FNodeList);
   FreeAndNil(FNodeList);
@@ -178,51 +184,48 @@ begin
   inherited;
   inherited;
 end;
 end;
 
 
-procedure TFaceExtractor.ExtractFacesFromVertexIndexList(
-  const FaceGroup : TFGVertexIndexList; const MeshObject : TMeshObject);
+procedure TGLFaceExtractor.ExtractFacesFromVertexIndexList(const FaceGroup
+  : TFGVertexIndexList; const MeshObject: TMeshObject);
 var
 var
-  List : PIntegerArray;
-  iFace, iVertex  : integer;
+  List: PIntegerArray;
+  iFace, iVertex: integer;
 begin
 begin
   case FaceGroup.Mode of
   case FaceGroup.Mode of
-
-    fgmmTriangles, fgmmFlatTriangles :
-    begin
-      for iFace := 0 to FaceGroup.TriangleCount - 1 do
+    fgmmTriangles, fgmmFlatTriangles:
       begin
       begin
-        List := @FaceGroup.VertexIndices.List[iFace * 3 + 0];
-        AddFace(List^[0], List^[1], List^[2], MeshObject);
+        for iFace := 0 to FaceGroup.TriangleCount - 1 do
+        begin
+          List := @FaceGroup.VertexIndices.List[iFace * 3 + 0];
+          AddFace(List^[0], List^[1], List^[2], MeshObject);
+        end;
       end;
       end;
-    end;
-
-    fgmmTriangleStrip :
-    begin
-      for iFace:=0 to FaceGroup.VertexIndices.Count-3 do
+    fgmmTriangleStrip:
       begin
       begin
-        List := @FaceGroup.VertexIndices.List[iFace];
-        if (iFace and 1)=0 then
-           AddFace(List^[0], List^[1], List^[2], MeshObject)
-        else
-           AddFace(List^[2], List^[1], List^[0], MeshObject);
+        for iFace := 0 to FaceGroup.VertexIndices.Count - 3 do
+        begin
+          List := @FaceGroup.VertexIndices.List[iFace];
+          if (iFace and 1) = 0 then
+            AddFace(List^[0], List^[1], List^[2], MeshObject)
+          else
+            AddFace(List^[2], List^[1], List^[0], MeshObject);
+        end;
       end;
       end;
-    end;
-
-    fgmmTriangleFan :
-    begin
-      List := @FaceGroup.VertexIndices.List;
+    fgmmTriangleFan:
+      begin
+        List := @FaceGroup.VertexIndices.List;
 
 
-      for iVertex:=2 to FaceGroup.VertexIndices.Count-1 do
-        AddFace(List^[0], List^[iVertex-1], List^[iVertex], MeshObject)
-    end;
-    else
-      Assert(false,'Not supported');
+        for iVertex := 2 to FaceGroup.VertexIndices.Count - 1 do
+          AddFace(List^[0], List^[iVertex - 1], List^[iVertex], MeshObject)
+      end;
+  else
+    Assert(false, 'Not supported');
   end;
   end;
 end;
 end;
 
 
-procedure TFaceExtractor.ProcessMesh;
+procedure TGLFaceExtractor.ProcessMesh;
 var
 var
-  iMeshObject : integer;
-  MeshObject : TMeshObject;
+  iMeshObject: integer;
+  MeshObject: TMeshObject;
 begin
 begin
   for iMeshObject := 0 to FGLBaseMesh.MeshObjects.Count - 1 do
   for iMeshObject := 0 to FGLBaseMesh.MeshObjects.Count - 1 do
   begin
   begin
@@ -231,9 +234,9 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TFaceExtractor.ProcessMeshObject(const MeshObject : TMeshObject);
+procedure TGLFaceExtractor.ProcessMeshObject(const MeshObject: TMeshObject);
 var
 var
- iFaceGroup : integer;
+  iFaceGroup: integer;
 begin
 begin
   if MeshObject.Mode = momFaceGroups then
   if MeshObject.Mode = momFaceGroups then
   begin
   begin
@@ -241,439 +244,414 @@ begin
     begin
     begin
       if MeshObject.FaceGroups[iFaceGroup] is TFGVertexIndexList then
       if MeshObject.FaceGroups[iFaceGroup] is TFGVertexIndexList then
       begin
       begin
-        ExtractFacesFromVertexIndexList(MeshObject.FaceGroups[iFaceGroup] as TFGVertexIndexList, MeshObject);
-      end else
+        ExtractFacesFromVertexIndexList(MeshObject.FaceGroups[iFaceGroup]
+          as TFGVertexIndexList, MeshObject);
+      end
+      else
         Assert(false);
         Assert(false);
     end;
     end;
-  end else
+  end
+  else
     Assert(false);
     Assert(false);
 end;
 end;
 
 
-function TFaceExtractor.AddFace(const Vi0, Vi1, Vi2: integer; const MeshObject : TMeshObject) : TFace;
+function TGLFaceExtractor.AddFace(const Vi0, Vi1, Vi2: integer;
+  const MeshObject: TMeshObject): TGLFace;
 var
 var
-  Face : TFace;
+  Face: TGLFace;
 begin
 begin
-  Face := TFace.Create(MeshObject);
+  Face := TGLFace.Create(MeshObject);
   FaceList.Add(Face);
   FaceList.Add(Face);
-
   Face.Vertices[0] := Vi0;
   Face.Vertices[0] := Vi0;
   Face.Vertices[1] := Vi1;
   Face.Vertices[1] := Vi1;
   Face.Vertices[2] := Vi2;
   Face.Vertices[2] := Vi2;
-
-  result := Face;
+  Result := Face;
 end;
 end;
 
 
-procedure TFaceExtractor.SetWeldDistance(const Value: single);
+procedure TGLFaceExtractor.SetWeldDistance(const Value: single);
 begin
 begin
   FWeldDistance := Value;
   FWeldDistance := Value;
 end;
 end;
 
 
-//------------------
-// TFaceList 
-//------------------
-
-function TFaceList.GetItems(i: integer): TFace;
+// ------------------
+// TGLFaceList
+// ------------------
+function TGLFaceList.GetItems(i: integer): TGLFace;
 begin
 begin
-  result := TFace(Get(i));
+  result := TGLFace(Get(i));
 end;
 end;
 
 
-procedure TFaceList.SetItems(i: integer; const Value: TFace);
+procedure TGLFaceList.SetItems(i: integer; const Value: TGLFace);
 begin
 begin
   Put(i, Value);
   Put(i, Value);
 end;
 end;
 
 
-//------------------
-// TEdgeList 
-//------------------
-
-function TEdgeList.GetItems(i: integer): TEdge;
+// ------------------
+// TGLEdgeList
+// ------------------
+function TGLEdgeList.GetItems(i: integer): TGLEdge;
 begin
 begin
-  result := TEdge(Get(i));
+  result := TGLEdge(Get(i));
 end;
 end;
 
 
-function TEdgeList.InsertSorted(AEdge: TEdge): integer;
+function TGLEdgeList.InsertSorted(AEdge: TGLEdge): integer;
 var
 var
-  i : integer;
+  i: integer;
 begin
 begin
-  for i := 0 to Count-1 do
+  for i := 0 to Count - 1 do
   begin
   begin
-    if AEdge.Length<Items[i].Length then
+    if AEdge.Length < Items[i].Length then
     begin
     begin
       Insert(i, AEdge);
       Insert(i, AEdge);
-      result := i;
-      exit;
+      Result := i;
+      Exit;
     end;
     end;
   end;
   end;
-  result := Add(AEdge);
+  Result := Add(AEdge);
 end;
 end;
 
 
-procedure TEdgeList.SetItems(i: integer; const Value: TEdge);
+procedure TGLEdgeList.SetItems(i: integer; const Value: TGLEdge);
 begin
 begin
   Put(i, Value);
   Put(i, Value);
 end;
 end;
 
 
-function EdgeLength(Item1, Item2 : pointer) : integer;
+function EdgeLength(Item1, Item2: pointer): integer;
 begin
 begin
-  if TEdge(Item1).Length < TEdge(Item2).Length then
-    result := -1
-  else if TEdge(Item1).Length = TEdge(Item2).Length then
-    result := 0
+  if TGLEdge(Item1).Length < TGLEdge(Item2).Length then
+    Result := -1
+  else if TGLEdge(Item1).Length = TGLEdge(Item2).Length then
+    Result := 0
   else
   else
-    result := 1;
+    Result := 1;
 end;
 end;
 
 
-procedure TEdgeList.SortByLength;
+procedure TGLEdgeList.SortByLength;
 begin
 begin
   Sort(@EdgeLength);
   Sort(@EdgeLength);
 end;
 end;
 
 
-//--------------------------
-{ TMeshObjectVerletNode }
-//--------------------------
-
-constructor TMeshObjectVerletNode.CreateOwned(const aOwner: TGLVerletWorld);
+// --------------------------
+// TGLMeshObjectVerletNode
+// --------------------------
+constructor TGLMeshObjectVerletNode.CreateOwned(const AOwner: TGLVerletWorld);
 begin
 begin
   inherited;
   inherited;
   VertexIndices := TIntegerList.Create;
   VertexIndices := TIntegerList.Create;
 end;
 end;
 
 
-destructor TMeshObjectVerletNode.Destroy;
+destructor TGLMeshObjectVerletNode.Destroy;
 begin
 begin
   VertexIndices.Free;
   VertexIndices.Free;
   inherited;
   inherited;
 end;
 end;
 
 
-procedure TMeshObjectVerletNode.AfterProgress;
+procedure TGLMeshObjectVerletNode.AfterProgress;
 var
 var
-  i : integer;
+  i: integer;
 begin
 begin
   // Update the actual vertex
   // Update the actual vertex
-  for i := 0 to VertexIndices.Count-1 do
-    MeshObject.Vertices[VertexIndices[i]] := MeshObject.Owner.Owner.AbsoluteToLocal(Location);
+  for i := 0 to VertexIndices.Count - 1 do
+    MeshObject.Vertices[VertexIndices[i]] :=
+      MeshObject.Owner.Owner.AbsoluteToLocal(Location);
 end;
 end;
 
 
-//--------------------------
-// TEdgeDetector 
-//--------------------------
-
-procedure TEdgeDetector.Clear;
+// --------------------------
+// TGLEdgeDetector
+// --------------------------
+procedure TGLEdgeDetector.Clear;
 var
 var
-  i : integer;
+  i: integer;
 begin
 begin
   inherited;
   inherited;
-  for i := 0 to EdgeList.Count-1 do
+  for i := 0 to EdgeList.Count - 1 do
     EdgeList[i].Free;
     EdgeList[i].Free;
   EdgeList.Clear;
   EdgeList.Clear;
   FCurrentNodeOffset := 0;
   FCurrentNodeOffset := 0;
   FNodesAdded := false;
   FNodesAdded := false;
 end;
 end;
 
 
-constructor TEdgeDetector.Create(const aGLBaseMesh: TGLBaseMesh);
+constructor TGLEdgeDetector.Create(const aGLBaseMesh: TGLBaseMesh);
 begin
 begin
-  FEdgeList := TEdgeList.Create;
+  FEdgeList := TGLEdgeList.Create;
   FCurrentNodeOffset := 0;
   FCurrentNodeOffset := 0;
   FNodesAdded := false;
   FNodesAdded := false;
   FCalcEdgeLength := false;
   FCalcEdgeLength := false;
   inherited;
   inherited;
 end;
 end;
 
 
-destructor TEdgeDetector.Destroy;
+destructor TGLEdgeDetector.Destroy;
 begin
 begin
   inherited;
   inherited;
   FreeAndNil(FEdgeList);
   FreeAndNil(FEdgeList);
 end;
 end;
 
 
-function TEdgeDetector.AddEdge(const Vi0, Vi1: integer;
-   const Face: TFace; const AMeshObject : TMeshObject): TEdge;
+function TGLEdgeDetector.AddEdge(const Vi0, Vi1: integer; const Face: TGLFace;
+  const aMeshObject: TMeshObject): TGLEdge;
 var
 var
-  i : integer;
-  Edge : TEdge;
+  i: integer;
+  Edge: TGLEdge;
 begin
 begin
   // Find an indentical edge, if there is one
   // Find an indentical edge, if there is one
   for i := 0 to EdgeList.Count - 1 do
   for i := 0 to EdgeList.Count - 1 do
   begin
   begin
     Edge := EdgeList[i];
     Edge := EdgeList[i];
-
-    if (Edge.Vertices[0]=Vi0) and (Edge.Vertices[1]=Vi1) or
-       (Edge.Vertices[1]=Vi0) and (Edge.Vertices[0]=Vi1) then
+    if (Edge.Vertices[0] = Vi0) and (Edge.Vertices[1] = Vi1) or
+      (Edge.Vertices[1] = Vi0) and (Edge.Vertices[0] = Vi1) then
     begin
     begin
       Edge.Faces[1] := Face;
       Edge.Faces[1] := Face;
-
-      result := Edge;
-      exit;
+      Result := Edge;
+      Exit;
     end;
     end;
   end;
   end;
-
   // No edge was found, create a new one
   // No edge was found, create a new one
-  Edge := TEdge.Create(self, Vi0, Vi1, Face, nil, AMeshObject, true);
+  Edge := TGLEdge.Create(self, Vi0, Vi1, Face, nil, aMeshObject, true);
   EdgeList.Add(Edge);
   EdgeList.Add(Edge);
-
-  result := Edge;
+  Result := Edge;
 end;
 end;
 
 
-function TEdgeDetector.AddFace(const Vi0, Vi1, Vi2: integer;
-  const MeshObject: TMeshObject): TFace;
+function TGLEdgeDetector.AddFace(const Vi0, Vi1, Vi2: integer;
+  const MeshObject: TMeshObject): TGLFace;
 var
 var
-  Face : TFace;
+  Face: TGLFace;
 begin
 begin
-  Face := TFace.Create(MeshObject);
+  Face := TGLFace.Create(MeshObject);
   FaceList.Add(Face);
   FaceList.Add(Face);
-
   Face.Vertices[0] := Vi0;
   Face.Vertices[0] := Vi0;
   Face.Vertices[1] := Vi1;
   Face.Vertices[1] := Vi1;
   Face.Vertices[2] := Vi2;
   Face.Vertices[2] := Vi2;
-
   AddEdge(Vi0, Vi1, Face, MeshObject);
   AddEdge(Vi0, Vi1, Face, MeshObject);
   AddEdge(Vi1, Vi2, Face, MeshObject);
   AddEdge(Vi1, Vi2, Face, MeshObject);
-  AddEdge(Vi2, Vi0, Face, MeshObject);//}
-
-  result := Face;
+  AddEdge(Vi2, Vi0, Face, MeshObject); // }
+  Result := Face;
 end;
 end;
 
 
-procedure TEdgeDetector.AddNodes(const VerletWorld : TGLVerletWorld);
+procedure TGLEdgeDetector.AddNodes(const VerletWorld: TGLVerletWorld);
 var
 var
-  i : integer;
-  MO : TMeshObject;
+  i: integer;
+  MO: TMeshObject;
 begin
 begin
   FNodesAdded := true;
   FNodesAdded := true;
   FCurrentNodeOffset := FNodeList.Count;
   FCurrentNodeOffset := FNodeList.Count;
-
   MO := FGLBaseMesh.MeshObjects[0];
   MO := FGLBaseMesh.MeshObjects[0];
-
-  for i := 0 to MO.Vertices.Count-1 do
+  for i := 0 to MO.Vertices.Count - 1 do
     AddNode(VerletWorld, MO, i);
     AddNode(VerletWorld, MO, i);
-
   // Assert(FNodeList.Count = MO.Vertices.Count, Format('%d <> %d',[FNodeList.Count, MO.Vertices.Count]));
   // Assert(FNodeList.Count = MO.Vertices.Count, Format('%d <> %d',[FNodeList.Count, MO.Vertices.Count]));
 end;
 end;
 
 
-procedure TEdgeDetector.AddEdgesAsSprings(const VerletWorld : TGLVerletWorld;
+procedure TGLEdgeDetector.AddEdgesAsSprings(const VerletWorld: TGLVerletWorld;
   const Strength, Damping, Slack: single);
   const Strength, Damping, Slack: single);
 var
 var
-  i : integer;
-  Edge : TEdge;
+  i: integer;
+  Edge: TGLEdge;
 begin
 begin
   if not FNodesAdded then
   if not FNodesAdded then
     AddNodes(VerletWorld);
     AddNodes(VerletWorld);
-
-  for i := 0 to EdgeList.Count-1 do
+  for i := 0 to EdgeList.Count - 1 do
   begin
   begin
     // if not EdgeList[i].SameSame(FNodeList) then
     // if not EdgeList[i].SameSame(FNodeList) then
     Edge := EdgeList[i];
     Edge := EdgeList[i];
-    if FNodeList[FCurrentNodeOffset+Edge.Vertices[0]] <> FNodeList[FCurrentNodeOffset+Edge.Vertices[1]] then
+    if FNodeList[FCurrentNodeOffset + Edge.Vertices[0]] <> FNodeList
+      [FCurrentNodeOffset + Edge.Vertices[1]] then
     begin
     begin
-      VerletWorld.CreateSpring(
-        FNodeList[FCurrentNodeOffset+Edge.Vertices[0]],
-        FNodeList[FCurrentNodeOffset+Edge.Vertices[1]],
-        Strength, Damping, Slack);
+      VerletWorld.CreateSpring(FNodeList[FCurrentNodeOffset + Edge.Vertices[0]],
+        FNodeList[FCurrentNodeOffset + Edge.Vertices[1]], Strength,
+        Damping, Slack);
     end;
     end;
   end;
   end;
 end;
 end;
 
 
-procedure TEdgeDetector.AddEdgesAsSticks(const VerletWorld : TGLVerletWorld;
-  const Slack : single);
+procedure TGLEdgeDetector.AddEdgesAsSticks(const VerletWorld: TGLVerletWorld;
+  const Slack: single);
 var
 var
-  i : integer;
-  Edge : TEdge;
+  i: integer;
+  Edge: TGLEdge;
 begin
 begin
   if not FNodesAdded then
   if not FNodesAdded then
     AddNodes(VerletWorld);
     AddNodes(VerletWorld);
-
-  for i := 0 to EdgeList.Count-1 do
+  for i := 0 to EdgeList.Count - 1 do
   begin
   begin
     // if not EdgeList[i].SameSame(FNodeList) then
     // if not EdgeList[i].SameSame(FNodeList) then
     Edge := EdgeList[i];
     Edge := EdgeList[i];
-    if FNodeList[FCurrentNodeOffset+Edge.Vertices[0]] <> FNodeList[FCurrentNodeOffset+Edge.Vertices[1]] then
+    if FNodeList[FCurrentNodeOffset + Edge.Vertices[0]] <> FNodeList
+      [FCurrentNodeOffset + Edge.Vertices[1]] then
     begin
     begin
-      VerletWorld.CreateStick(
-        FNodeList[FCurrentNodeOffset + Edge.Vertices[0]],
-        FNodeList[FCurrentNodeOffset + Edge.Vertices[1]],
-        Slack);
+      VerletWorld.CreateStick(FNodeList[FCurrentNodeOffset + Edge.Vertices[0]],
+        FNodeList[FCurrentNodeOffset + Edge.Vertices[1]], Slack);
     end;
     end;
   end;
   end;
 end;
 end;
 
 
-procedure TEdgeDetector.AddEdgesAsSolidEdges(
-  const VerletWorld: TGLVerletWorld);
+procedure TGLEdgeDetector.AddEdgesAsSolidEdges(const VerletWorld: TGLVerletWorld);
 var
 var
-  i : integer;
-  Edge : TEdge;
+  i: integer;
+  Edge: TGLEdge;
 begin
 begin
   if not FNodesAdded then
   if not FNodesAdded then
     AddNodes(VerletWorld);
     AddNodes(VerletWorld);
-
-  for i := 0 to EdgeList.Count-1 do
+  for i := 0 to EdgeList.Count - 1 do
   begin
   begin
     // if not EdgeList[i].SameSame(FNodeList) then
     // if not EdgeList[i].SameSame(FNodeList) then
     Edge := EdgeList[i];
     Edge := EdgeList[i];
-    if FNodeList[FCurrentNodeOffset+Edge.Vertices[0]] <> FNodeList[FCurrentNodeOffset+Edge.Vertices[1]] then
+    if FNodeList[FCurrentNodeOffset + Edge.Vertices[0]] <> FNodeList
+      [FCurrentNodeOffset + Edge.Vertices[1]] then
     begin
     begin
       if Edge.Solid then
       if Edge.Solid then
-        VerletWorld.AddSolidEdge(
-          FNodeList[FCurrentNodeOffset + Edge.Vertices[0]],
-          FNodeList[FCurrentNodeOffset + Edge.Vertices[1]]);
+        VerletWorld.AddSolidEdge(FNodeList[FCurrentNodeOffset + Edge.Vertices[0]
+          ], FNodeList[FCurrentNodeOffset + Edge.Vertices[1]]);
     end;
     end;
   end;
   end;
 end;
 end;
 
 
-procedure TEdgeDetector.AddOuterEdgesAsSolidEdges(
-  const VerletWorld: TGLVerletWorld);
+procedure TGLEdgeDetector.AddOuterEdgesAsSolidEdges(const VerletWorld
+  : TGLVerletWorld);
 var
 var
-  i : integer;
-  Edge : TEdge;
+  i: integer;
+  Edge: TGLEdge;
 begin
 begin
   if not FNodesAdded then
   if not FNodesAdded then
     AddNodes(VerletWorld);
     AddNodes(VerletWorld);
-
-  for i := 0 to EdgeList.Count-1 do
+  for i := 0 to EdgeList.Count - 1 do
   begin
   begin
     // if not EdgeList[i].SameSame(FNodeList) then
     // if not EdgeList[i].SameSame(FNodeList) then
     Edge := EdgeList[i];
     Edge := EdgeList[i];
-    if FNodeList[FCurrentNodeOffset+Edge.Vertices[0]] <> FNodeList[FCurrentNodeOffset+Edge.Vertices[1]] then
+    if FNodeList[FCurrentNodeOffset + Edge.Vertices[0]] <> FNodeList
+      [FCurrentNodeOffset + Edge.Vertices[1]] then
     begin
     begin
-      if Edge.Solid and (Edge.Faces[1]=nil) then
-        VerletWorld.AddSolidEdge(
-          FNodeList[FCurrentNodeOffset + Edge.Vertices[0]],
-          FNodeList[FCurrentNodeOffset + Edge.Vertices[1]]);
+      if Edge.Solid and (Edge.Faces[1] = nil) then
+        VerletWorld.AddSolidEdge(FNodeList[FCurrentNodeOffset + Edge.Vertices[0]
+          ], FNodeList[FCurrentNodeOffset + Edge.Vertices[1]]);
     end;
     end;
   end;
   end;
 end;
 end;
 
 
-procedure TEdgeDetector.RenderEdges(var rci: TGLRenderContextInfo);
+procedure TGLEdgeDetector.RenderEdges(var rci: TGLRenderContextInfo);
 var
 var
-  i : integer;
-  Edge : TEdge;
-  Vertex0, Vertex1 : TAffineVector;
+  i: integer;
+  Edge: TGLEdge;
+  Vertex0, Vertex1: TAffineVector;
 begin
 begin
-  if EdgeList.Count>0 then
+  if EdgeList.Count > 0 then
   begin
   begin
     rci.GLStates.Disable(stLighting);
     rci.GLStates.Disable(stLighting);
     rci.GLStates.LineWidth := 3;
     rci.GLStates.LineWidth := 3;
-    gl.Color3f(1,1,1);
-
+    gl.Color3f(1, 1, 1);
     gl.Begin_(GL_LINES);
     gl.Begin_(GL_LINES);
-      for i := 0 to EdgeList.Count - 1 do
-      begin
-        Edge := EdgeList[i];
-
-        Vertex0 := Edge.MeshObject.Vertices[Edge.Vertices[0]];
-        Vertex1 := Edge.MeshObject.Vertices[Edge.Vertices[1]];
-
-        gl.Vertex3fv(PGLfloat(@Vertex0));
-        gl.Vertex3fv(PGLfloat(@Vertex1));
-      end;
+    for i := 0 to EdgeList.Count - 1 do
+    begin
+      Edge := EdgeList[i];
+      Vertex0 := Edge.MeshObject.Vertices[Edge.Vertices[0]];
+      Vertex1 := Edge.MeshObject.Vertices[Edge.Vertices[1]];
+      gl.Vertex3fv(PGLfloat(@Vertex0));
+      gl.Vertex3fv(PGLfloat(@Vertex1));
+    end;
     gl.End_;
     gl.End_;
-  end;//}
+  end;
+  // }
 end;
 end;
 
 
-procedure TEdgeDetector.BuildOpposingEdges;
+procedure TGLEdgeDetector.BuildOpposingEdges;
 var
 var
-  iEdge, EdgeCount, vi0, vi1, iEdgeTest : integer;
-  Face0, Face1 : TFace;
-  Edge, NewEdge, TestEdge : TEdge;
+  iEdge, EdgeCount, Vi0, Vi1, iEdgeTest: integer;
+  Face0, Face1: TGLFace;
+  Edge, NewEdge, TestEdge: TGLEdge;
 begin
 begin
   // For each edge that's connected by two triangles, create a new edge that
   // For each edge that's connected by two triangles, create a new edge that
   // connects the two "extra" vertices.... makes sense?
   // connects the two "extra" vertices.... makes sense?
   EdgeCount := EdgeList.Count;
   EdgeCount := EdgeList.Count;
 
 
-  for iEdge := 0 to EdgeCount-1 do
+  for iEdge := 0 to EdgeCount - 1 do
   begin
   begin
     Edge := EdgeList[iEdge];
     Edge := EdgeList[iEdge];
-
     if Assigned(Edge.Faces[1]) then
     if Assigned(Edge.Faces[1]) then
     begin
     begin
       Face0 := Edge.Faces[0];
       Face0 := Edge.Faces[0];
       Face1 := Edge.Faces[1];
       Face1 := Edge.Faces[1];
-
-      if (Face0.Vertices[0] <> Edge.Vertices[0]) and (Face0.Vertices[0] <> Edge.Vertices[1]) then
-        vi0 := Face0.Vertices[0]
-      else if (Face0.Vertices[1] <> Edge.Vertices[0]) and (Face0.Vertices[1] <> Edge.Vertices[1]) then
-        vi0 := Face0.Vertices[1]
+      if (Face0.Vertices[0] <> Edge.Vertices[0]) and
+        (Face0.Vertices[0] <> Edge.Vertices[1]) then
+        Vi0 := Face0.Vertices[0]
+      else if (Face0.Vertices[1] <> Edge.Vertices[0]) and
+        (Face0.Vertices[1] <> Edge.Vertices[1]) then
+        Vi0 := Face0.Vertices[1]
       else
       else
-        vi0 := Face0.Vertices[2];
-
-      if (Face1.Vertices[0] <> Edge.Vertices[0]) and (Face1.Vertices[0] <> Edge.Vertices[1]) then
-        vi1 := Face1.Vertices[0]
-      else if (Face1.Vertices[1] <> Edge.Vertices[0]) and (Face1.Vertices[1] <> Edge.Vertices[1]) then
-        vi1 := Face1.Vertices[1]
+        Vi0 := Face0.Vertices[2];
+
+      if (Face1.Vertices[0] <> Edge.Vertices[0]) and
+        (Face1.Vertices[0] <> Edge.Vertices[1]) then
+        Vi1 := Face1.Vertices[0]
+      else if (Face1.Vertices[1] <> Edge.Vertices[0]) and
+        (Face1.Vertices[1] <> Edge.Vertices[1]) then
+        Vi1 := Face1.Vertices[1]
       else
       else
-        vi1 := Face1.Vertices[2];
+        Vi1 := Face1.Vertices[2];
 
 
-      if (vi0=vi1) or
-         (vi0=Edge.Vertices[0]) or
-         (vi0=Edge.Vertices[1]) or
-         (vi1=Edge.Vertices[0]) or
-         (vi1=Edge.Vertices[1]) then
+      if (Vi0 = Vi1) or (Vi0 = Edge.Vertices[0]) or (Vi0 = Edge.Vertices[1]) or
+        (Vi1 = Edge.Vertices[0]) or (Vi1 = Edge.Vertices[1]) then
         continue;
         continue;
-
       // Find an indentical edge, if there is one
       // Find an indentical edge, if there is one
       for iEdgeTest := 0 to EdgeList.Count - 1 do
       for iEdgeTest := 0 to EdgeList.Count - 1 do
       begin
       begin
         TestEdge := EdgeList[iEdgeTest];
         TestEdge := EdgeList[iEdgeTest];
 
 
-        if (TestEdge.Vertices[0]=Vi0) and (TestEdge.Vertices[1]=Vi1) or
-           (TestEdge.Vertices[1]=Vi0) and (TestEdge.Vertices[0]=Vi1) then
+        if (TestEdge.Vertices[0] = Vi0) and (TestEdge.Vertices[1] = Vi1) or
+          (TestEdge.Vertices[1] = Vi0) and (TestEdge.Vertices[0] = Vi1) then
         begin
         begin
           // Edge allready exists!
           // Edge allready exists!
           inc(FEdgeDoublesSkipped);
           inc(FEdgeDoublesSkipped);
           continue;
           continue;
         end;
         end;
       end;
       end;
-
-      NewEdge := TEdge.Create(self, Vi0, Vi1, nil, nil, Edge.MeshObject, false);
-
-      EdgeList.Add(NewEdge);//}
+      NewEdge := TGLEdge.Create(self, Vi0, Vi1, nil, nil, Edge.MeshObject, false);
+      EdgeList.Add(NewEdge);
+      // *)
     end;
     end;
   end;
   end;
 end;
 end;
 
 
-function TEdgeDetector.AddNode(const VerletWorld : TGLVerletWorld; const MeshObject: TMeshObject;
-  const VertexIndex: integer): TVerletNode;
+function TGLEdgeDetector.AddNode(const VerletWorld: TGLVerletWorld;
+  const MeshObject: TMeshObject; const VertexIndex: integer): TGLVerletNode;
 var
 var
-  Location : TAffineVector;
-  aNode : TMeshObjectVerletNode;
-  i : integer;
+  Location: TAffineVector;
+  aNode: TGLMeshObjectVerletNode;
+  i: integer;
 begin
 begin
   // Is there an identical node?
   // Is there an identical node?
-  Location := MeshObject.Owner.Owner.LocalToAbsolute(MeshObject.Vertices[VertexIndex]);
+  Location := MeshObject.Owner.Owner.LocalToAbsolute
+    (MeshObject.Vertices[VertexIndex]);
 
 
-  for i := FCurrentNodeOffset to FNodeList.Count-1 do
+  for i := FCurrentNodeOffset to FNodeList.Count - 1 do
   begin
   begin
-    aNode := TMeshObjectVerletNode(FNodeList[i]);
-
-    if VectorDistance2(Location, aNode.Location)<=FWeldDistance then
+    aNode := TGLMeshObjectVerletNode(FNodeList[i]);
+    if VectorDistance2(Location, aNode.Location) <= FWeldDistance then
     begin
     begin
       FNodeList.Add(aNode);
       FNodeList.Add(aNode);
       aNode.VertexIndices.Add(VertexIndex);
       aNode.VertexIndices.Add(VertexIndex);
-      Result:=aNode;
-      Exit;
+      result := aNode;
+      exit;
     end;
     end;
-  end;//}
-
-  aNode := TMeshObjectVerletNode.CreateOwned(VerletWorld);
+  end; // *)
+  aNode := TGLMeshObjectVerletNode.CreateOwned(VerletWorld);
   aNode.MeshObject := MeshObject;
   aNode.MeshObject := MeshObject;
   aNode.VertexIndices.Add(VertexIndex);
   aNode.VertexIndices.Add(VertexIndex);
   aNode.Location := Location;
   aNode.Location := Location;
   aNode.OldLocation := Location;
   aNode.OldLocation := Location;
-
   FNodeList.Add(aNode);
   FNodeList.Add(aNode);
-  Result:=aNode;
+  result := aNode;
 end;
 end;
 
 
-procedure TEdgeDetector.ProcessMesh;
+procedure TGLEdgeDetector.ProcessMesh;
 begin
 begin
   inherited;
   inherited;
-
   BuildOpposingEdges;
   BuildOpposingEdges;
 end;
 end;
 
 
-procedure TEdgeDetector.ReplaceVertexIndex(const ViRemove,
+procedure TGLEdgeDetector.ReplaceVertexIndex(const ViRemove,
   ViReplaceWith: integer);
   ViReplaceWith: integer);
 var
 var
-  i : integer;
-  Done : boolean;
-  Edge : TEdge;
+  i: integer;
+  Done: boolean;
+  Edge: TGLEdge;
 begin
 begin
-  for i := 0 to FaceList.Count-1 do
+  for i := 0 to FaceList.Count - 1 do
     with FaceList[i] do
     with FaceList[i] do
     begin
     begin
       if Active then
       if Active then
@@ -687,18 +665,16 @@ begin
         if Vertices[2] = ViRemove then
         if Vertices[2] = ViRemove then
           Vertices[2] := ViReplaceWith;
           Vertices[2] := ViReplaceWith;
 
 
-        if (Vertices[0]=Vertices[1]) or
-         (Vertices[1]=Vertices[2]) or
-         (Vertices[2]=Vertices[0]) then
+        if (Vertices[0] = Vertices[1]) or (Vertices[1] = Vertices[2]) or
+          (Vertices[2] = Vertices[0]) then
           Active := false;
           Active := false;
       end;
       end;
     end;
     end;
-
   Done := false;
   Done := false;
   while not Done do
   while not Done do
   begin
   begin
     Done := true;
     Done := true;
-    for i := 0 to EdgeList.Count-1 do
+    for i := 0 to EdgeList.Count - 1 do
       with EdgeList[i] do
       with EdgeList[i] do
       begin
       begin
         if (Vertices[0] = ViRemove) or (Vertices[1] = ViRemove) then
         if (Vertices[0] = ViRemove) or (Vertices[1] = ViRemove) then
@@ -708,78 +684,68 @@ begin
 
 
           if Vertices[1] = ViRemove then
           if Vertices[1] = ViRemove then
             Vertices[1] := ViReplaceWith;
             Vertices[1] := ViReplaceWith;
-
           UpdateEdgeLength;
           UpdateEdgeLength;
-
           Edge := EdgeList[i];
           Edge := EdgeList[i];
           EdgeList.Delete(i);
           EdgeList.Delete(i);
-
-          if Edge.Length=-1 then
+          if Edge.Length = -1 then
             Edge.Free
             Edge.Free
           else
           else
             EdgeList.InsertSorted(Edge);
             EdgeList.InsertSorted(Edge);
-
           Done := false;
           Done := false;
-
-          break;//}
+          break; // }
         end;
         end;
       end;
       end;
   end;
   end;
 end;
 end;
 
 
-//--------------------------
-// TFace
-//--------------------------
-
-constructor TFace.Create(aMeshObject: TMeshObject);
+// --------------------------
+// TGLFace
+// --------------------------
+constructor TGLFace.Create(aMeshObject: TMeshObject);
 begin
 begin
   MeshObject := aMeshObject;
   MeshObject := aMeshObject;
   Active := true;
   Active := true;
 end;
 end;
 
 
-procedure TFace.UpdateNormal;
+procedure TGLFace.UpdateNormal;
 begin
 begin
-  CalcPlaneNormal(
-    MeshObject.Vertices[Vertices[0]],
-    MeshObject.Vertices[Vertices[1]],
-    MeshObject.Vertices[Vertices[2]], Normal);
+  CalcPlaneNormal(MeshObject.Vertices[Vertices[0]],
+    MeshObject.Vertices[Vertices[1]], MeshObject.Vertices[Vertices[2]], Normal);
 end;
 end;
 
 
-//------------------
-{ TEdge }
-//------------------
-
-procedure TEdge.Contract;
+// ------------------
+// TGLEdge
+// ------------------
+procedure TGLEdge.Contract;
 begin
 begin
   // We're removing vertex 1 and replacing it with vertex 0
   // We're removing vertex 1 and replacing it with vertex 0
   FOwner.ReplaceVertexIndex(Vertices[1], Vertices[0]);
   FOwner.ReplaceVertexIndex(Vertices[1], Vertices[0]);
-  //MeshObject.Vertices[Vertices[0]] := MeshObject.Vertices[Vertices[1]];
+  // MeshObject.Vertices[Vertices[0]] := MeshObject.Vertices[Vertices[1]];
   Length := -1;
   Length := -1;
 end;
 end;
 
 
-constructor TEdge.Create(const AOwner: TEdgeDetector; AVi0, AVi1 : integer;
-  AFace0, AFace1 : TFace; AMeshObject : TMeshObject; ASolid : boolean);
+constructor TGLEdge.Create(const AOwner: TGLEdgeDetector; AVi0, AVi1: integer;
+  AFace0, AFace1: TGLFace; aMeshObject: TMeshObject; ASolid: boolean);
 begin
 begin
   FOwner := AOwner;
   FOwner := AOwner;
   Vertices[0] := AVi0;
   Vertices[0] := AVi0;
   Vertices[1] := AVi1;
   Vertices[1] := AVi1;
   Faces[0] := AFace0;
   Faces[0] := AFace0;
   Faces[1] := AFace1;
   Faces[1] := AFace1;
-  FMeshObject := AMeshObject;
+  FMeshObject := aMeshObject;
   FSolid := true;
   FSolid := true;
-
   UpdateEdgeLength;
   UpdateEdgeLength;
 end;
 end;
 
 
-procedure TEdge.UpdateEdgeLength;
+procedure TGLEdge.UpdateEdgeLength;
 begin
 begin
   if FOwner.FCalcEdgeLength then
   if FOwner.FCalcEdgeLength then
   begin
   begin
     if Vertices[0] = Vertices[1] then
     if Vertices[0] = Vertices[1] then
       Length := -1
       Length := -1
     else
     else
-      Length := VectorDistance(
-        FOwner.GLBaseMesh.LocalToAbsolute(FMeshObject.Vertices[Vertices[0]]),
+      Length := VectorDistance(FOwner.GLBaseMesh.LocalToAbsolute
+        (FMeshObject.Vertices[Vertices[0]]),
         FOwner.GLBaseMesh.LocalToAbsolute(FMeshObject.Vertices[Vertices[1]]));
         FOwner.GLBaseMesh.LocalToAbsolute(FMeshObject.Vertices[Vertices[1]]));
   end;
   end;
 end;
 end;

+ 83 - 83
Source/GLS.VerletHairClasses.pas

@@ -1,12 +1,11 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.VerletHairClasses;
 unit GLS.VerletHairClasses;
 
 
 (*
 (*
-   Creates a single strand of hair using verlet classes. Can be used to simulate
-   ropes, fur or hair. 
+  Creates a single strand of hair using verlet classes. Can be used to simulate
+  ropes, fur or hair.
 *)
 *)
 
 
 interface
 interface
@@ -14,170 +13,171 @@ interface
 {$I GLScene.inc}
 {$I GLScene.inc}
 
 
 uses
 uses
-  System.Classes, 
+  System.Classes,
   System.SysUtils,
   System.SysUtils,
-  GLS.VerletTypes, 
-  GLS.VectorTypes, 
-  GLS.VectorLists, 
+  GLS.VerletTypes,
+  GLS.VectorTypes,
+  GLS.VectorLists,
   GLS.VectorGeometry;
   GLS.VectorGeometry;
 
 
 type
 type
-  TVHStiffness = (vhsFull, vhsSkip1Node, vhsSkip2Node, vhsSkip3Node,
+  TGLStiffnessVH = (vhsFull, vhsSkip1Node, vhsSkip2Node, vhsSkip3Node,
     vhsSkip4Node, vhsSkip5Node, vhsSkip6Node, vhsSkip7Node, vhsSkip8Node,
     vhsSkip4Node, vhsSkip5Node, vhsSkip6Node, vhsSkip7Node, vhsSkip8Node,
     vhsSkip9Node);
     vhsSkip9Node);
-  TVHStiffnessSet = set of TVHStiffness;
+  TGLStiffnessSetVH = set of TGLStiffnessVH;
 
 
   TGLVerletHair = class
   TGLVerletHair = class
   private
   private
-    FNodeList: TVerletNodeList;
+    FNodeList: TGLVerletNodeList;
     FLinkCount: integer;
     FLinkCount: integer;
     FRootDepth: single;
     FRootDepth: single;
     FVerletWorld: TGLVerletWorld;
     FVerletWorld: TGLVerletWorld;
     FHairLength: single;
     FHairLength: single;
     FData: pointer;
     FData: pointer;
-    FStiffness: TVHStiffnessSet;
-    FStiffnessList : TList;
-    function GetAnchor: TVerletNode;
-    function GetRoot: TVerletNode;
+    FStiffness: TGLStiffnessSetVH;
+    FStiffnessList: TList;
+    function GetAnchor: TGLBaseNode;
+    function GetRoot: TGLBaseNode;
     function GetLinkLength: single;
     function GetLinkLength: single;
-    procedure AddStickStiffness(const ANodeSkip : integer);
-    procedure SetStiffness(const Value: TVHStiffnessSet);
+    procedure AddStickStiffness(const ANodeSkip: integer);
+    procedure SetStiffness(const Value: TGLStiffnessSetVH);
   public
   public
     procedure BuildHair(const AAnchorPosition, AHairDirection: TAffineVector);
     procedure BuildHair(const AAnchorPosition, AHairDirection: TAffineVector);
     procedure BuildStiffness;
     procedure BuildStiffness;
     procedure ClearStiffness;
     procedure ClearStiffness;
     procedure Clear;
     procedure Clear;
-    constructor Create(const AVerletWorld : TGLVerletWorld;
-    const ARootDepth, AHairLength : single; ALinkCount : integer;
-    const AAnchorPosition, AHairDirection : TAffineVector;
-    const AStiffness : TVHStiffnessSet);
+    constructor Create(const AVerletWorld: TGLVerletWorld;
+      const ARootDepth, AHairLength: single; ALinkCount: integer;
+      const AAnchorPosition, AHairDirection: TAffineVector;
+      const AStiffness: TGLStiffnessSetVH);
     destructor Destroy; override;
     destructor Destroy; override;
-    property NodeList : TVerletNodeList read FNodeList;
-    property VerletWorld : TGLVerletWorld read FVerletWorld;
-    property RootDepth : single read FRootDepth;
-    property LinkLength : single read GetLinkLength;
-    property LinkCount : integer read FLinkCount;
-    property HairLength : single read FHairLength;
-    property Stiffness : TVHStiffnessSet read FStiffness write SetStiffness;
-    property Data : pointer read FData write FData;
-    {Anchor should be nailed down to give the hair stability }
-    property Anchor : TVerletNode read GetAnchor;
-    {Root should be nailed down to give the hair stability }
-    property Root : TVerletNode read GetRoot;
+    property NodeList: TGLVerletNodeList read FNodeList;
+    property VerletWorld: TGLVerletWorld read FVerletWorld;
+    property RootDepth: single read FRootDepth;
+    property LinkLength: single read GetLinkLength;
+    property LinkCount: integer read FLinkCount;
+    property HairLength: single read FHairLength;
+    property Stiffness: TGLStiffnessSetVH read FStiffness write SetStiffness;
+    property Data: pointer read FData write FData;
+    // Anchor should be nailed down to give the hair stability
+    property Anchor: TGLBaseNode read GetAnchor;
+    // Root should be nailed down to give the hair stability
+    property Root: TGLBaseNode read GetRoot;
   end;
   end;
 
 
-//------------------------------------------------------------------
+// ------------------------------------------------------------------
 implementation
 implementation
-//------------------------------------------------------------------
-
-{ TGLVerletHair }
+// ------------------------------------------------------------------
 
 
+//-----------------------------
+// TGLVerletHair
+//-----------------------------
 procedure TGLVerletHair.AddStickStiffness(const ANodeSkip: integer);
 procedure TGLVerletHair.AddStickStiffness(const ANodeSkip: integer);
 var
 var
-  i : integer;
+  i: integer;
 begin
 begin
-  for i := 0 to NodeList.Count-(1+ANodeSkip*2) do
-    FStiffnessList.Add(VerletWorld.CreateStick(NodeList[i], NodeList[i+2*ANodeSkip]));
+  for i := 0 to NodeList.Count - (1 + ANodeSkip * 2) do
+    FStiffnessList.Add(VerletWorld.CreateStick(NodeList[i],
+      NodeList[i + 2 * ANodeSkip]));
 end;
 end;
 
 
-procedure TGLVerletHair.BuildHair(const AAnchorPosition, AHairDirection: TAffineVector);
+procedure TGLVerletHair.BuildHair(const AAnchorPosition, AHairDirection
+  : TAffineVector);
 var
 var
-  i : integer;
-  Position : TAffineVector;
-  Node, PrevNode : TVerletNode;
-  Direction : TAffineVector;
+  i: integer;
+  Position: TAffineVector;
+  Node, PrevNode: TGLBaseNode;
+  Direction: TAffineVector;
 begin
 begin
   Clear;
   Clear;
-
   Direction := VectorNormalize(AHairDirection);
   Direction := VectorNormalize(AHairDirection);
-
   // Fix the root of the hair
   // Fix the root of the hair
   Position := VectorAdd(AAnchorPosition, VectorScale(Direction, -FRootDepth));
   Position := VectorAdd(AAnchorPosition, VectorScale(Direction, -FRootDepth));
   Node := VerletWorld.CreateOwnedNode(Position);
   Node := VerletWorld.CreateOwnedNode(Position);
   NodeList.Add(Node);
   NodeList.Add(Node);
   Node.NailedDown := true;
   Node.NailedDown := true;
   PrevNode := Node;
   PrevNode := Node;
-
   // Now add the links in the hair
   // Now add the links in the hair
-  for i := 0 to FLinkCount-1 do
+  for i := 0 to FLinkCount - 1 do
   begin
   begin
-    Position := VectorAdd(AAnchorPosition, VectorScale(Direction, HairLength * (i/LinkCount)));
-
+    Position := VectorAdd(AAnchorPosition, VectorScale(Direction,
+      HairLength * (i / LinkCount)));
     Node := VerletWorld.CreateOwnedNode(Position);
     Node := VerletWorld.CreateOwnedNode(Position);
     NodeList.Add(Node);
     NodeList.Add(Node);
-
     // first one is the anchor
     // first one is the anchor
-    if i=0 then
+    if i = 0 then
       Node.NailedDown := true
       Node.NailedDown := true
     else
     else
       // Creates the hair link
       // Creates the hair link
       VerletWorld.CreateStick(PrevNode, Node);
       VerletWorld.CreateStick(PrevNode, Node);
-
     PrevNode := Node;
     PrevNode := Node;
   end;
   end;
-
   // Now we must stiffen the hair with either sticks or springs
   // Now we must stiffen the hair with either sticks or springs
   BuildStiffness;
   BuildStiffness;
 end;
 end;
 
 
 procedure TGLVerletHair.BuildStiffness;
 procedure TGLVerletHair.BuildStiffness;
 var
 var
-  i : integer;
+  i: integer;
 begin
 begin
   ClearStiffness;
   ClearStiffness;
-
   if vhsFull in FStiffness then
   if vhsFull in FStiffness then
   begin
   begin
     for i := 1 to 100 do
     for i := 1 to 100 do
       AddStickStiffness(i);
       AddStickStiffness(i);
-      
     exit;
     exit;
   end;
   end;
-
-  if vhsSkip1Node in FStiffness then AddStickStiffness(1);
-  if vhsSkip2Node in FStiffness then AddStickStiffness(2);
-  if vhsSkip3Node in FStiffness then AddStickStiffness(3);
-  if vhsSkip4Node in FStiffness then AddStickStiffness(4);
-  if vhsSkip5Node in FStiffness then AddStickStiffness(5);
-  if vhsSkip6Node in FStiffness then AddStickStiffness(6);
-  if vhsSkip7Node in FStiffness then AddStickStiffness(7);
-  if vhsSkip8Node in FStiffness then AddStickStiffness(8);
-  if vhsSkip9Node in FStiffness then AddStickStiffness(9);
+  if vhsSkip1Node in FStiffness then
+    AddStickStiffness(1);
+  if vhsSkip2Node in FStiffness then
+    AddStickStiffness(2);
+  if vhsSkip3Node in FStiffness then
+    AddStickStiffness(3);
+  if vhsSkip4Node in FStiffness then
+    AddStickStiffness(4);
+  if vhsSkip5Node in FStiffness then
+    AddStickStiffness(5);
+  if vhsSkip6Node in FStiffness then
+    AddStickStiffness(6);
+  if vhsSkip7Node in FStiffness then
+    AddStickStiffness(7);
+  if vhsSkip8Node in FStiffness then
+    AddStickStiffness(8);
+  if vhsSkip9Node in FStiffness then
+    AddStickStiffness(9);
 end;
 end;
 
 
 procedure TGLVerletHair.Clear;
 procedure TGLVerletHair.Clear;
 var
 var
-  i : integer;
+  i: integer;
 begin
 begin
   ClearStiffness;
   ClearStiffness;
-  for i := FNodeList.Count-1 downto 0 do
+  for i := FNodeList.Count - 1 downto 0 do
     FNodeList[i].Free;
     FNodeList[i].Free;
-
   FNodeList.Clear;
   FNodeList.Clear;
   FStiffnessList.Clear;
   FStiffnessList.Clear;
 end;
 end;
 
 
 procedure TGLVerletHair.ClearStiffness;
 procedure TGLVerletHair.ClearStiffness;
 var
 var
-  i : integer;
+  i: integer;
 begin
 begin
-  for i := 0 to FStiffnessList.Count-1 do
-    TVerletConstraint(FStiffnessList[i]).Free;
-
+  for i := 0 to FStiffnessList.Count - 1 do
+    TGLVerletConstraint(FStiffnessList[i]).Free;
   FStiffnessList.Clear;
   FStiffnessList.Clear;
 end;
 end;
 
 
-constructor TGLVerletHair.Create(const AVerletWorld : TGLVerletWorld;
-      const ARootDepth, AHairLength : single; ALinkCount : integer;
-      const AAnchorPosition, AHairDirection : TAffineVector;
-      const AStiffness : TVHStiffnessSet);
+constructor TGLVerletHair.Create(const AVerletWorld: TGLVerletWorld;
+  const ARootDepth, AHairLength: single; ALinkCount: integer;
+  const AAnchorPosition, AHairDirection: TAffineVector;
+  const AStiffness: TGLStiffnessSetVH);
 begin
 begin
   FVerletWorld := AVerletWorld;
   FVerletWorld := AVerletWorld;
   FRootDepth := ARootDepth;
   FRootDepth := ARootDepth;
   FLinkCount := ALinkCount;
   FLinkCount := ALinkCount;
   FHairLength := AHairLength;
   FHairLength := AHairLength;
 
 
-  FNodeList := TVerletNodeList.Create;
+  FNodeList := TGLVerletNodeList.Create;
   FStiffness := AStiffness;
   FStiffness := AStiffness;
   FStiffnessList := TList.Create;
   FStiffnessList := TList.Create;
 
 
@@ -192,25 +192,25 @@ begin
   inherited;
   inherited;
 end;
 end;
 
 
-function TGLVerletHair.GetAnchor: TVerletNode;
+function TGLVerletHair.GetAnchor: TGLBaseNode;
 begin
 begin
   result := NodeList[1];
   result := NodeList[1];
 end;
 end;
 
 
 function TGLVerletHair.GetLinkLength: single;
 function TGLVerletHair.GetLinkLength: single;
 begin
 begin
-  if LinkCount>0 then
+  if LinkCount > 0 then
     result := HairLength / LinkCount
     result := HairLength / LinkCount
   else
   else
     result := 0;
     result := 0;
 end;
 end;
 
 
-function TGLVerletHair.GetRoot: TVerletNode;
+function TGLVerletHair.GetRoot: TGLBaseNode;
 begin
 begin
   result := NodeList[0];
   result := NodeList[0];
 end;
 end;
 
 
-procedure TGLVerletHair.SetStiffness(const Value: TVHStiffnessSet);
+procedure TGLVerletHair.SetStiffness(const Value: TGLStiffnessSetVH);
 begin
 begin
   FStiffness := Value;
   FStiffness := Value;
   BuildStiffness;
   BuildStiffness;

+ 73 - 75
Source/GLS.VerletSkeletonColliders.pas

@@ -1,7 +1,6 @@
 //
 //
 // The graphics rendering engine GLScene http://glscene.org
 // The graphics rendering engine GLScene http://glscene.org
 //
 //
-
 unit GLS.VerletSkeletonColliders;
 unit GLS.VerletSkeletonColliders;
 
 
 (* Skeleton colliders for defining and controlling verlet constraints. *)
 (* Skeleton colliders for defining and controlling verlet constraints. *)
@@ -17,57 +16,54 @@ uses
   GLS.VectorTypes;
   GLS.VectorTypes;
 
 
 type
 type
-
-  //Base verlet skeleton collider class.
-  TSCVerletBase = class(TGLSkeletonCollider)
-    private
-      FVerletConstraint : TVerletConstraint;
-    public
-      procedure WriteToFiler(writer : TVirtualWriter); override;
-      procedure ReadFromFiler(reader : TVirtualReader); override;
-      procedure AddToVerletWorld(VerletWorld : TGLVerletWorld); virtual;
-      // The verlet constraint is created through the AddToVerletWorld procedure
-      property VerletConstraint : TVerletConstraint read FVerletConstraint;
+  // Base Verlet Skeleton Collider class.
+  TGLVerletBase = class(TGLSkeletonCollider)
+  private
+    FVerletConstraint: TGLVerletConstraint;
+  public
+    procedure WriteToFiler(writer: TVirtualWriter); override;
+    procedure ReadFromFiler(reader: TVirtualReader); override;
+    procedure AddToVerletWorld(VerletWorld: TGLVerletWorld); virtual;
+    // The verlet constraint is created through the AddToVerletWorld procedure
+    property VerletConstraint: TGLVerletConstraint read FVerletConstraint;
   end;
   end;
 
 
   // Sphere shaped verlet constraint in a skeleton collider
   // Sphere shaped verlet constraint in a skeleton collider
-  TSCVerletSphere = class(TSCVerletBase)
-    private
-      FRadius : Single;
-    protected
-      procedure SetRadius(const val : Single);
-    public
-      constructor Create; override;
-      procedure WriteToFiler(writer : TVirtualWriter); override;
-      procedure ReadFromFiler(reader : TVirtualReader); override;
-      procedure AddToVerletWorld(VerletWorld : TGLVerletWorld); override;
-      procedure AlignCollider; override;
-
-      property Radius : Single read FRadius write SetRadius;
+  TGLVerletSphere = class(TGLVerletBase)
+  private
+    FRadius: Single;
+  protected
+    procedure SetRadius(const val: Single);
+  public
+    constructor Create; override;
+    procedure WriteToFiler(writer: TVirtualWriter); override;
+    procedure ReadFromFiler(reader: TVirtualReader); override;
+    procedure AddToVerletWorld(VerletWorld: TGLVerletWorld); override;
+    procedure AlignCollider; override;
+    property Radius: Single read FRadius write SetRadius;
   end;
   end;
 
 
   // Capsule shaped verlet constraint in a skeleton collider
   // Capsule shaped verlet constraint in a skeleton collider
-  TSCVerletCapsule = class(TSCVerletBase)
-    private
-      FRadius,
-      FLength : Single;
-    protected
-      procedure SetRadius(const val : Single);
-      procedure SetLength(const val : Single);
-    public
-      constructor Create; override;
-      procedure WriteToFiler(writer : TVirtualWriter); override;
-      procedure ReadFromFiler(reader : TVirtualReader); override;
-      procedure AddToVerletWorld(VerletWorld : TGLVerletWorld); override;
-      procedure AlignCollider; override;
-      property Radius : Single read FRadius write SetRadius;
-      property Length : Single read FLength write SetLength;
+  TGLVerletCapsule = class(TGLVerletBase)
+  private
+    FRadius, FLength: Single;
+  protected
+    procedure SetRadius(const val: Single);
+    procedure SetLength(const val: Single);
+  public
+    constructor Create; override;
+    procedure WriteToFiler(writer: TVirtualWriter); override;
+    procedure ReadFromFiler(reader: TVirtualReader); override;
+    procedure AddToVerletWorld(VerletWorld: TGLVerletWorld); override;
+    procedure AlignCollider; override;
+    property Radius: Single read FRadius write SetRadius;
+    property Length: Single read FLength write SetLength;
   end;
   end;
 
 
-(* After loading call this function to add all the constraints in a
-   skeleton collider list to a given verlet world. *)
-procedure AddSCVerletConstriantsToVerletWorld(
-  colliders : TGLSkeletonColliderList; world : TGLVerletWorld);
+  (* After loading call this function to add all the constraints in a
+    skeleton collider list to a given verlet world. *)
+procedure AddSCVerletConstriantsToVerletWorld
+  (colliders: TGLSkeletonColliderList; world: TGLVerletWorld);
 
 
 // ------------------------------------------------------------------
 // ------------------------------------------------------------------
 implementation
 implementation
@@ -83,15 +79,15 @@ var
   i: Integer;
   i: Integer;
 begin
 begin
   for i := 0 to colliders.Count - 1 do
   for i := 0 to colliders.Count - 1 do
-    if colliders[i] is TSCVerletBase then
-      TSCVerletBase(colliders[i]).AddToVerletWorld(world);
+    if colliders[i] is TGLVerletBase then
+      TGLVerletBase(colliders[i]).AddToVerletWorld(world);
 end;
 end;
 
 
 // ------------------
 // ------------------
-// ------------------ TSCVerletBase ------------------
+// ------------------ TGLVerletBase ------------------
 // ------------------
 // ------------------
 
 
-procedure TSCVerletBase.WriteToFiler(writer: TVirtualWriter);
+procedure TGLVerletBase.WriteToFiler(writer: TVirtualWriter);
 begin
 begin
   inherited WriteToFiler(writer);
   inherited WriteToFiler(writer);
   with writer do
   with writer do
@@ -100,7 +96,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TSCVerletBase.ReadFromFiler(reader: TVirtualReader);
+procedure TGLVerletBase.ReadFromFiler(reader: TVirtualReader);
 var
 var
   archiveVersion: Integer;
   archiveVersion: Integer;
 begin
 begin
@@ -113,24 +109,22 @@ begin
       RaiseFilerException(archiveVersion);
       RaiseFilerException(archiveVersion);
 end;
 end;
 
 
-procedure TSCVerletBase.AddToVerletWorld(VerletWorld: TGLVerletWorld);
+procedure TGLVerletBase.AddToVerletWorld(VerletWorld: TGLVerletWorld);
 begin
 begin
   AlignCollider;
   AlignCollider;
 end;
 end;
 
 
-
 // ------------------
 // ------------------
-// ------------------ TSCVerletSphere ------------------
+// ------------------ TGLVerletSphere ------------------
 // ------------------
 // ------------------
-
-constructor TSCVerletSphere.Create;
+constructor TGLVerletSphere.Create;
 begin
 begin
   inherited;
   inherited;
   Radius := 0.5;
   Radius := 0.5;
   AlignCollider;
   AlignCollider;
 end;
 end;
 
 
-procedure TSCVerletSphere.WriteToFiler(writer: TVirtualWriter);
+procedure TGLVerletSphere.WriteToFiler(writer: TVirtualWriter);
 begin
 begin
   inherited WriteToFiler(writer);
   inherited WriteToFiler(writer);
   with writer do
   with writer do
@@ -140,7 +134,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TSCVerletSphere.ReadFromFiler(reader: TVirtualReader);
+procedure TGLVerletSphere.ReadFromFiler(reader: TVirtualReader);
 var
 var
   archiveVersion: Integer;
   archiveVersion: Integer;
 begin
 begin
@@ -153,21 +147,21 @@ begin
     RaiseFilerException(archiveVersion);
     RaiseFilerException(archiveVersion);
 end;
 end;
 
 
-procedure TSCVerletSphere.AddToVerletWorld(VerletWorld: TGLVerletWorld);
+procedure TGLVerletSphere.AddToVerletWorld(VerletWorld: TGLVerletWorld);
 begin
 begin
   FVerletConstraint := TVCSphere.Create(VerletWorld);
   FVerletConstraint := TVCSphere.Create(VerletWorld);
   TVCSphere(FVerletConstraint).Radius := FRadius;
   TVCSphere(FVerletConstraint).Radius := FRadius;
   inherited;
   inherited;
 end;
 end;
 
 
-procedure TSCVerletSphere.AlignCollider;
+procedure TGLVerletSphere.AlignCollider;
 begin
 begin
   inherited;
   inherited;
   if Assigned(FVerletConstraint) then
   if Assigned(FVerletConstraint) then
     TVCSphere(FVerletConstraint).Location := AffineVectorMake(GlobalMatrix.W);
     TVCSphere(FVerletConstraint).Location := AffineVectorMake(GlobalMatrix.W);
 end;
 end;
 
 
-procedure TSCVerletSphere.SetRadius(const val: Single);
+procedure TGLVerletSphere.SetRadius(const val: Single);
 begin
 begin
   if val <> FRadius then
   if val <> FRadius then
   begin
   begin
@@ -178,10 +172,9 @@ begin
 end;
 end;
 
 
 // ------------------
 // ------------------
-// ------------------ TSCVerletCapsule ------------------
+// ------------------ TGLVerletCapsule ------------------
 // ------------------
 // ------------------
-
-constructor TSCVerletCapsule.Create;
+constructor TGLVerletCapsule.Create;
 begin
 begin
   inherited;
   inherited;
   Radius := 0.5;
   Radius := 0.5;
@@ -189,7 +182,7 @@ begin
   AlignCollider;
   AlignCollider;
 end;
 end;
 
 
-procedure TSCVerletCapsule.WriteToFiler(writer : TVirtualWriter);
+procedure TGLVerletCapsule.WriteToFiler(writer: TVirtualWriter);
 begin
 begin
   inherited WriteToFiler(writer);
   inherited WriteToFiler(writer);
   with writer do
   with writer do
@@ -200,19 +193,23 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TSCVerletCapsule.ReadFromFiler(reader : TVirtualReader);
+procedure TGLVerletCapsule.ReadFromFiler(reader: TVirtualReader);
 var
 var
-  archiveVersion : integer;
+  archiveVersion: Integer;
 begin
 begin
   inherited ReadFromFiler(reader);
   inherited ReadFromFiler(reader);
-  archiveVersion:=reader.ReadInteger;
-  if archiveVersion=0 then with reader do begin
-    Radius:=ReadFloat;
-    Length:=ReadFloat;
-  end else RaiseFilerException(archiveVersion);
+  archiveVersion := reader.ReadInteger;
+  if archiveVersion = 0 then
+    with reader do
+    begin
+      Radius := ReadFloat;
+      Length := ReadFloat;
+    end
+  else
+    RaiseFilerException(archiveVersion);
 end;
 end;
 
 
-procedure TSCVerletCapsule.AddToVerletWorld(VerletWorld : TGLVerletWorld);
+procedure TGLVerletCapsule.AddToVerletWorld(VerletWorld: TGLVerletWorld);
 begin
 begin
   FVerletConstraint := TVCCapsule.Create(VerletWorld);
   FVerletConstraint := TVCCapsule.Create(VerletWorld);
   TVCCapsule(FVerletConstraint).Radius := FRadius;
   TVCCapsule(FVerletConstraint).Radius := FRadius;
@@ -220,7 +217,7 @@ begin
   inherited;
   inherited;
 end;
 end;
 
 
-procedure TSCVerletCapsule.AlignCollider;
+procedure TGLVerletCapsule.AlignCollider;
 begin
 begin
   inherited;
   inherited;
   if Assigned(FVerletConstraint) then
   if Assigned(FVerletConstraint) then
@@ -230,7 +227,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TSCVerletCapsule.SetRadius(const val : Single);
+procedure TGLVerletCapsule.SetRadius(const val: Single);
 begin
 begin
   if val <> FRadius then
   if val <> FRadius then
   begin
   begin
@@ -240,7 +237,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TSCVerletCapsule.SetLength(const val : Single);
+procedure TGLVerletCapsule.SetLength(const val: Single);
 begin
 begin
   if val <> FLength then
   if val <> FLength then
   begin
   begin
@@ -252,8 +249,9 @@ end;
 
 
 // ------------------------------------------------------------------
 // ------------------------------------------------------------------
 initialization
 initialization
+
 // ------------------------------------------------------------------
 // ------------------------------------------------------------------
 
 
-  RegisterClasses([TSCVerletBase,TSCVerletSphere,TSCVerletCapsule]);
+RegisterClasses([TGLVerletBase, TGLVerletSphere, TGLVerletCapsule]);
 
 
 end.
 end.

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 234 - 214
Source/GLS.VerletTypes.pas


+ 1 - 1
Source/GLS.zBuffer.pas

@@ -134,7 +134,7 @@ type
     Fsoft: boolean;
     Fsoft: boolean;
     FTolerance: single;
     FTolerance: single;
     FColor: TGLColor;
     FColor: TGLColor;
-    SCol: TPixel32;
+    SCol: TGLPixel32;
     //stepX, stepY :single;
     //stepX, stepY :single;
     FTexturePrepared: Boolean;
     FTexturePrepared: Boolean;
     FTexHandle: TGLTextureHandle;
     FTexHandle: TGLTextureHandle;

+ 3 - 3
Source/Physics.ODEUtils.pas

@@ -436,16 +436,16 @@ function CreateTriMeshFromBaseMesh(
   var Indices: PdIntegerArray): PdxGeom;
   var Indices: PdIntegerArray): PdxGeom;
 var
 var
   i, j, p: integer;
   i, j, p: integer;
-  FaceExtractor: TFaceExtractor;
+  FaceExtractor: TGLFaceExtractor;
   VertexCount: integer;
   VertexCount: integer;
   Vertex: TAffineVector;
   Vertex: TAffineVector;
   OffsetList: TIntegerList;
   OffsetList: TIntegerList;
-  Face: TFace;
+  Face: TGLFace;
   iMO: integer;
   iMO: integer;
   TriMeshData: PdxTriMeshData;
   TriMeshData: PdxTriMeshData;
 begin
 begin
   OffsetList := nil;
   OffsetList := nil;
-  FaceExtractor := TFaceExtractor.Create(GLBaseMesh);
+  FaceExtractor := TGLFaceExtractor.Create(GLBaseMesh);
 
 
   try
   try
     OffsetList := TIntegerList.Create;
     OffsetList := TIntegerList.Create;

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů