2
0
GLScene 4 жил өмнө
parent
commit
ed64c83bba
51 өөрчлөгдсөн 1081 нэмэгдсэн , 1092 устгасан
  1. 1 1
      AdvDemos/Delphi/TextureTB/FTTBMain.pas
  2. 0 1
      CleanRelease.bat
  3. BIN
      Demos/Delphi/meshes/ActorProxy.jpg
  4. BIN
      Demos/Delphi/meshes/ActorTwocam.jpg
  5. 3 0
      Demos/Delphi/meshes/Actorms3dFm.pas
  6. BIN
      Demos/Delphi/meshes/Centering.jpg
  7. BIN
      Demos/Delphi/meshes/Csg.jpg
  8. BIN
      Demos/Delphi/meshes/Ducky.jpg
  9. 0 1
      Demos/Delphi/meshes/DuckyFm.dfm
  10. 9 0
      Demos/Delphi/meshes/ExPolygon.dproj
  11. BIN
      Demos/Delphi/meshes/ExPolygon.jpg
  12. 0 1
      Demos/Delphi/meshes/ExPolygonFm.dfm
  13. BIN
      Demos/Delphi/meshes/Formula.jpg
  14. BIN
      Demos/Delphi/meshes/Mushroom.jpg
  15. BIN
      Demos/Delphi/meshes/Portal.jpg
  16. BIN
      Demos/Delphi/meshes/ShadedTerrain.jpg
  17. 3 3
      Demos/Delphi/meshes/Skeletal.dpr
  18. 1 3
      Demos/Delphi/meshes/Skeletal.dproj
  19. BIN
      Demos/Delphi/meshes/Skeletal.jpg
  20. 7 7
      Demos/Delphi/meshes/Subdivide.dpr
  21. 1 3
      Demos/Delphi/meshes/Subdivide.dproj
  22. BIN
      Demos/Delphi/meshes/Subdivide.jpg
  23. BIN
      Demos/Delphi/meshes/SynthTerrain.jpg
  24. BIN
      Demos/Delphi/meshes/Terrain.jpg
  25. BIN
      Demos/Delphi/meshes/Tiles.jpg
  26. BIN
      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
      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;
    bmp32 : TGLBitmap32;
    x, y : Integer;
-   pSrc : PPixel32Array;
+   pSrc : PGLPixel32Array;
    pDest : PIntegerArray;
    c : Integer;
 begin

+ 0 - 1
CleanRelease.bat

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

BIN
Demos/Delphi/meshes/ActorProxy.jpg


BIN
Demos/Delphi/meshes/ActorTwocam.jpg


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

@@ -139,6 +139,9 @@ begin
   GLSArchiveManager1.Archives[0].LoadFromFile('ActorMS3D.zlib');
 
 //  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('Chair', 'PNG');
   LoadTexture('Hair', 'PNG');

BIN
Demos/Delphi/meshes/Centering.jpg


BIN
Demos/Delphi/meshes/Csg.jpg


BIN
Demos/Delphi/meshes/Ducky.jpg


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

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

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

@@ -28,6 +28,12 @@
         <CfgParent>Base</CfgParent>
         <Base>true</Base>
     </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)'!=''">
         <Cfg_1_Win64>true</Cfg_1_Win64>
         <CfgParent>Cfg_1</CfgParent>
@@ -89,6 +95,9 @@
         <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
         <DCC_DebugInformation>0</DCC_DebugInformation>
     </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
+        <BT_BuildType>Debug</BT_BuildType>
+    </PropertyGroup>
     <PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
         <AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
         <AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>

BIN
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.Style = []
   OldCreateOrder = False
-  WindowState = wsMaximized
   OnShow = FormShow
   PixelsPerInch = 96
   TextHeight = 13

BIN
Demos/Delphi/meshes/Formula.jpg


BIN
Demos/Delphi/meshes/Mushroom.jpg


BIN
Demos/Delphi/meshes/Portal.jpg


BIN
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
    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>
    Thanks!
-}
+*)
 program Skeletal;
 
 uses
   Forms,
-  SkeletalFm in 'SkeletalFm.pas' {FormSkeletal};
+  SkeletalFm in 'SkeletalFm.pas';
 
 {$R *.RES}
 

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

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

BIN
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;
 
 uses
   Forms,
-  SubdivideFm in 'SubdivideFm.pas' {FormSubdivide};
+  SubdivideFm in 'SubdivideFm.pas';
 
 {$R *.res}
 

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

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

BIN
Demos/Delphi/meshes/Subdivide.jpg


BIN
Demos/Delphi/meshes/SynthTerrain.jpg


BIN
Demos/Delphi/meshes/Terrain.jpg


BIN
Demos/Delphi/meshes/Tiles.jpg


BIN
Demos/Delphi/meshes/Tree.jpg


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

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

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

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

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

@@ -8,9 +8,6 @@
 <!--
  /* Font Definitions */
  @font-face
-	{font-family:Wingdings;
-	panose-1:5 0 0 0 0 0 0 0 0 0;}
-@font-face
 	{font-family:"Cambria Math";
 	panose-1:2 4 5 3 5 4 6 3 2 4;}
 @font-face
@@ -44,6 +41,12 @@ span.a
 	{mso-style-name:"\0422\0435\043A\0441\0442 \0417\043D\0430\043A";
 	mso-style-link:\0422\0435\043A\0441\0442;
 	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
 	{font-size:10.0pt;}
 @page WordSection1
@@ -68,10 +71,10 @@ ul
 <p class=MsoPlainText><b><span lang=FR style='font-size:13.5pt;font-family:
 "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>
   <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>
@@ -80,18 +83,25 @@ ul
 
 <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>
- <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
       walk/run, turn/strafe</span></li>
   <li class=MsoNormal><span lang=FR>switching between first-person and
@@ -99,21 +109,41 @@ 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>effects of various AutoCentering options</span></li>
  </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>
 
-<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>The CSG system uses BSP to optimize what
       triangles it considers.</span></li>
@@ -124,9 +154,13 @@ ul
 
 <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
       object.</span></li>
   <li class=MsoNormal><span lang=FR>Use the resolution slider to increase or
@@ -134,12 +168,21 @@ 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>
 
-<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>
      :</span></li>
- <ul type=circle>
+ <ul style='margin-top:0cm' type=circle>
   <li class=MsoNormal><span lang=FR>using TMultiPolygon for rendering complex
       polygons</span></li>
   <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>
 
-<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
       object to extract mesh data from regular GLScene objects.</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>
 
-<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
       3D</span></li>
   <li class=MsoNormal><span lang=FR>triangle and triangle-strip meshes to make
@@ -170,11 +215,23 @@ 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>
 
-<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
       (.3DS) mesh</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>
 
-<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
       scenes</span></li>
   <li class=MsoNormal><span lang=FR>basic wolfenstein-like &quot;level
@@ -194,22 +253,24 @@ 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
       model (.smd)</span></li>
   <li class=MsoNormal><span lang=FR>animating an actor (skeletal animation)</span></li>
  </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>...</span></li>
  </ul>
@@ -217,34 +278,69 @@ ul
 
 <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>MD2 format isn't really suited for
       refinement</span></li>
  </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>1D textures</span></li>
  </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
       render a simple landscape</span></li>
   <li class=MsoNormal><span lang=FR>Full-screen mode and using
       THUDText/TBitmapFont for a FPS counter</span></li>
   <li class=MsoNormal><span lang=FR>Positional 3D sounds</span></li>
  </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>
- <ul type=circle>
+ <ul style='margin-top:0cm' 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>The TGLTilePlane object</span></li>
@@ -253,15 +349,21 @@ ul
 
 <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>
- <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>Interactive parameter changes display tree
       variations.</span></li>
  </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>
 
 </div>

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

@@ -72,8 +72,8 @@ type
   public
     mx, my: Integer;
     VerletWorld: TGLVerletWorld;
-    EdgeDetector: TEdgeDetector;
-    AirResistance: TVFAirResistance;
+    EdgeDetector: TGLEdgeDetector;
+    AirResistance: TGLAirResistanceVF;
   end;
 
 var
@@ -122,9 +122,7 @@ begin
   for i := 0 to BaseMesh.MeshObjects.Count - 1 do
   begin
     mo := BaseMesh.MeshObjects[i];
-
     FillChar(mo.Normals.List[0], SizeOf(TAffineVector) * mo.Normals.Count, 0);
-
     for j := 0 to mo.FaceGroups.Count - 1 do
     begin
       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 + 1], n);
           mo.Normals.TranslateItem(fg.VertexIndices.List[k + 2], n); // }
-
           Inc(k, 3);
         end;
       end;
     end;
     mo.Normals.Normalize;
   end;
-
   BaseMesh.StructureChanged;
 end;
 
 procedure TFormClothActor.FormCreate(Sender: TObject);
+var
+  FloorVC: TGLFloorVC;
 begin
   SetGLSceneMediaDir();
   Randomize;
@@ -182,39 +180,34 @@ begin
   VerletWorld.Iterations := 3;
 
   // 'Clothify' the cape and add it to the verlet world
-  EdgeDetector := TEdgeDetector.Create(Cape);
+  EdgeDetector := TGLEdgeDetector.Create(Cape);
   EdgeDetector.ProcessMesh;
   EdgeDetector.AddEdgesAsSticks(VerletWorld, 0.15);
   EdgeDetector.AddEdgesAsSolidEdges(VerletWorld);
   // EdgeDetector.AddOuterEdgesAsSolidEdges(VerletWorld);
 
   // 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));
-  end;
-
   // Load the skeleton colliders. Skeleton colliders define an
   // approximate collision boundary for actors and are controlled
   // 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
   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;
 
 procedure TFormClothActor.FormDestroy(Sender: TObject);
@@ -229,73 +222,67 @@ var
 begin
   // Step the verlet world (this is where the magic happens)
   VerletWorld.Progress(deltaTime, newTime);
-
   // Recalculate the cape's normals
   RecalcMeshNormals(Cape);
-
   // Cycle the floor texture to make it look like it's moving
   GLPlane1.YOffset := GLPlane1.YOffset - 0.25 * deltaTime;
   if GLPlane1.YOffset < 0 then
     GLPlane1.YOffset := GLPlane1.YOffset + 1;
-
   // Orbit the light (to show off the pretty shadow volumes)
   GLLightSource1.MoveObjectAround(GLActor1, 0, -deltaTime * 20);
   GLLightSource1.PointTo(GLActor1, YHMGVector);
 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
-    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
-    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;
 
+procedure TFormClothActor.OctreeRendererRender(Sender: TObject;
+  var rci: TGLRenderContextInfo);
 begin
   if cbShowOctree.Checked then
   begin

BIN
Demos/media/TRINITYrage.glsc


+ 4 - 4
Source/GLS.BaseClasses.pas

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

+ 2 - 2
Source/GLS.Blur.pas

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

+ 1 - 1
Source/GLS.BumpmapHDS.pas

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

+ 0 - 1
Source/GLS.Coordinates.pas

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

+ 7 - 7
Source/GLS.FileBMP.pas

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

+ 52 - 53
Source/GLS.Graphics.pas

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

+ 0 - 4
Source/GLS.Gui.pas

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

+ 0 - 1
Source/GLS.Objects.pas

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

+ 1 - 1
Source/GLS.ParticleFX.pas

@@ -2852,7 +2852,7 @@ var
   s: Integer;
   x, y, d, h2: Integer;
   ih2, f, fy: Single;
-  scanLine1, scanLine2: PPixel32Array;
+  scanLine1, scanLine2: PGLPixel32Array;
 begin
   s := (1 shl TexMapSize);
   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;
     is2, f, fy, pf, nBase, nAmp, df, dfg: Single;
     invGamma: Single;
-    scanLine: PPixel32Array;
+    scanLine: PGLPixel32Array;
     gotIntensityCorrection: Boolean;
   begin
     s2 := s shr 1;

+ 1 - 1
Source/GLS.ProcTextures.pas

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

+ 0 - 2
Source/GLS.ProjectedTextures.pas

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

+ 1 - 2
Source/GLS.ShadowHDS.pas

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

+ 39 - 117
Source/GLS.SpacePartition.pas

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

+ 320 - 354
Source/GLS.VerletClothify.pas

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

+ 83 - 83
Source/GLS.VerletHairClasses.pas

@@ -1,12 +1,11 @@
 //
 // The graphics rendering engine GLScene http://glscene.org
 //
-
 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
@@ -14,170 +13,171 @@ interface
 {$I GLScene.inc}
 
 uses
-  System.Classes, 
+  System.Classes,
   System.SysUtils,
-  GLS.VerletTypes, 
-  GLS.VectorTypes, 
-  GLS.VectorLists, 
+  GLS.VerletTypes,
+  GLS.VectorTypes,
+  GLS.VectorLists,
   GLS.VectorGeometry;
 
 type
-  TVHStiffness = (vhsFull, vhsSkip1Node, vhsSkip2Node, vhsSkip3Node,
+  TGLStiffnessVH = (vhsFull, vhsSkip1Node, vhsSkip2Node, vhsSkip3Node,
     vhsSkip4Node, vhsSkip5Node, vhsSkip6Node, vhsSkip7Node, vhsSkip8Node,
     vhsSkip9Node);
-  TVHStiffnessSet = set of TVHStiffness;
+  TGLStiffnessSetVH = set of TGLStiffnessVH;
 
   TGLVerletHair = class
   private
-    FNodeList: TVerletNodeList;
+    FNodeList: TGLVerletNodeList;
     FLinkCount: integer;
     FRootDepth: single;
     FVerletWorld: TGLVerletWorld;
     FHairLength: single;
     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;
-    procedure AddStickStiffness(const ANodeSkip : integer);
-    procedure SetStiffness(const Value: TVHStiffnessSet);
+    procedure AddStickStiffness(const ANodeSkip: integer);
+    procedure SetStiffness(const Value: TGLStiffnessSetVH);
   public
     procedure BuildHair(const AAnchorPosition, AHairDirection: TAffineVector);
     procedure BuildStiffness;
     procedure ClearStiffness;
     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;
-    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;
 
-//------------------------------------------------------------------
+// ------------------------------------------------------------------
 implementation
-//------------------------------------------------------------------
-
-{ TGLVerletHair }
+// ------------------------------------------------------------------
 
+//-----------------------------
+// TGLVerletHair
+//-----------------------------
 procedure TGLVerletHair.AddStickStiffness(const ANodeSkip: integer);
 var
-  i : integer;
+  i: integer;
 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;
 
-procedure TGLVerletHair.BuildHair(const AAnchorPosition, AHairDirection: TAffineVector);
+procedure TGLVerletHair.BuildHair(const AAnchorPosition, AHairDirection
+  : TAffineVector);
 var
-  i : integer;
-  Position : TAffineVector;
-  Node, PrevNode : TVerletNode;
-  Direction : TAffineVector;
+  i: integer;
+  Position: TAffineVector;
+  Node, PrevNode: TGLBaseNode;
+  Direction: TAffineVector;
 begin
   Clear;
-
   Direction := VectorNormalize(AHairDirection);
-
   // Fix the root of the hair
   Position := VectorAdd(AAnchorPosition, VectorScale(Direction, -FRootDepth));
   Node := VerletWorld.CreateOwnedNode(Position);
   NodeList.Add(Node);
   Node.NailedDown := true;
   PrevNode := Node;
-
   // Now add the links in the hair
-  for i := 0 to FLinkCount-1 do
+  for i := 0 to FLinkCount - 1 do
   begin
-    Position := VectorAdd(AAnchorPosition, VectorScale(Direction, HairLength * (i/LinkCount)));
-
+    Position := VectorAdd(AAnchorPosition, VectorScale(Direction,
+      HairLength * (i / LinkCount)));
     Node := VerletWorld.CreateOwnedNode(Position);
     NodeList.Add(Node);
-
     // first one is the anchor
-    if i=0 then
+    if i = 0 then
       Node.NailedDown := true
     else
       // Creates the hair link
       VerletWorld.CreateStick(PrevNode, Node);
-
     PrevNode := Node;
   end;
-
   // Now we must stiffen the hair with either sticks or springs
   BuildStiffness;
 end;
 
 procedure TGLVerletHair.BuildStiffness;
 var
-  i : integer;
+  i: integer;
 begin
   ClearStiffness;
-
   if vhsFull in FStiffness then
   begin
     for i := 1 to 100 do
       AddStickStiffness(i);
-      
     exit;
   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;
 
 procedure TGLVerletHair.Clear;
 var
-  i : integer;
+  i: integer;
 begin
   ClearStiffness;
-  for i := FNodeList.Count-1 downto 0 do
+  for i := FNodeList.Count - 1 downto 0 do
     FNodeList[i].Free;
-
   FNodeList.Clear;
   FStiffnessList.Clear;
 end;
 
 procedure TGLVerletHair.ClearStiffness;
 var
-  i : integer;
+  i: integer;
 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;
 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
   FVerletWorld := AVerletWorld;
   FRootDepth := ARootDepth;
   FLinkCount := ALinkCount;
   FHairLength := AHairLength;
 
-  FNodeList := TVerletNodeList.Create;
+  FNodeList := TGLVerletNodeList.Create;
   FStiffness := AStiffness;
   FStiffnessList := TList.Create;
 
@@ -192,25 +192,25 @@ begin
   inherited;
 end;
 
-function TGLVerletHair.GetAnchor: TVerletNode;
+function TGLVerletHair.GetAnchor: TGLBaseNode;
 begin
   result := NodeList[1];
 end;
 
 function TGLVerletHair.GetLinkLength: single;
 begin
-  if LinkCount>0 then
+  if LinkCount > 0 then
     result := HairLength / LinkCount
   else
     result := 0;
 end;
 
-function TGLVerletHair.GetRoot: TVerletNode;
+function TGLVerletHair.GetRoot: TGLBaseNode;
 begin
   result := NodeList[0];
 end;
 
-procedure TGLVerletHair.SetStiffness(const Value: TVHStiffnessSet);
+procedure TGLVerletHair.SetStiffness(const Value: TGLStiffnessSetVH);
 begin
   FStiffness := Value;
   BuildStiffness;

+ 73 - 75
Source/GLS.VerletSkeletonColliders.pas

@@ -1,7 +1,6 @@
 //
 // The graphics rendering engine GLScene http://glscene.org
 //
-
 unit GLS.VerletSkeletonColliders;
 
 (* Skeleton colliders for defining and controlling verlet constraints. *)
@@ -17,57 +16,54 @@ uses
   GLS.VectorTypes;
 
 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;
 
   // 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;
 
   // 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;
 
-(* 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
@@ -83,15 +79,15 @@ var
   i: Integer;
 begin
   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;
 
 // ------------------
-// ------------------ TSCVerletBase ------------------
+// ------------------ TGLVerletBase ------------------
 // ------------------
 
-procedure TSCVerletBase.WriteToFiler(writer: TVirtualWriter);
+procedure TGLVerletBase.WriteToFiler(writer: TVirtualWriter);
 begin
   inherited WriteToFiler(writer);
   with writer do
@@ -100,7 +96,7 @@ begin
   end;
 end;
 
-procedure TSCVerletBase.ReadFromFiler(reader: TVirtualReader);
+procedure TGLVerletBase.ReadFromFiler(reader: TVirtualReader);
 var
   archiveVersion: Integer;
 begin
@@ -113,24 +109,22 @@ begin
       RaiseFilerException(archiveVersion);
 end;
 
-procedure TSCVerletBase.AddToVerletWorld(VerletWorld: TGLVerletWorld);
+procedure TGLVerletBase.AddToVerletWorld(VerletWorld: TGLVerletWorld);
 begin
   AlignCollider;
 end;
 
-
 // ------------------
-// ------------------ TSCVerletSphere ------------------
+// ------------------ TGLVerletSphere ------------------
 // ------------------
-
-constructor TSCVerletSphere.Create;
+constructor TGLVerletSphere.Create;
 begin
   inherited;
   Radius := 0.5;
   AlignCollider;
 end;
 
-procedure TSCVerletSphere.WriteToFiler(writer: TVirtualWriter);
+procedure TGLVerletSphere.WriteToFiler(writer: TVirtualWriter);
 begin
   inherited WriteToFiler(writer);
   with writer do
@@ -140,7 +134,7 @@ begin
   end;
 end;
 
-procedure TSCVerletSphere.ReadFromFiler(reader: TVirtualReader);
+procedure TGLVerletSphere.ReadFromFiler(reader: TVirtualReader);
 var
   archiveVersion: Integer;
 begin
@@ -153,21 +147,21 @@ begin
     RaiseFilerException(archiveVersion);
 end;
 
-procedure TSCVerletSphere.AddToVerletWorld(VerletWorld: TGLVerletWorld);
+procedure TGLVerletSphere.AddToVerletWorld(VerletWorld: TGLVerletWorld);
 begin
   FVerletConstraint := TVCSphere.Create(VerletWorld);
   TVCSphere(FVerletConstraint).Radius := FRadius;
   inherited;
 end;
 
-procedure TSCVerletSphere.AlignCollider;
+procedure TGLVerletSphere.AlignCollider;
 begin
   inherited;
   if Assigned(FVerletConstraint) then
     TVCSphere(FVerletConstraint).Location := AffineVectorMake(GlobalMatrix.W);
 end;
 
-procedure TSCVerletSphere.SetRadius(const val: Single);
+procedure TGLVerletSphere.SetRadius(const val: Single);
 begin
   if val <> FRadius then
   begin
@@ -178,10 +172,9 @@ begin
 end;
 
 // ------------------
-// ------------------ TSCVerletCapsule ------------------
+// ------------------ TGLVerletCapsule ------------------
 // ------------------
-
-constructor TSCVerletCapsule.Create;
+constructor TGLVerletCapsule.Create;
 begin
   inherited;
   Radius := 0.5;
@@ -189,7 +182,7 @@ begin
   AlignCollider;
 end;
 
-procedure TSCVerletCapsule.WriteToFiler(writer : TVirtualWriter);
+procedure TGLVerletCapsule.WriteToFiler(writer: TVirtualWriter);
 begin
   inherited WriteToFiler(writer);
   with writer do
@@ -200,19 +193,23 @@ begin
   end;
 end;
 
-procedure TSCVerletCapsule.ReadFromFiler(reader : TVirtualReader);
+procedure TGLVerletCapsule.ReadFromFiler(reader: TVirtualReader);
 var
-  archiveVersion : integer;
+  archiveVersion: Integer;
 begin
   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;
 
-procedure TSCVerletCapsule.AddToVerletWorld(VerletWorld : TGLVerletWorld);
+procedure TGLVerletCapsule.AddToVerletWorld(VerletWorld: TGLVerletWorld);
 begin
   FVerletConstraint := TVCCapsule.Create(VerletWorld);
   TVCCapsule(FVerletConstraint).Radius := FRadius;
@@ -220,7 +217,7 @@ begin
   inherited;
 end;
 
-procedure TSCVerletCapsule.AlignCollider;
+procedure TGLVerletCapsule.AlignCollider;
 begin
   inherited;
   if Assigned(FVerletConstraint) then
@@ -230,7 +227,7 @@ begin
   end;
 end;
 
-procedure TSCVerletCapsule.SetRadius(const val : Single);
+procedure TGLVerletCapsule.SetRadius(const val: Single);
 begin
   if val <> FRadius then
   begin
@@ -240,7 +237,7 @@ begin
   end;
 end;
 
-procedure TSCVerletCapsule.SetLength(const val : Single);
+procedure TGLVerletCapsule.SetLength(const val: Single);
 begin
   if val <> FLength then
   begin
@@ -252,8 +249,9 @@ end;
 
 // ------------------------------------------------------------------
 initialization
+
 // ------------------------------------------------------------------
 
-  RegisterClasses([TSCVerletBase,TSCVerletSphere,TSCVerletCapsule]);
+RegisterClasses([TGLVerletBase, TGLVerletSphere, TGLVerletCapsule]);
 
 end.

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 234 - 214
Source/GLS.VerletTypes.pas


+ 1 - 1
Source/GLS.zBuffer.pas

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

+ 3 - 3
Source/Physics.ODEUtils.pas

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

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно