Browse Source

Included gxs.cyborgmanager

glscene 1 year ago
parent
commit
b4c38b26ae
45 changed files with 1463 additions and 1215 deletions
  1. 5 0
      Examples/Demos/bench/canvas/CanvasD.dproj
  2. 3 99
      Examples/Demox.groupproj
  3. 5 3
      Examples/Demox/Heightmap/Heightmap_c.cbproj
  4. 1 1
      Examples/Demox/Pathfinder/Pathfinder.dpr
  5. 14 16
      Examples/Demox/Sailboat/fdSailboat.fmx
  6. 1 1
      Packages/GXScene_GBE.dproj
  7. 6 4
      Packages/GXScene_RT.dpk
  8. 5 3
      Packages/GXScene_RT.dproj
  9. 3 7
      Source/GLS.Behaviours.pas
  10. 12 7
      Source/GLS.CUDA.Compiler.pas
  11. 2 2
      Source/GLS.CameraController.pas
  12. 1 3
      Source/GLS.ImageUtils.pas
  13. 15 13
      Source/GLS.PhysForces.pas
  14. 15 7
      Source/GLS.PhysInertias.pas
  15. 4 4
      Source/GLS.PhysJoints.pas
  16. 5 6
      Source/GLS.PhysManager.pas
  17. 1 1
      Source/GLS.ScriptBase.pas
  18. 4 5
      Source/GLS.SmartObjects.pas
  19. 781 0
      Source/GLScene.RedBlackTree.pas
  20. 3 3
      Sourcex/GXS.Canvas.pas
  21. 12 13
      Sourcex/GXS.CelShader.pas
  22. 9 12
      Sourcex/GXS.Collision.pas
  23. 5 7
      Sourcex/GXS.CompositeImage.pas
  24. 1 1
      Sourcex/GXS.Console.pas
  25. 118 0
      Sourcex/GXS.CyborgManager.pas
  26. 8 11
      Sourcex/GXS.DCE.pas
  27. 1 0
      Sourcex/GXS.DCEMisc.pas
  28. 2 2
      Sourcex/GXS.EllipseCollision.pas
  29. 1 3
      Sourcex/GXS.Material.pas
  30. 48 54
      Sourcex/GXS.Octree.pas
  31. 2 4
      Sourcex/GXS.OpenGLAdapter.pas
  32. 2 7
      Sourcex/GXS.PAKArchive.pas
  33. 1 3
      Sourcex/GXS.Particles.pas
  34. 1 3
      Sourcex/GXS.PictureRegisteredFormats.pas
  35. 1 3
      Sourcex/GXS.PolygonTesselation.pas
  36. 19 23
      Sourcex/GXS.ProxyObjects.pas
  37. 12 14
      Sourcex/GXS.ROAMPatch.pas
  38. 3 3
      Sourcex/GXS.Ragdoll.pas
  39. 6 8
      Sourcex/GXS.RandomHDS.pas
  40. 0 788
      Sourcex/GXS.RedBlackTree.pas
  41. 13 16
      Sourcex/GXS.SceneViewer.pas
  42. 1 3
      Sourcex/GXS.Screen.pas
  43. 5 7
      Sourcex/GXS.ScriptBase.pas
  44. 265 0
      Sourcex/GXS.SmartObjects.pas
  45. 41 45
      Sourcex/GXS.SoundManager.pas

+ 5 - 0
Examples/Demos/bench/canvas/CanvasD.dproj

@@ -9,6 +9,7 @@
         <FrameworkType>VCL</FrameworkType>
         <FrameworkType>VCL</FrameworkType>
         <ProjectVersion>20.1</ProjectVersion>
         <ProjectVersion>20.1</ProjectVersion>
         <Platform Condition="'$(Platform)'==''">Win32</Platform>
         <Platform Condition="'$(Platform)'==''">Win32</Platform>
+        <ProjectName Condition="'$(ProjectName)'==''">CanvasD</ProjectName>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
         <Base>true</Base>
         <Base>true</Base>
@@ -815,6 +816,9 @@
                     <Platform Name="Win64">
                     <Platform Name="Win64">
                         <Operation>1</Operation>
                         <Operation>1</Operation>
                     </Platform>
                     </Platform>
+                    <Platform Name="Win64x">
+                        <Operation>1</Operation>
+                    </Platform>
                 </DeployClass>
                 </DeployClass>
                 <DeployClass Name="ProjectiOSDeviceDebug">
                 <DeployClass Name="ProjectiOSDeviceDebug">
                     <Platform Name="iOSDevice32">
                     <Platform Name="iOSDevice32">
@@ -1108,6 +1112,7 @@
                 <ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="Win64x" Name="$(PROJECTNAME)"/>
             </Deployment>
             </Deployment>
         </BorlandProject>
         </BorlandProject>
         <ProjectFileVersion>12</ProjectFileVersion>
         <ProjectFileVersion>12</ProjectFileVersion>

+ 3 - 99
Examples/Demox.groupproj

@@ -9,45 +9,24 @@
         <Projects Include="Demox\Clouds\Clouds.dproj">
         <Projects Include="Demox\Clouds\Clouds.dproj">
             <Dependencies/>
             <Dependencies/>
         </Projects>
         </Projects>
-        <Projects Include="Demox\Clouds\Clouds_c.cbproj">
-            <Dependencies/>
-        </Projects>
         <Projects Include="Demox\Cube\Cube.dproj">
         <Projects Include="Demox\Cube\Cube.dproj">
             <Dependencies/>
             <Dependencies/>
         </Projects>
         </Projects>
-        <Projects Include="Demox\Cube\Cube_c.cbproj">
-            <Dependencies/>
-        </Projects>
         <Projects Include="Demox\Cubemap\Cubemap.dproj">
         <Projects Include="Demox\Cubemap\Cubemap.dproj">
             <Dependencies/>
             <Dependencies/>
         </Projects>
         </Projects>
-        <Projects Include="Demox\Cubemap\Cubemap_c.cbproj">
-            <Dependencies/>
-        </Projects>
         <Projects Include="Demox\CylinderExt\CylinderExt.dproj">
         <Projects Include="Demox\CylinderExt\CylinderExt.dproj">
             <Dependencies/>
             <Dependencies/>
         </Projects>
         </Projects>
-        <Projects Include="Demox\CylinderExt\CylinderExt_c.cbproj">
-            <Dependencies/>
-        </Projects>
         <Projects Include="Demox\Genoise\Genoise.dproj">
         <Projects Include="Demox\Genoise\Genoise.dproj">
             <Dependencies/>
             <Dependencies/>
         </Projects>
         </Projects>
-        <Projects Include="Demox\Genoise\Genoise_c.cbproj">
-            <Dependencies/>
-        </Projects>
         <Projects Include="Demox\Grass\Grass.dproj">
         <Projects Include="Demox\Grass\Grass.dproj">
             <Dependencies/>
             <Dependencies/>
         </Projects>
         </Projects>
-        <Projects Include="Demox\Grass\Grass_c.cbproj">
-            <Dependencies/>
-        </Projects>
         <Projects Include="Demox\Heightmap\Heightmap.dproj">
         <Projects Include="Demox\Heightmap\Heightmap.dproj">
             <Dependencies/>
             <Dependencies/>
         </Projects>
         </Projects>
-        <Projects Include="Demox\Heightmap\Heightmap_c.cbproj">
-            <Dependencies/>
-        </Projects>
         <Projects Include="Demox\Island\Island.dproj">
         <Projects Include="Demox\Island\Island.dproj">
             <Dependencies/>
             <Dependencies/>
         </Projects>
         </Projects>
@@ -75,9 +54,6 @@
         <Projects Include="Demox\Waves\Waves.dproj">
         <Projects Include="Demox\Waves\Waves.dproj">
             <Dependencies/>
             <Dependencies/>
         </Projects>
         </Projects>
-        <Projects Include="Demox\Waves\Waves_c.cbproj">
-            <Dependencies/>
-        </Projects>
     </ItemGroup>
     </ItemGroup>
     <ProjectExtensions>
     <ProjectExtensions>
         <Borland.Personality>Default.Personality.12</Borland.Personality>
         <Borland.Personality>Default.Personality.12</Borland.Personality>
@@ -104,15 +80,6 @@
     <Target Name="Clouds:Make">
     <Target Name="Clouds:Make">
         <MSBuild Projects="Demox\Clouds\Clouds.dproj" Targets="Make"/>
         <MSBuild Projects="Demox\Clouds\Clouds.dproj" Targets="Make"/>
     </Target>
     </Target>
-    <Target Name="Clouds_c">
-        <MSBuild Projects="Demox\Clouds\Clouds_c.cbproj"/>
-    </Target>
-    <Target Name="Clouds_c:Clean">
-        <MSBuild Projects="Demox\Clouds\Clouds_c.cbproj" Targets="Clean"/>
-    </Target>
-    <Target Name="Clouds_c:Make">
-        <MSBuild Projects="Demox\Clouds\Clouds_c.cbproj" Targets="Make"/>
-    </Target>
     <Target Name="Cube">
     <Target Name="Cube">
         <MSBuild Projects="Demox\Cube\Cube.dproj"/>
         <MSBuild Projects="Demox\Cube\Cube.dproj"/>
     </Target>
     </Target>
@@ -122,15 +89,6 @@
     <Target Name="Cube:Make">
     <Target Name="Cube:Make">
         <MSBuild Projects="Demox\Cube\Cube.dproj" Targets="Make"/>
         <MSBuild Projects="Demox\Cube\Cube.dproj" Targets="Make"/>
     </Target>
     </Target>
-    <Target Name="Cube_c">
-        <MSBuild Projects="Demox\Cube\Cube_c.cbproj"/>
-    </Target>
-    <Target Name="Cube_c:Clean">
-        <MSBuild Projects="Demox\Cube\Cube_c.cbproj" Targets="Clean"/>
-    </Target>
-    <Target Name="Cube_c:Make">
-        <MSBuild Projects="Demox\Cube\Cube_c.cbproj" Targets="Make"/>
-    </Target>
     <Target Name="Cubemap">
     <Target Name="Cubemap">
         <MSBuild Projects="Demox\Cubemap\Cubemap.dproj"/>
         <MSBuild Projects="Demox\Cubemap\Cubemap.dproj"/>
     </Target>
     </Target>
@@ -140,15 +98,6 @@
     <Target Name="Cubemap:Make">
     <Target Name="Cubemap:Make">
         <MSBuild Projects="Demox\Cubemap\Cubemap.dproj" Targets="Make"/>
         <MSBuild Projects="Demox\Cubemap\Cubemap.dproj" Targets="Make"/>
     </Target>
     </Target>
-    <Target Name="Cubemap_c">
-        <MSBuild Projects="Demox\Cubemap\Cubemap_c.cbproj"/>
-    </Target>
-    <Target Name="Cubemap_c:Clean">
-        <MSBuild Projects="Demox\Cubemap\Cubemap_c.cbproj" Targets="Clean"/>
-    </Target>
-    <Target Name="Cubemap_c:Make">
-        <MSBuild Projects="Demox\Cubemap\Cubemap_c.cbproj" Targets="Make"/>
-    </Target>
     <Target Name="CylinderExt">
     <Target Name="CylinderExt">
         <MSBuild Projects="Demox\CylinderExt\CylinderExt.dproj"/>
         <MSBuild Projects="Demox\CylinderExt\CylinderExt.dproj"/>
     </Target>
     </Target>
@@ -158,15 +107,6 @@
     <Target Name="CylinderExt:Make">
     <Target Name="CylinderExt:Make">
         <MSBuild Projects="Demox\CylinderExt\CylinderExt.dproj" Targets="Make"/>
         <MSBuild Projects="Demox\CylinderExt\CylinderExt.dproj" Targets="Make"/>
     </Target>
     </Target>
-    <Target Name="CylinderExt_c">
-        <MSBuild Projects="Demox\CylinderExt\CylinderExt_c.cbproj"/>
-    </Target>
-    <Target Name="CylinderExt_c:Clean">
-        <MSBuild Projects="Demox\CylinderExt\CylinderExt_c.cbproj" Targets="Clean"/>
-    </Target>
-    <Target Name="CylinderExt_c:Make">
-        <MSBuild Projects="Demox\CylinderExt\CylinderExt_c.cbproj" Targets="Make"/>
-    </Target>
     <Target Name="Genoise">
     <Target Name="Genoise">
         <MSBuild Projects="Demox\Genoise\Genoise.dproj"/>
         <MSBuild Projects="Demox\Genoise\Genoise.dproj"/>
     </Target>
     </Target>
@@ -176,15 +116,6 @@
     <Target Name="Genoise:Make">
     <Target Name="Genoise:Make">
         <MSBuild Projects="Demox\Genoise\Genoise.dproj" Targets="Make"/>
         <MSBuild Projects="Demox\Genoise\Genoise.dproj" Targets="Make"/>
     </Target>
     </Target>
-    <Target Name="Genoise_c">
-        <MSBuild Projects="Demox\Genoise\Genoise_c.cbproj"/>
-    </Target>
-    <Target Name="Genoise_c:Clean">
-        <MSBuild Projects="Demox\Genoise\Genoise_c.cbproj" Targets="Clean"/>
-    </Target>
-    <Target Name="Genoise_c:Make">
-        <MSBuild Projects="Demox\Genoise\Genoise_c.cbproj" Targets="Make"/>
-    </Target>
     <Target Name="Grass">
     <Target Name="Grass">
         <MSBuild Projects="Demox\Grass\Grass.dproj"/>
         <MSBuild Projects="Demox\Grass\Grass.dproj"/>
     </Target>
     </Target>
@@ -194,15 +125,6 @@
     <Target Name="Grass:Make">
     <Target Name="Grass:Make">
         <MSBuild Projects="Demox\Grass\Grass.dproj" Targets="Make"/>
         <MSBuild Projects="Demox\Grass\Grass.dproj" Targets="Make"/>
     </Target>
     </Target>
-    <Target Name="Grass_c">
-        <MSBuild Projects="Demox\Grass\Grass_c.cbproj"/>
-    </Target>
-    <Target Name="Grass_c:Clean">
-        <MSBuild Projects="Demox\Grass\Grass_c.cbproj" Targets="Clean"/>
-    </Target>
-    <Target Name="Grass_c:Make">
-        <MSBuild Projects="Demox\Grass\Grass_c.cbproj" Targets="Make"/>
-    </Target>
     <Target Name="Heightmap">
     <Target Name="Heightmap">
         <MSBuild Projects="Demox\Heightmap\Heightmap.dproj"/>
         <MSBuild Projects="Demox\Heightmap\Heightmap.dproj"/>
     </Target>
     </Target>
@@ -212,15 +134,6 @@
     <Target Name="Heightmap:Make">
     <Target Name="Heightmap:Make">
         <MSBuild Projects="Demox\Heightmap\Heightmap.dproj" Targets="Make"/>
         <MSBuild Projects="Demox\Heightmap\Heightmap.dproj" Targets="Make"/>
     </Target>
     </Target>
-    <Target Name="Heightmap_c">
-        <MSBuild Projects="Demox\Heightmap\Heightmap_c.cbproj"/>
-    </Target>
-    <Target Name="Heightmap_c:Clean">
-        <MSBuild Projects="Demox\Heightmap\Heightmap_c.cbproj" Targets="Clean"/>
-    </Target>
-    <Target Name="Heightmap_c:Make">
-        <MSBuild Projects="Demox\Heightmap\Heightmap_c.cbproj" Targets="Make"/>
-    </Target>
     <Target Name="Island">
     <Target Name="Island">
         <MSBuild Projects="Demox\Island\Island.dproj"/>
         <MSBuild Projects="Demox\Island\Island.dproj"/>
     </Target>
     </Target>
@@ -302,23 +215,14 @@
     <Target Name="Waves:Make">
     <Target Name="Waves:Make">
         <MSBuild Projects="Demox\Waves\Waves.dproj" Targets="Make"/>
         <MSBuild Projects="Demox\Waves\Waves.dproj" Targets="Make"/>
     </Target>
     </Target>
-    <Target Name="Waves_c">
-        <MSBuild Projects="Demox\Waves\Waves_c.cbproj"/>
-    </Target>
-    <Target Name="Waves_c:Clean">
-        <MSBuild Projects="Demox\Waves\Waves_c.cbproj" Targets="Clean"/>
-    </Target>
-    <Target Name="Waves_c:Make">
-        <MSBuild Projects="Demox\Waves\Waves_c.cbproj" Targets="Make"/>
-    </Target>
     <Target Name="Build">
     <Target Name="Build">
-        <CallTarget Targets="GXScene_GBE;Clouds;Clouds_c;Cube;Cube_c;Cubemap;Cubemap_c;CylinderExt;CylinderExt_c;Genoise;Genoise_c;Grass;Grass_c;Heightmap;Heightmap_c;Island;Joystickplayer;Multitextures;Pathfinder;Sailboat;SphereExt;Terrain;Viewports;Waves;Waves_c"/>
+        <CallTarget Targets="GXScene_GBE;Clouds;Cube;Cubemap;CylinderExt;Genoise;Grass;Heightmap;Island;Joystickplayer;Multitextures;Pathfinder;Sailboat;SphereExt;Terrain;Viewports;Waves"/>
     </Target>
     </Target>
     <Target Name="Clean">
     <Target Name="Clean">
-        <CallTarget Targets="GXScene_GBE:Clean;Clouds:Clean;Clouds_c:Clean;Cube:Clean;Cube_c:Clean;Cubemap:Clean;Cubemap_c:Clean;CylinderExt:Clean;CylinderExt_c:Clean;Genoise:Clean;Genoise_c:Clean;Grass:Clean;Grass_c:Clean;Heightmap:Clean;Heightmap_c:Clean;Island:Clean;Joystickplayer:Clean;Multitextures:Clean;Pathfinder:Clean;Sailboat:Clean;SphereExt:Clean;Terrain:Clean;Viewports:Clean;Waves:Clean;Waves_c:Clean"/>
+        <CallTarget Targets="GXScene_GBE:Clean;Clouds:Clean;Cube:Clean;Cubemap:Clean;CylinderExt:Clean;Genoise:Clean;Grass:Clean;Heightmap:Clean;Island:Clean;Joystickplayer:Clean;Multitextures:Clean;Pathfinder:Clean;Sailboat:Clean;SphereExt:Clean;Terrain:Clean;Viewports:Clean;Waves:Clean"/>
     </Target>
     </Target>
     <Target Name="Make">
     <Target Name="Make">
-        <CallTarget Targets="GXScene_GBE:Make;Clouds:Make;Clouds_c:Make;Cube:Make;Cube_c:Make;Cubemap:Make;Cubemap_c:Make;CylinderExt:Make;CylinderExt_c:Make;Genoise:Make;Genoise_c:Make;Grass:Make;Grass_c:Make;Heightmap:Make;Heightmap_c:Make;Island:Make;Joystickplayer:Make;Multitextures:Make;Pathfinder:Make;Sailboat:Make;SphereExt:Make;Terrain:Make;Viewports:Make;Waves:Make;Waves_c:Make"/>
+        <CallTarget Targets="GXScene_GBE:Make;Clouds:Make;Cube:Make;Cubemap:Make;CylinderExt:Make;Genoise:Make;Grass:Make;Heightmap:Make;Island:Make;Joystickplayer:Make;Multitextures:Make;Pathfinder:Make;Sailboat:Make;SphereExt:Make;Terrain:Make;Viewports:Make;Waves:Make"/>
     </Target>
     </Target>
     <Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
     <Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
 </Project>
 </Project>

+ 5 - 3
Examples/Demox/Heightmap/Heightmap_c.cbproj

@@ -6,10 +6,11 @@
         <MainSource>Heightmap_c.cpp</MainSource>
         <MainSource>Heightmap_c.cpp</MainSource>
         <Base>True</Base>
         <Base>True</Base>
         <Config Condition="'$(Config)'==''">Debug</Config>
         <Config Condition="'$(Config)'==''">Debug</Config>
-        <Platform Condition="'$(Platform)'==''">Win64x</Platform>
+        <Platform Condition="'$(Platform)'==''">Win32</Platform>
         <ProjectName Condition="'$(ProjectName)'==''">Heightmap_c</ProjectName>
         <ProjectName Condition="'$(ProjectName)'==''">Heightmap_c</ProjectName>
-        <TargetedPlatforms>1048576</TargetedPlatforms>
+        <TargetedPlatforms>1048577</TargetedPlatforms>
         <AppType>Application</AppType>
         <AppType>Application</AppType>
+        <CC_Suffix Condition="'$(CC_Suffix)'==''">c</CC_Suffix>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
         <Base>true</Base>
         <Base>true</Base>
@@ -161,6 +162,7 @@
         <IncludePath>..\..\include\$(Platform);$(IncludePath)</IncludePath>
         <IncludePath>..\..\include\$(Platform);$(IncludePath)</IncludePath>
         <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
         <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
         <VerInfo_Locale>1033</VerInfo_Locale>
         <VerInfo_Locale>1033</VerInfo_Locale>
+        <LinkPackageStatics>GXScene_GBE.lib</LinkPackageStatics>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
     <PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
         <AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
         <AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
@@ -1269,7 +1271,7 @@
                 <ProjectRoot Platform="Win64x" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win64x" Name="$(PROJECTNAME)"/>
             </Deployment>
             </Deployment>
             <Platforms>
             <Platforms>
-                <Platform value="Win32">False</Platform>
+                <Platform value="Win32">True</Platform>
                 <Platform value="Win64">False</Platform>
                 <Platform value="Win64">False</Platform>
                 <Platform value="Win64x">True</Platform>
                 <Platform value="Win64x">True</Platform>
             </Platforms>
             </Platforms>

+ 1 - 1
Examples/Demox/Pathfinder/Pathfinder.dpr

@@ -10,6 +10,6 @@ uses
 
 
 begin
 begin
   Application.Initialize;
   Application.Initialize;
-  Application.CreateForm(TfFormPathfinder, fFormPathfinder);
+  Application.CreateForm(TFormPathfinder, fFormPathfinder);
   Application.Run;
   Application.Run;
 end.
 end.

+ 14 - 16
Examples/Demox/Sailboat/fdSailboat.fmx

@@ -271704,7 +271704,6 @@ object FormSailboatDemo: TFormSailboatDemo
             Height = 0.400000005960464500
             Height = 0.400000005960464500
             Depth = 0.400000005960464500
             Depth = 0.400000005960464500
             Opacity = 0.500000000000000000
             Opacity = 0.500000000000000000
-            Visible = False
           end
           end
           object modelBoat: TModel3D
           object modelBoat: TModel3D
             Position.X = -0.439999997615814200
             Position.X = -0.439999997615814200
@@ -291023,14 +291022,14 @@ object FormSailboatDemo: TFormSailboatDemo
               MaterialSource = texJibSail
               MaterialSource = texJibSail
               ShowLines = False
               ShowLines = False
               UseTasks = True
               UseTasks = True
-              SailShape = shapeJib
+              SailShape = ShapeJib
               CamberRight = True
               CamberRight = True
               SailHeight = 3.000000000000000000
               SailHeight = 3.000000000000000000
-              chordTop = 0.200000002980232200
-              chordMid = 1.500000000000000000
-              chordBottom = 0.100000001490116100
+              ChordTop = 0.200000002980232200
+              ChordMid = 1.500000000000000000
+              ChordBottom = 0.100000001490116100
               HeightX = 0.600000023841857900
               HeightX = 0.600000023841857900
-              chordX = 1.799999952316284000
+              ChordX = 1.799999952316284000
               version = 3
               version = 3
               Quanternion = 
               Quanternion = 
                 '(-0.70710676908493,-3.09086196637054E-8,0.70710676908493,-3.0908' +
                 '(-0.70710676908493,-3.09086196637054E-8,0.70710676908493,-3.0908' +
@@ -291095,11 +291094,11 @@ object FormSailboatDemo: TFormSailboatDemo
               UseTasks = True
               UseTasks = True
               CamberRight = True
               CamberRight = True
               SailHeight = 4.500000000000000000
               SailHeight = 4.500000000000000000
-              chordTop = 0.349999994039535500
-              chordMid = 1.200000047683716000
-              chordBottom = 1.500000000000000000
+              ChordTop = 0.349999994039535500
+              ChordMid = 1.200000047683716000
+              ChordBottom = 1.500000000000000000
               HeightX = 1.000000000000000000
               HeightX = 1.000000000000000000
-              chordX = 3.500000000000000000
+              ChordX = 3.500000000000000000
               version = 2
               version = 2
               Quanternion = 
               Quanternion = 
                 '(0.707106709480286,5.96046412226769E-8,-0.707106709480286,5.9604' +
                 '(0.707106709480286,5.96046412226769E-8,-0.707106709480286,5.9604' +
@@ -291114,7 +291113,6 @@ object FormSailboatDemo: TFormSailboatDemo
               Width = 2.000000000000000000
               Width = 2.000000000000000000
               Height = 0.500000000000000000
               Height = 0.500000000000000000
               Depth = 0.200000002980232200
               Depth = 0.200000002980232200
-              Visible = False
               SubdivisionsHeight = 3
               SubdivisionsHeight = 3
               SubdivisionsWidth = 3
               SubdivisionsWidth = 3
               MaterialSource = materialFlag
               MaterialSource = materialFlag
@@ -291122,11 +291120,11 @@ object FormSailboatDemo: TFormSailboatDemo
               UseTasks = True
               UseTasks = True
               CamberRight = True
               CamberRight = True
               SailHeight = 0.500000000000000000
               SailHeight = 0.500000000000000000
-              chordTop = 0.100000001490116100
-              chordMid = 0.300000011920929000
-              chordBottom = 0.100000001490116100
+              ChordTop = 0.100000001490116100
+              ChordMid = 0.300000011920929000
+              ChordBottom = 0.100000001490116100
               HeightX = 0.250000000000000000
               HeightX = 0.250000000000000000
-              chordX = 0.500000000000000000
+              ChordX = 0.500000000000000000
               version = 5
               version = 5
               Quanternion = 
               Quanternion = 
                 '(0.000137370603624731,-0.579030752182007,-0.00528378272429109,-0' +
                 '(0.000137370603624731,-0.579030752182007,-0.00528378272429109,-0' +
@@ -302827,7 +302825,7 @@ object FormSailboatDemo: TFormSailboatDemo
           Size.Width = 51.000000000000000000
           Size.Width = 51.000000000000000000
           Size.Height = 32.000000000000000000
           Size.Height = 32.000000000000000000
           Size.PlatformDefault = False
           Size.PlatformDefault = False
-          TabOrder = 117
+          TabOrder = 115
         end
         end
         object cbShowDolphin: TSwitch
         object cbShowDolphin: TSwitch
           IsChecked = True
           IsChecked = True

+ 1 - 1
Packages/GXScene_GBE.dproj

@@ -6,7 +6,7 @@
         <FrameworkType>FMX</FrameworkType>
         <FrameworkType>FMX</FrameworkType>
         <Base>True</Base>
         <Base>True</Base>
         <Config Condition="'$(Config)'==''">Debug</Config>
         <Config Condition="'$(Config)'==''">Debug</Config>
-        <Platform Condition="'$(Platform)'==''">Win32</Platform>
+        <Platform Condition="'$(Platform)'==''">Win64x</Platform>
         <TargetedPlatforms>1048577</TargetedPlatforms>
         <TargetedPlatforms>1048577</TargetedPlatforms>
         <AppType>Package</AppType>
         <AppType>Package</AppType>
         <ProjectName Condition="'$(ProjectName)'==''">GXScene_GBE</ProjectName>
         <ProjectName Condition="'$(ProjectName)'==''">GXScene_GBE</ProjectName>

+ 6 - 4
Packages/GXScene_RT.dpk

@@ -164,14 +164,13 @@ contains
   GXS.ROAMPatch in '..\SourceX\GXS.ROAMPatch.pas',
   GXS.ROAMPatch in '..\SourceX\GXS.ROAMPatch.pas',
   GXS.Ragdoll in '..\SourceX\GXS.Ragdoll.pas',
   GXS.Ragdoll in '..\SourceX\GXS.Ragdoll.pas',
   GXS.RandomHDS in '..\SourceX\GXS.RandomHDS.pas',
   GXS.RandomHDS in '..\SourceX\GXS.RandomHDS.pas',
-  GXS.RedBlackTree in '..\SourceX\GXS.RedBlackTree.pas',
+  GLScene.RedBlackTree in '..\Source\GLScene.RedBlackTree.pas',
   GXS.RenderContextInfo in '..\SourceX\GXS.RenderContextInfo.pas',
   GXS.RenderContextInfo in '..\SourceX\GXS.RenderContextInfo.pas',
   GXS.Scene in '..\SourceX\GXS.Scene.pas',
   GXS.Scene in '..\SourceX\GXS.Scene.pas',
   GXS.WinContext in '..\SourceX\GXS.WinContext.pas',
   GXS.WinContext in '..\SourceX\GXS.WinContext.pas',
   GXS.SceneViewer in '..\SourceX\GXS.SceneViewer.pas',
   GXS.SceneViewer in '..\SourceX\GXS.SceneViewer.pas',
   GXS.Screen in '..\SourceX\GXS.Screen.pas',
   GXS.Screen in '..\SourceX\GXS.Screen.pas',
   GXS.ScreenSaver in '..\SourceX\GXS.ScreenSaver.pas',
   GXS.ScreenSaver in '..\SourceX\GXS.ScreenSaver.pas',
-  GXS.ScriptBase in '..\SourceX\GXS.ScriptBase.pas',
   GXS.Selection in '..\SourceX\GXS.Selection.pas',
   GXS.Selection in '..\SourceX\GXS.Selection.pas',
   GXS.ShadowHDS in '..\SourceX\GXS.ShadowHDS.pas',
   GXS.ShadowHDS in '..\SourceX\GXS.ShadowHDS.pas',
   GXS.ShadowPlane in '..\SourceX\GXS.ShadowPlane.pas',
   GXS.ShadowPlane in '..\SourceX\GXS.ShadowPlane.pas',
@@ -180,7 +179,7 @@ contains
   GXS.SimpleNavigation in '..\SourceX\GXS.SimpleNavigation.pas',
   GXS.SimpleNavigation in '..\SourceX\GXS.SimpleNavigation.pas',
   GXS.Skydome in '..\SourceX\GXS.Skydome.pas',
   GXS.Skydome in '..\SourceX\GXS.Skydome.pas',
   GXS.SmoothNavigator in '..\SourceX\GXS.SmoothNavigator.pas',
   GXS.SmoothNavigator in '..\SourceX\GXS.SmoothNavigator.pas',
-  GXS.Sound in '..\SourceX\GXS.Sound.pas',
+  GXS.SoundManager in '..\Sourcex\GXS.SoundManager.pas',
   GXS.SoundFileObjects in '..\SourceX\GXS.SoundFileObjects.pas',
   GXS.SoundFileObjects in '..\SourceX\GXS.SoundFileObjects.pas',
   GXS.SpaceText in '..\SourceX\GXS.SpaceText.pas',
   GXS.SpaceText in '..\SourceX\GXS.SpaceText.pas',
   GXS.SpatialPartitioning in '..\SourceX\GXS.SpatialPartitioning.pas',
   GXS.SpatialPartitioning in '..\SourceX\GXS.SpatialPartitioning.pas',
@@ -270,6 +269,9 @@ contains
   GLScene.Keyboard in '..\Source\GLScene.Keyboard.pas',
   GLScene.Keyboard in '..\Source\GLScene.Keyboard.pas',
   GLScene.Polynomials in '..\Source\GLScene.Polynomials.pas',
   GLScene.Polynomials in '..\Source\GLScene.Polynomials.pas',
   GLScene.Color in '..\Source\GLScene.Color.pas',
   GLScene.Color in '..\Source\GLScene.Color.pas',
-  GLScene.PipelineTransform in '..\Source\GLScene.PipelineTransform.pas';
+  GLScene.PipelineTransform in '..\Source\GLScene.PipelineTransform.pas',
+  GXS.ScriptBase in '..\Sourcex\GXS.ScriptBase.pas',
+  GXS.SmartObjects in '..\Sourcex\GXS.SmartObjects.pas',
+  GXS.CyborgManager in '..\Sourcex\GXS.CyborgManager.pas';
 
 
 end.
 end.

+ 5 - 3
Packages/GXScene_RT.dproj

@@ -313,14 +313,13 @@
         <DCCReference Include="..\SourceX\GXS.ROAMPatch.pas"/>
         <DCCReference Include="..\SourceX\GXS.ROAMPatch.pas"/>
         <DCCReference Include="..\SourceX\GXS.Ragdoll.pas"/>
         <DCCReference Include="..\SourceX\GXS.Ragdoll.pas"/>
         <DCCReference Include="..\SourceX\GXS.RandomHDS.pas"/>
         <DCCReference Include="..\SourceX\GXS.RandomHDS.pas"/>
-        <DCCReference Include="..\SourceX\GXS.RedBlackTree.pas"/>
+        <DCCReference Include="..\Source\GLScene.RedBlackTree.pas"/>
         <DCCReference Include="..\SourceX\GXS.RenderContextInfo.pas"/>
         <DCCReference Include="..\SourceX\GXS.RenderContextInfo.pas"/>
         <DCCReference Include="..\SourceX\GXS.Scene.pas"/>
         <DCCReference Include="..\SourceX\GXS.Scene.pas"/>
         <DCCReference Include="..\SourceX\GXS.WinContext.pas"/>
         <DCCReference Include="..\SourceX\GXS.WinContext.pas"/>
         <DCCReference Include="..\SourceX\GXS.SceneViewer.pas"/>
         <DCCReference Include="..\SourceX\GXS.SceneViewer.pas"/>
         <DCCReference Include="..\SourceX\GXS.Screen.pas"/>
         <DCCReference Include="..\SourceX\GXS.Screen.pas"/>
         <DCCReference Include="..\SourceX\GXS.ScreenSaver.pas"/>
         <DCCReference Include="..\SourceX\GXS.ScreenSaver.pas"/>
-        <DCCReference Include="..\SourceX\GXS.ScriptBase.pas"/>
         <DCCReference Include="..\SourceX\GXS.Selection.pas"/>
         <DCCReference Include="..\SourceX\GXS.Selection.pas"/>
         <DCCReference Include="..\SourceX\GXS.ShadowHDS.pas"/>
         <DCCReference Include="..\SourceX\GXS.ShadowHDS.pas"/>
         <DCCReference Include="..\SourceX\GXS.ShadowPlane.pas"/>
         <DCCReference Include="..\SourceX\GXS.ShadowPlane.pas"/>
@@ -329,7 +328,7 @@
         <DCCReference Include="..\SourceX\GXS.SimpleNavigation.pas"/>
         <DCCReference Include="..\SourceX\GXS.SimpleNavigation.pas"/>
         <DCCReference Include="..\SourceX\GXS.Skydome.pas"/>
         <DCCReference Include="..\SourceX\GXS.Skydome.pas"/>
         <DCCReference Include="..\SourceX\GXS.SmoothNavigator.pas"/>
         <DCCReference Include="..\SourceX\GXS.SmoothNavigator.pas"/>
-        <DCCReference Include="..\SourceX\GXS.Sound.pas"/>
+        <DCCReference Include="..\Sourcex\GXS.SoundManager.pas"/>
         <DCCReference Include="..\SourceX\GXS.SoundFileObjects.pas"/>
         <DCCReference Include="..\SourceX\GXS.SoundFileObjects.pas"/>
         <DCCReference Include="..\SourceX\GXS.SpaceText.pas"/>
         <DCCReference Include="..\SourceX\GXS.SpaceText.pas"/>
         <DCCReference Include="..\SourceX\GXS.SpatialPartitioning.pas"/>
         <DCCReference Include="..\SourceX\GXS.SpatialPartitioning.pas"/>
@@ -420,6 +419,9 @@
         <DCCReference Include="..\Source\GLScene.Polynomials.pas"/>
         <DCCReference Include="..\Source\GLScene.Polynomials.pas"/>
         <DCCReference Include="..\Source\GLScene.Color.pas"/>
         <DCCReference Include="..\Source\GLScene.Color.pas"/>
         <DCCReference Include="..\Source\GLScene.PipelineTransform.pas"/>
         <DCCReference Include="..\Source\GLScene.PipelineTransform.pas"/>
+        <DCCReference Include="..\Sourcex\GXS.ScriptBase.pas"/>
+        <DCCReference Include="..\Sourcex\GXS.SmartObjects.pas"/>
+        <DCCReference Include="..\Sourcex\GXS.CyborgManager.pas"/>
         <None Include="..\Sourcex\GXS.Scene.inc"/>
         <None Include="..\Sourcex\GXS.Scene.inc"/>
         <None Include="..\Source\GLScene.Defines.inc"/>
         <None Include="..\Source\GLScene.Defines.inc"/>
         <BuildConfiguration Include="Base">
         <BuildConfiguration Include="Base">

+ 3 - 7
Source/GLS.Behaviours.pas

@@ -156,9 +156,7 @@ function GetOrCreateInertia(obj: TGLBaseSceneObject): TGLBInertia; overload;
 function GetOrCreateAcceleration(behaviours: TGLBehaviours): TGLBAcceleration; overload;
 function GetOrCreateAcceleration(behaviours: TGLBehaviours): TGLBAcceleration; overload;
 function GetOrCreateAcceleration(obj: TGLBaseSceneObject): TGLBAcceleration; overload;
 function GetOrCreateAcceleration(obj: TGLBaseSceneObject): TGLBAcceleration; overload;
 
 
-// ------------------------------------------------------------------
-implementation
-// ------------------------------------------------------------------
+implementation // -----------------------------------------------------------
 
 
 function GetInertia(const AGLSceneObject: TGLBaseSceneObject): TGLBInertia;
 function GetInertia(const AGLSceneObject: TGLBaseSceneObject): TGLBInertia;
 var
 var
@@ -602,15 +600,13 @@ begin
   end;
   end;
 end;
 end;
 
 
-// ------------------------------------------------------------------
-initialization
-// ------------------------------------------------------------------
+initialization // ------------------------------------------------------------
 
 
 // class registrations
 // class registrations
   RegisterXCollectionItemClass(TGLBInertia);
   RegisterXCollectionItemClass(TGLBInertia);
   RegisterXCollectionItemClass(TGLBAcceleration);
   RegisterXCollectionItemClass(TGLBAcceleration);
 
 
-finalization
+finalization // --------------------------------------------------------------
 
 
   UnregisterXCollectionItemClass(TGLBInertia);
   UnregisterXCollectionItemClass(TGLBInertia);
   UnregisterXCollectionItemClass(TGLBAcceleration);
   UnregisterXCollectionItemClass(TGLBAcceleration);

+ 12 - 7
Source/GLS.CUDA.Compiler.pas

@@ -21,7 +21,7 @@ uses
   System.Classes,
   System.Classes,
 
 
   Vcl.Forms,
   Vcl.Forms,
-  VCL.Dialogs,
+ // VCL.Dialogs,
 
 
   GLS.ApplicationFileIO,
   GLS.ApplicationFileIO,
 
 
@@ -210,7 +210,8 @@ begin
   if not FileExists(FSourceCodeFile) then
   if not FileExists(FSourceCodeFile) then
   begin
   begin
     if csDesigning in ComponentState then
     if csDesigning in ComponentState then
-      MessageDlg('Source File Not Found', TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0)
+      // MessageDlg('Source File Not Found', TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0)
+      Write('Source File Not Found')
     else
     else
      {$IFDEF USE_LOGGING}
      {$IFDEF USE_LOGGING}
        LogError('Source File Not Found');
        LogError('Source File Not Found');
@@ -333,7 +334,8 @@ begin
       else
       else
       begin
       begin
         if csDesigning in ComponentState then
         if csDesigning in ComponentState then
-          MessageDlg('Fail Run NVCC', TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0)
+          // MessageDlg('Fail Run NVCC', TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0)
+          Write('Fail Run NVCC')
         else
         else
          {$IFDEF USE_LOGGING}
          {$IFDEF USE_LOGGING}
             LogError('Fail Run NVCC');
             LogError('Fail Run NVCC');
@@ -353,7 +355,8 @@ begin
         FConsoleContent := string(StrPas(Buffer));
         FConsoleContent := string(StrPas(Buffer));
         msg := Format('Success Compilation', [FConsoleContent]);
         msg := Format('Success Compilation', [FConsoleContent]);
         if csDesigning in ComponentState then
         if csDesigning in ComponentState then
-          MessageDlg(msg, TMsgDlgType.mtInformation, [TMsgDlgBtn.mbOK], 0)
+          // MessageDlg(msg, TMsgDlgType.mtInformation, [TMsgDlgBtn.mbOK], 0)
+          Write(msg)
         else
         else
          {$IFDEF USE_LOGGING}
          {$IFDEF USE_LOGGING}
            LogInfo(msg);
            LogInfo(msg);
@@ -363,7 +366,8 @@ begin
       begin
       begin
         msg := Format('Fail Compilation', [StrPas(Buffer)]);
         msg := Format('Fail Compilation', [StrPas(Buffer)]);
         if csDesigning in ComponentState then
         if csDesigning in ComponentState then
-          MessageDlg(msg, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0)
+          //MessageDlg(msg, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0)
+          Write(msg)
         else
         else
           {$IFDEF USE_LOGGING}
           {$IFDEF USE_LOGGING}
             LogError(msg);
             LogError(msg);
@@ -378,7 +382,8 @@ begin
     else
     else
     begin
     begin
       if csDesigning in ComponentState then
       if csDesigning in ComponentState then
-        MessageDlg('Fail Create Pipe', TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0)
+        //MessageDlg('Fail Create Pipe', TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0)
+        Write(msg)
       else
       else
        {$IFDEF USE_LOGGING}
        {$IFDEF USE_LOGGING}
         GLSLogger.LogError(strFailCreatePipe);
         GLSLogger.LogError(strFailCreatePipe);
@@ -420,7 +425,7 @@ procedure TGLCUDACompiler.setOutputCodeType(const Value
   : TGLCUDACompilerOutput);
   : TGLCUDACompilerOutput);
 begin
 begin
   if Value = codeUndefined then
   if Value = codeUndefined then
-    exit;
+    Exit;
   FOutputCodeType := Value;
   FOutputCodeType := Value;
 end;
 end;
 
 

+ 2 - 2
Source/GLS.CameraController.pas

@@ -20,10 +20,10 @@ uses
 
 
   GLScene.VectorTypes,
   GLScene.VectorTypes,
   GLScene.VectorGeometry,
   GLScene.VectorGeometry,
-
-  GLS.Scene,
   GLScene.Coordinates,
   GLScene.Coordinates,
   GLScene.PersistentClasses,
   GLScene.PersistentClasses,
+
+  GLS.Scene,
   GLS.SmoothNavigator;
   GLS.SmoothNavigator;
 
 
 type
 type

+ 1 - 3
Source/GLS.ImageUtils.pas

@@ -29,6 +29,7 @@ uses
   Vcl.Dialogs,
   Vcl.Dialogs,
   Vcl.ExtDlgs,
   Vcl.ExtDlgs,
   Vcl.Graphics,
   Vcl.Graphics,
+
   GLScene.OpenGLTokens,
   GLScene.OpenGLTokens,
   GLScene.Strings,
   GLScene.Strings,
   GLScene.VectorGeometry,
   GLScene.VectorGeometry,
@@ -39,7 +40,6 @@ var
   vImageScaleFilterWidth: Integer = 5; // Relative sample radius for filtering
   vImageScaleFilterWidth: Integer = 5; // Relative sample radius for filtering
 
 
 type
 type
-
   TIntermediateFormat = record
   TIntermediateFormat = record
     R, G, B, A: Single;
     R, G, B, A: Single;
   end;
   end;
@@ -92,7 +92,6 @@ procedure AlphaGammaBrightCorrection(const ASrc: Pointer;
   AColorFormat: Cardinal; ADataType: Cardinal; ASrcWidth, ASrcHeight: Integer;
   AColorFormat: Cardinal; ADataType: Cardinal; ASrcWidth, ASrcHeight: Integer;
   anAlphaProc: TImageAlphaProc; ABrightness: Single; AGamma: Single);
   anAlphaProc: TImageAlphaProc; ABrightness: Single; AGamma: Single);
 
 
-
 // Converts a string into color
 // Converts a string into color
 function StringToColorAdvancedSafe(const Str: string;
 function StringToColorAdvancedSafe(const Str: string;
   const Default: TColor): TColor;
   const Default: TColor): TColor;
@@ -149,7 +148,6 @@ type
     NumColors: Integer; // Number of entries in the device's color table.
     NumColors: Integer; // Number of entries in the device's color table.
   end;
   end;
 
 
-
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 
 
 function GLOKMessageBox(const Text, Caption: string): Integer;
 function GLOKMessageBox(const Text, Caption: string): Integer;

+ 15 - 13
Source/GLS.PhysForces.pas

@@ -7,7 +7,6 @@ interface
 
 
 uses
 uses
   System.Classes,
   System.Classes,
-  Vcl.Dialogs,
 
 
   GLScene.VectorTypes,
   GLScene.VectorTypes,
   GLScene.XCollection,
   GLScene.XCollection,
@@ -139,18 +138,18 @@ end;
 
 
 procedure TGLForce.SetObject1(const val: TGLBaseSceneObject);
 procedure TGLForce.SetObject1(const val: TGLBaseSceneObject);
 begin
 begin
-  // if val.Behaviours.IndexOfClass(TGLBaseInertia) >=0 then
-  fObject1 := val
-  // else
-  // messagedlg('Object1 does not have an inertia behaviour',mtWarning,[mbOk],0);
+  if val.Behaviours.IndexOfClass(TGLBaseInertia) >=0 then
+    fObject1 := val
+  else
+    Write('Object1 does not have an inertia behaviour');
 end;
 end;
 
 
 procedure TGLForce.SetObject2(const val: TGLBaseSceneObject);
 procedure TGLForce.SetObject2(const val: TGLBaseSceneObject);
 begin
 begin
-  // if val.Behaviours.IndexOfClass(TGLBaseInertia) >=0 then
-  fObject2 := val
-  // else
-  // messagedlg('Object2 does not have an inertia behaviour',mtWarning,[mbOk],0);
+  if val.Behaviours.IndexOfClass(TGLBaseInertia) >=0 then
+    fObject2 := val
+  else
+   Write('Object2 does not have an inertia behaviour');
 end;
 end;
 
 
 procedure TGLForce.SetPosition1(const val: TgCoordinates);
 procedure TGLForce.SetPosition1(const val: TgCoordinates);
@@ -204,7 +203,7 @@ end;
 procedure TGLForce.WriteToFiler(writer: TWriter);
 procedure TGLForce.WriteToFiler(writer: TWriter);
 begin
 begin
   inherited WriteToFiler(writer);
   inherited WriteToFiler(writer);
-  // messagedlg('Writing to filer'+GetNamePath,mtInformation,[mbOk],0);
+  // Write('Writing to filer'+GetNamePath);
   with writer do
   with writer do
   begin
   begin
     fposition1.WriteToFiler(writer);
     fposition1.WriteToFiler(writer);
@@ -223,7 +222,7 @@ end;
 
 
 procedure TGLForce.ReadFromFiler(reader: TReader);
 procedure TGLForce.ReadFromFiler(reader: TReader);
 begin
 begin
-  // messagedlg('Reading from filer'+GetNamePath,mtInformation,[mbOk],0);
+  // Read('Reading from filer'+GetNamePath);
   inherited ReadFromFiler(reader);
   inherited ReadFromFiler(reader);
   with reader do
   with reader do
   begin
   begin
@@ -240,8 +239,11 @@ end;
 procedure TGLForce.SetName(const val: String);
 procedure TGLForce.SetName(const val: String);
 begin
 begin
   inherited SetName(val);
   inherited SetName(val);
-  // if Assigned(vGLBehaviourNameChangeEvent) then
-  // vGLBehaviourNameChangeEvent(Self);
+  (*
+  if Assigned(vGLBehaviourNameChangeEvent)
+  then
+   vGLBehaviourNameChangeEvent(Self);
+  *)
 end;
 end;
 
 
 function TGLForce.CalculateForce(): TAffineVector;
 function TGLForce.CalculateForce(): TAffineVector;

+ 15 - 7
Source/GLS.PhysInertias.pas

@@ -8,7 +8,6 @@ interface
 uses
 uses
   System.SysUtils,
   System.SysUtils,
   System.Classes,
   System.Classes,
-  Vcl.Dialogs,
 
 
   GLScene.PersistentClasses,
   GLScene.PersistentClasses,
   GLScene.XCollection,
   GLScene.XCollection,
@@ -379,7 +378,10 @@ begin
   // F = -Normalised(V)*( Constant + (Linear)*(V) + (Quadtratic)*(V)*(V) )
   // F = -Normalised(V)*( Constant + (Linear)*(V) + (Quadtratic)*(V)*(V) )
   dampingForce := VectorScale(VectorNormalize(velocity),
   dampingForce := VectorScale(VectorNormalize(velocity),
     -(damping.Constant + damping.Linear * v + damping.Quadratic * v * v));
     -(damping.Constant + damping.Linear * v + damping.Quadratic * v * v));
-  // dampingForce:=VectorScale(VectorNormalize(velocity),-(Damping.Constant+Damping.Linear*v+Damping.Quadratic*v*v));
+  (*
+    dampingForce:=VectorScale(VectorNormalize(velocity),
+    -(Damping.Constant+Damping.Linear*v+Damping.Quadratic*v*v));
+  *)
   ApplyForce(dampingForce);
   ApplyForce(dampingForce);
 end;
 end;
 
 
@@ -779,12 +781,17 @@ begin
   fBodyInverseInertiaTensor := fBodyInertiaTensor;
   fBodyInverseInertiaTensor := fBodyInertiaTensor;
 
 
   InvertMatrix(fBodyInverseInertiaTensor);
   InvertMatrix(fBodyInverseInertiaTensor);
-  // Messagedlg('setting BodyIit: '+Format('%f,%f,%f,%f,%f,%f,%f,%f,%f',[fBodyInverseInertiaTensor[0][0],fBodyInverseInertiaTensor[0][1],fBodyInverseInertiaTensor[0][2],fBodyInverseInertiaTensor[1][0],fBodyInverseInertiaTensor[1][1],fBodyInverseInertiaTensor[1][2],fBodyInverseInertiaTensor[2][0],fBodyInverseInertiaTensor[2][1],fBodyInverseInertiaTensor[2][2]]),mtinformation,[mbok],0);
-
+  // Write
+  (*
+    Messagedlg('setting BodyIit: '+ Format('%f,%f,%f,%f,%f,%f,%f,%f,%f',
+    [fBodyInverseInertiaTensor[0][0],fBodyInverseInertiaTensor[0][1],fBodyInverseInertiaTensor[0][2],
+     fBodyInverseInertiaTensor[1][0],fBodyInverseInertiaTensor[1][1],fBodyInverseInertiaTensor[1][2],
+     fBodyInverseInertiaTensor[2][0],fBodyInverseInertiaTensor[2][1],
+     fBodyInverseInertiaTensor[2][2]]),mtinformation,[mbok],0);
+  *)
   AngularOrientation := IdentityQuaternion;
   AngularOrientation := IdentityQuaternion;
   AngularMomentum := VectorTransform(RotationSpeed.AsAffineVector,
   AngularMomentum := VectorTransform(RotationSpeed.AsAffineVector,
     fBodyInertiaTensor);
     fBodyInertiaTensor);
-
 end;
 end;
 
 
 procedure TGLRigidBodyInertia.CalcAuxiliary();
 procedure TGLRigidBodyInertia.CalcAuxiliary();
@@ -820,7 +827,6 @@ begin
   OwnerBaseSceneObject.position.y := LinearPosition.Y;
   OwnerBaseSceneObject.position.y := LinearPosition.Y;
   OwnerBaseSceneObject.position.z := LinearPosition.Z;
   OwnerBaseSceneObject.position.z := LinearPosition.Z;
   OwnerBaseSceneObject.EndUpdate;
   OwnerBaseSceneObject.EndUpdate;
-
 end;
 end;
 
 
 procedure TGLRigidBodyInertia.StateToArray(var StateArray: TStateArray;
 procedure TGLRigidBodyInertia.StateToArray(var StateArray: TStateArray;
@@ -910,6 +916,8 @@ begin
   // SetDESolver(ssEuler);
   // SetDESolver(ssEuler);
 end;
 end;
 
 
+//---------------------------------------------------------------------------
+
 destructor TGLRigidBodyInertia.Destroy;
 destructor TGLRigidBodyInertia.Destroy;
 begin
 begin
   // FLinearDamping.Free;
   // FLinearDamping.Free;
@@ -989,7 +997,7 @@ procedure TGLRigidBodyInertia.DoProgress(const progressTime : TProgressTimes);
   UnDampedAngularMomentum,DampedAngularMomentum:Real;
   UnDampedAngularMomentum,DampedAngularMomentum:Real;
   i:integer;
   i:integer;
   begin
   begin
-  //    messagedlg('Calculating next state...',mtinformation,[mbOk],0);
+  // Write('Calculating next state...');
 
 
   with OwnerBaseSceneObject do
   with OwnerBaseSceneObject do
   with progressTime do
   with progressTime do

+ 4 - 4
Source/GLS.PhysJoints.pas

@@ -11,8 +11,8 @@ unit GLS.PhysJoints;
 interface
 interface
 
 
 uses
 uses
-  GLScene.VectorTypes,
   GLS.Scene,
   GLS.Scene,
+  GLScene.VectorTypes,
   GLScene.VectorGeometry;
   GLScene.VectorGeometry;
 
 
 type
 type
@@ -207,9 +207,7 @@ type
   TGLBallAndSocketJoint = class(TGLJoint)
   TGLBallAndSocketJoint = class(TGLJoint)
   end;
   end;
 
 
-//======================================================================
-implementation
-//======================================================================
+implementation //--------------------------------------------------------------
 
 
 constructor TGLLink.Create(LinkLength, TwistAngle, LinkAngle,
 constructor TGLLink.Create(LinkLength, TwistAngle, LinkAngle,
   LinkDistance: Real);
   LinkDistance: Real);
@@ -260,4 +258,6 @@ begin
   inherited Create(Length, 0, Angle, 0);
   inherited Create(Length, 0, Angle, 0);
 end;
 end;
 
 
+//---------------------------------------------------------------------------
+
 end.
 end.

+ 5 - 6
Source/GLS.PhysManager.pas

@@ -10,7 +10,6 @@ interface
 uses
 uses
   System.Classes,
   System.Classes,
   System.SysUtils,
   System.SysUtils,
-  Vcl.Dialogs,
 
 
   GLScene.XCollection,
   GLScene.XCollection,
   GLScene.VectorGeometry,
   GLScene.VectorGeometry,
@@ -31,7 +30,7 @@ type
     RungeKutta2, ***RungeKutta4***, RungKutta4Adaptive
     RungeKutta2, ***RungeKutta4***, RungKutta4Adaptive
     State Variables:  Position,  Velocity
     State Variables:  Position,  Velocity
 
 
-    Verlet 
+    Verlet
     State Variables:  Position, Old Position
     State Variables:  Position, Old Position
   *)
   *)
 
 
@@ -265,7 +264,7 @@ procedure TGLPhysManager.WriteForces(stream: TStream);
 var
 var
   writer: TWriter;
   writer: TWriter;
 begin
 begin
-  // messagedlg('Writing forces',mtInformation,[mbOk],0);
+  // Writing forces
   writer := TWriter.Create(stream, 16384);
   writer := TWriter.Create(stream, 16384);
   try
   try
     Forces.WriteToFiler(writer);
     Forces.WriteToFiler(writer);
@@ -447,7 +446,7 @@ var
   // UnDampedMomentum,DampedMomentum:Real;
   // UnDampedMomentum,DampedMomentum:Real;
 begin
 begin
 {$IFDEF DEBUG}
 {$IFDEF DEBUG}
-  messagedlg('Euler integration', mtinformation, [mbok], 0);
+  Write('Euler integration');
 {$ENDIF}
 {$ENDIF}
   for i := 0 to Owner.fInertias.Count - 1 do
   for i := 0 to Owner.fInertias.Count - 1 do
   begin
   begin
@@ -695,7 +694,7 @@ begin
       FManager.DeRegisterInertia(Self);
       FManager.DeRegisterInertia(Self);
     if Assigned(val) then
     if Assigned(val) then
       val.RegisterInertia(Self);
       val.RegisterInertia(Self);
-    // messagedlg(val.GetNamePath,mtinformation,[mbok],0);
+    // Write(val.GetNamePath);
   end;
   end;
 end;
 end;
 
 
@@ -715,7 +714,7 @@ end;
 
 
 procedure TGLBaseInertia.WriteToFiler(writer: TWriter);
 procedure TGLBaseInertia.WriteToFiler(writer: TWriter);
 begin
 begin
-  inherited; // Dan Bartlett
+  inherited;
   with writer do
   with writer do
   begin
   begin
     WriteInteger(0); // Archive Version 0
     WriteInteger(0); // Archive Version 0

+ 1 - 1
Source/GLS.ScriptBase.pas

@@ -243,7 +243,7 @@ begin
   inherited;
   inherited;
 end;
 end;
 
 
-initialization
+initialization //-------------------------------------------------------------
 
 
 RegisterClasses([TGLScriptLibrary, TGLScripts, TGLScriptBase]);
 RegisterClasses([TGLScriptLibrary, TGLScripts, TGLScriptBase]);
 
 

+ 4 - 5
Source/GLS.SmartObjects.pas

@@ -4,11 +4,10 @@
 unit GLS.SmartObjects;
 unit GLS.SmartObjects;
 
 
 (*
 (*
-  These objects have built-in properties and methods to support sound, vision,
-  physics, and finding shortest paths through obstacle terrains. In addition,
-  they have artificial intelligence to conduct dialogues and make
-  independent decisions. The smart spatial objects are used to interact
-  with other smart objects.
+  The objects that have built-in properties and methods to support sound, vision,
+  physics, and finding shortest paths through mezza obstacles, hightfields or terrains. 
+  They should have AI to conduct dialogues and make independent decisions. 
+  The smart spatial objects are used to interact with other smart objects and cyborgs.
 
 
   The registered classes:
   The registered classes:
    [TGLSmartGerm, TGLSmartCells, TGLSmartSwarm, TGLSmartNet, TGLCyborg, TGLCyborgs]
    [TGLSmartGerm, TGLSmartCells, TGLSmartSwarm, TGLSmartNet, TGLCyborg, TGLCyborgs]

+ 781 - 0
Source/GLScene.RedBlackTree.pas

@@ -0,0 +1,781 @@
+//
+// The graphics engine GXScene https://github.com/glscene
+//
+unit GLScene.RedBlackTree;
+
+(*
+  USAGE
+  The TRedBlackTree generic class behaves somewhat like a TList:
+  it stores _Value_ by _Key_
+  and uses the same comparison function as TList.Sort (TListSortCompare).
+  Functions Clear, Add, Delete, First and Last are equivalent,
+  except that First and Last return a _Key_ so they
+  can be used for comparisons in loops.
+
+  All _Key_ occur only once in the tree if DuplicateKeys is False:
+  when the same value is added twice, the second one is not stored.
+
+  When DuplicateKeys is enabled the second comparison function is used
+  for sort _Value_ and it duplicates not allowed.
+
+  To be able to manage the tree, the Create constructor has an argument
+  specifying the comparison function that should be used.
+
+  The function Find can be used to find a _Value_ that was put in the tree,
+  it searches for the given _Key_ using the comparison function given
+  at time of object creation.
+
+  The functions NextKey and PrevKey can be used to "walk" through the tree:
+  given a _Key_, NextKey replace it with the smallest key that
+  is larger than _Key_, PrevKey returns the largest key that is
+  smaller than _Key_. For Last and First key result not returned.
+*)
+
+interface
+
+{$I GLScene.Defines.inc}
+
+uses
+  System.Classes;
+
+type
+
+  TRBColor = (clRed, clBlack);
+
+{$IFDEF GENERIC_PREFIX}
+generic
+{$ENDIF}
+
+GRedBlackTree<TKey, TValue> = class
+  public 
+  type 
+  TKeyCompareFunc = function(const Item1, Item2: TKey): Integer;
+  TValueCompareFunc = function(const Item1, Item2: TValue): Boolean;
+  TForEachProc = procedure(AKey: TKey; AValue: TValue; out AContinue: Boolean);
+  TRBNode = class Key: TKey;
+    Left, Right, Parent, Twin: TRBNode;
+    Color:
+    TRBColor;
+    Value:
+    TValue;
+  end;
+
+  var
+    FRoot: TRBNode;
+    FLeftmost: TRBNode;
+    FRightmost: TRBNode;
+    FLastFound: TRBNode;
+    FLastNode: TRBNode;
+    FCount: Integer;
+    FKeyCompareFunc: TKeyCompareFunc;
+    FDuplicateKeys: Boolean;
+    FValueCompareFunc: TValueCompareFunc;
+    FOnChange: TNotifyEvent;
+
+  function FindNode(const Key: TKey): TRBNode;
+  procedure RotateLeft(var x: TRBNode);
+  procedure RotateRight(var x: TRBNode);
+  function Minimum(var x: TRBNode): TRBNode;
+  function Maximum(var x: TRBNode): TRBNode;
+  function GetFirst: TKey;
+  function GetLast: TKey;
+  procedure SetDuplicateKeys(Value: Boolean);
+  class procedure FastErase(x: TRBNode);
+  public
+    constructor Create(KeyCompare: TKeyCompareFunc;
+      ValueCompare: TValueCompareFunc);
+    destructor Destroy; override;
+    procedure Clear;
+    // Find value by key.
+    function Find(const Key: TKey; out Value: TValue): Boolean;
+    function NextKey(var Key: TKey; out Value: TValue): Boolean;
+    function PrevKey(var Key: TKey; out Value: TValue): Boolean;
+    function NextDublicate(out Value: TValue): Boolean;
+    procedure Add(const Key: TKey; const Value: TValue);
+    procedure Delete(const Key: TKey);
+    procedure ForEach(AProc: TForEachProc);
+    property Count: Integer read FCount;
+    property First: TKey read GetFirst;
+    property Last: TKey read GetLast;
+    property DuplicateKeys: Boolean read FDuplicateKeys
+      write SetDuplicateKeys;
+    property OnChange: TNotifyEvent read FOnChange
+      write FOnChange;
+end;
+
+function CompareInteger(const Item1, Item2: Integer): Integer;
+
+implementation // -------------------------------------------------------------
+
+function CompareInteger(const Item1, Item2: Integer): Integer;
+begin
+  if Item1 < Item2 then
+  begin
+    Result := -1;
+  end
+  else if (Item1 = Item2) then
+  begin
+    Result := 0;
+  end
+  else
+  begin
+    Result := 1;
+  end
+end;
+
+constructor GRedBlackTree<TKey, TValue>.Create(KeyCompare: TKeyCompareFunc;
+  ValueCompare: TValueCompareFunc);
+begin
+  inherited Create;
+  Assert(Assigned(KeyCompare));
+  FKeyCompareFunc := KeyCompare;
+  FValueCompareFunc := ValueCompare;
+  FRoot := nil;
+  FLeftmost := nil;
+  FRightmost := nil;
+  FDuplicateKeys := Assigned(ValueCompare);
+end;
+
+destructor GRedBlackTree<TKey, TValue>.Destroy;
+begin
+  Clear;
+  inherited Destroy;
+end;
+
+class procedure GRedBlackTree<TKey, TValue>.FastErase(x: TRBNode);
+var
+  y: TRBNode;
+begin
+  if (x.Left <> nil) then
+    FastErase(x.Left);
+  if (x.Right <> nil) then
+    FastErase(x.Right);
+  repeat
+    y := x;
+    x := x.Twin;
+    y.Destroy;
+  until x = nil;
+end;
+
+procedure GRedBlackTree<TKey, TValue>.Clear;
+begin
+  if (FRoot <> nil) then
+    FastErase(FRoot);
+  FRoot := nil;
+  FLeftmost := nil;
+  FRightmost := nil;
+  FCount := 0;
+  if Assigned(FOnChange) then
+    FOnChange(Self);
+end;
+
+function GRedBlackTree<TKey, TValue>.Find(const Key: TKey;
+  out Value: TValue): Boolean;
+begin
+  FLastFound := FindNode(Key);
+  Result := Assigned(FLastFound);
+  if Result then
+    Value := FLastFound.Value;
+end;
+
+function GRedBlackTree<TKey, TValue>.FindNode(const Key: TKey): TRBNode;
+var
+  cmp: Integer;
+begin
+  Result := FRoot;
+  while (Result <> nil) do
+  begin
+    cmp := FKeyCompareFunc(Result.Key, Key);
+    if cmp < 0 then
+    begin
+      Result := Result.Right;
+    end
+    else if cmp > 0 then
+    begin
+      Result := Result.Left;
+    end
+    else
+    begin
+      break;
+    end;
+  end;
+end;
+
+function GRedBlackTree<TKey, TValue>.NextDublicate(out Value: TValue): Boolean;
+begin
+  if Assigned(FLastFound) then
+  begin
+    if Assigned(FLastFound.Twin) then
+    begin
+      FLastFound := FLastFound.Twin;
+      Value := FLastFound.Value;
+      exit(True);
+    end;
+  end;
+  Result := False;
+end;
+
+procedure GRedBlackTree<TKey, TValue>.RotateLeft(var x: TRBNode);
+var
+  y: TRBNode;
+begin
+  y := x.Right;
+  x.Right := y.Left;
+  if (y.Left <> nil) then
+  begin
+    y.Left.Parent := x;
+  end;
+  y.Parent := x.Parent;
+  if (x = FRoot) then
+  begin
+    FRoot := y;
+  end
+  else if (x = x.Parent.Left) then
+  begin
+    x.Parent.Left := y;
+  end
+  else
+  begin
+    x.Parent.Right := y;
+  end;
+  y.Left := x;
+  x.Parent := y;
+end;
+
+procedure GRedBlackTree<TKey, TValue>.RotateRight(var x: TRBNode);
+var
+  y: TRBNode;
+begin
+  y := x.Left;
+  x.Left := y.Right;
+  if (y.Right <> nil) then
+  begin
+    y.Right.Parent := x;
+  end;
+  y.Parent := x.Parent;
+  if (x = FRoot) then
+  begin
+    FRoot := y;
+  end
+  else if (x = x.Parent.Right) then
+  begin
+    x.Parent.Right := y;
+  end
+  else
+  begin
+    x.Parent.Left := y;
+  end;
+  y.Right := x;
+  x.Parent := y;
+end;
+
+function GRedBlackTree<TKey, TValue>.Minimum(var x: TRBNode): TRBNode;
+begin
+  Result := x;
+  while (Result.Left <> nil) do
+    Result := Result.Left;
+end;
+
+function GRedBlackTree<TKey, TValue>.Maximum(var x: TRBNode): TRBNode;
+begin
+  Result := x;
+  while (Result.Right <> nil) do
+    Result := Result.Right;
+end;
+
+procedure GRedBlackTree<TKey, TValue>.Add(const Key: TKey; const Value: TValue);
+var
+  x, y, z, zpp: TRBNode;
+  cmp: Integer;
+begin
+  z := TRBNode.Create;
+
+  { Initialize fields in new node z }
+  z.Key := Key;
+  z.Left := nil;
+  z.Right := nil;
+  z.Color := clRed;
+  z.Value := Value;
+  z.Twin := nil;
+
+  { Maintain FLeftmost and FRightmost nodes }
+  if ((FLeftmost = nil) or (FKeyCompareFunc(Key, FLeftmost.Key) < 0)) then
+  begin
+    FLeftmost := z;
+  end;
+  if ((FRightmost = nil) or (FKeyCompareFunc(FRightmost.Key, Key) < 0)) then
+  begin
+    FRightmost := z;
+  end;
+
+  { Insert node z }
+  y := nil;
+  x := FRoot;
+  while (x <> nil) do
+  begin
+    y := x;
+    cmp := FKeyCompareFunc(Key, x.Key);
+    if cmp < 0 then
+      x := x.Left
+    else if cmp > 0 then
+      x := x.Right
+    else
+    begin
+      { Key already exists in tree. }
+      if FDuplicateKeys then
+      begin
+        { Check twins chain for value dublicate. }
+        repeat
+          if FValueCompareFunc(Value, x.Value) then
+          begin
+            y := nil;
+            break;
+          end;
+          y := x;
+          x := x.Twin;
+        until x = nil;
+        if Assigned(y) then
+        begin
+          { Add dublicate key to end of twins chain. }
+          y.Twin := z;
+          Inc(FCount);
+          if Assigned(FOnChange) then
+            FOnChange(Self);
+          exit;
+        end;
+        // Value already exists in tree.
+      end;
+      z.Destroy;
+      // a jzombi: memory leak: if we don't put it in the tree, we shouldn't hold it in the memory
+      exit;
+    end;
+  end;
+  z.Parent := y;
+  if (y = nil) then
+  begin
+    FRoot := z;
+  end
+  else if (FKeyCompareFunc(Key, y.Key) < 0) then
+  begin
+    y.Left := z;
+  end
+  else
+  begin
+    y.Right := z;
+  end;
+
+  { Rebalance tree }
+  while ((z <> FRoot) and (z.Parent.Color = clRed)) do
+  begin
+    zpp := z.Parent.Parent;
+    if (z.Parent = zpp.Left) then
+    begin
+      y := zpp.Right;
+      if ((y <> nil) and (y.Color = clRed)) then
+      begin
+        z.Parent.Color := clBlack;
+        y.Color := clBlack;
+        zpp.Color := clRed;
+        z := zpp;
+      end
+      else
+      begin
+        if (z = z.Parent.Right) then
+        begin
+          z := z.Parent;
+          RotateLeft(z);
+        end;
+        z.Parent.Color := clBlack;
+        zpp.Color := clRed;
+        RotateRight(zpp);
+      end;
+    end
+    else
+    begin
+      y := zpp.Left;
+      if ((y <> nil) and (y.Color = clRed)) then
+      begin
+        z.Parent.Color := clBlack;
+        y.Color := clBlack;
+        zpp.Color := clRed; // c jzombi: zpp.color := clRed;
+        z := zpp;
+      end
+      else
+      begin
+        if (z = z.Parent.Left) then
+        begin
+          z := z.Parent;
+          RotateRight(z);
+        end;
+        z.Parent.Color := clBlack;
+        zpp.Color := clRed; // c jzombi: zpp.color := clRed;
+        RotateLeft(zpp);
+      end;
+    end;
+  end;
+  FRoot.Color := clBlack;
+  Inc(FCount);
+  if Assigned(FOnChange) then
+    FOnChange(Self);
+end;
+
+procedure GRedBlackTree<TKey, TValue>.Delete(const Key: TKey);
+var
+  w, x, y, z, x_parent: TRBNode;
+  tmpcol: TRBColor;
+begin
+  z := FindNode(Key);
+  if z = nil then
+    exit;
+
+  y := z;
+  x := nil;
+  x_parent := nil;
+
+  if (y.Left = nil) then
+  begin // z has at most one non-null child. y = z.
+    x := y.Right; // x might be null.
+  end
+  else
+  begin
+    if (y.Right = nil) then
+    begin // z has exactly one non-null child. y = z.
+      x := y.Left; // x is not null.
+    end
+    else
+    begin
+      // z has two non-null children.  Set y to
+      y := y.Right; // z's successor.  x might be null.
+      while (y.Left <> nil) do
+      begin
+        y := y.Left;
+      end;
+      x := y.Right;
+    end;
+  end;
+
+  if (y <> z) then
+  begin
+    (* "copy y's sattelite data into z"
+      relink y in place of z.  y is z's successor *)
+    z.Left.Parent := y;
+    y.Left := z.Left;
+    if (y <> z.Right) then
+    begin
+      x_parent := y.Parent;
+      if (x <> nil) then
+      begin
+        x.Parent := y.Parent;
+      end;
+      y.Parent.Left := x; // y must be a child of left
+      y.Right := z.Right;
+      z.Right.Parent := y;
+    end
+    else
+    begin
+      x_parent := y;
+    end;
+    if (FRoot = z) then
+    begin
+      FRoot := y;
+    end
+    else if (z.Parent.Left = z) then
+    begin
+      z.Parent.Left := y;
+    end
+    else
+    begin
+      z.Parent.Right := y;
+    end;
+    y.Parent := z.Parent;
+    tmpcol := y.Color;
+    y.Color := z.Color;
+    z.Color := tmpcol;
+    y := z;
+    // y now points to node to be actually deleted
+  end
+  else
+  begin // y = z
+    x_parent := y.Parent;
+    if (x <> nil) then
+    begin
+      x.Parent := y.Parent;
+    end;
+    if (FRoot = z) then
+    begin
+      FRoot := x;
+    end
+    else
+    begin
+      if (z.Parent.Left = z) then
+      begin
+        z.Parent.Left := x;
+      end
+      else
+      begin
+        z.Parent.Right := x;
+      end;
+    end;
+    if (FLeftmost = z) then
+    begin
+      if (z.Right = nil) then
+      begin // z.left must be null also
+        FLeftmost := z.Parent;
+      end
+      else
+      begin
+        FLeftmost := Minimum(x);
+      end;
+    end;
+    if (FRightmost = z) then
+    begin
+      if (z.Left = nil) then
+      begin // z.right must be null also
+        FRightmost := z.Parent;
+      end
+      else
+      begin // x == z.left
+        FRightmost := Maximum(x);
+      end;
+    end;
+  end;
+
+  // Rebalance tree
+  if (y.Color = clBlack) then
+  begin
+    while ((x <> FRoot) and ((x = nil) or (x.Color = clBlack))) do
+    begin
+      if (x = x_parent.Left) then
+      begin
+        w := x_parent.Right;
+        if (w.Color = clRed) then
+        begin
+          w.Color := clBlack;
+          x_parent.Color := clRed;
+          RotateLeft(x_parent);
+          w := x_parent.Right;
+        end;
+        if (((w.Left = nil) or (w.Left.Color = clBlack)) and
+          ((w.Right = nil) or (w.Right.Color = clBlack))) then
+        begin
+          w.Color := clRed;
+          x := x_parent;
+          x_parent := x_parent.Parent;
+        end
+        else
+        begin
+          if ((w.Right = nil) or (w.Right.Color = clBlack)) then
+          begin
+            w.Left.Color := clBlack;
+            w.Color := clRed;
+            RotateRight(w);
+            w := x_parent.Right;
+          end;
+          w.Color := x_parent.Color;
+          x_parent.Color := clBlack;
+          if (w.Right <> nil) then
+          begin
+            w.Right.Color := clBlack;
+          end;
+          RotateLeft(x_parent);
+          x := FRoot; { break; }
+        end
+      end
+      else
+      begin
+        { same as above, with right <. left. }
+        w := x_parent.Left;
+        if (w.Color = clRed) then
+        begin
+          w.Color := clBlack;
+          x_parent.Color := clRed;
+          RotateRight(x_parent);
+          w := x_parent.Left;
+        end;
+        if (((w.Right = nil) or (w.Right.Color = clBlack)) and
+          ((w.Left = nil) or (w.Left.Color = clBlack))) then
+        begin
+          w.Color := clRed;
+          x := x_parent;
+          x_parent := x_parent.Parent;
+        end
+        else
+        begin
+          if ((w.Left = nil) or (w.Left.Color = clBlack)) then
+          begin
+            w.Right.Color := clBlack;
+            w.Color := clRed;
+            RotateLeft(w);
+            w := x_parent.Left;
+          end;
+          w.Color := x_parent.Color;
+          x_parent.Color := clBlack;
+          if (w.Left <> nil) then
+          begin
+            w.Left.Color := clBlack;
+          end;
+          RotateRight(x_parent);
+          x := FRoot; // break;
+        end;
+      end;
+    end;
+    if (x <> nil) then
+    begin
+      x.Color := clBlack;
+    end;
+  end;
+  while Assigned(y.Twin) do
+  begin
+    z := y;
+    y := y.Twin;
+    z.Destroy;
+  end;
+  y.Destroy;
+  Dec(FCount);
+  if Assigned(FOnChange) then
+    FOnChange(Self);
+end;
+
+function GRedBlackTree<TKey, TValue>.NextKey(var Key: TKey;
+  out Value: TValue): Boolean;
+var
+  x, y: TRBNode;
+begin
+  if Assigned(FLastNode) and (FKeyCompareFunc(FLastNode.Key, Key) = 0) then
+    x := FLastNode
+  else
+    x := FindNode(Key);
+  if x = nil then
+    exit;
+  if (x.Right <> nil) then
+  begin
+    x := x.Right;
+    while (x.Left <> nil) do
+    begin
+      x := x.Left;
+    end;
+  end
+  else if (x.Parent <> nil) then
+  begin
+    y := x.Parent;
+    while Assigned(y) and (x = y.Right) do
+    begin
+      x := y;
+      y := y.Parent;
+    end;
+    if (x.Right <> y) then
+      x := y;
+  end
+  else
+    x := FRoot;
+  if x = nil then
+    exit(False);
+  Key := x.Key;
+  FLastNode := x;
+  Value := x.Value;
+  Result := True;
+end;
+
+function GRedBlackTree<TKey, TValue>.PrevKey(var Key: TKey;
+  out Value: TValue): Boolean;
+var
+  x, y: TRBNode;
+begin
+  if Assigned(FLastNode) and (FKeyCompareFunc(FLastNode.Key, Key) = 0) then
+    x := FLastNode
+  else
+    x := FindNode(Key);
+  if x = nil then
+    exit(False);
+  if (x.Left <> nil) then
+  begin
+    y := x.Left;
+    while (y.Right <> nil) do
+    begin
+      y := y.Right;
+    end;
+    x := y;
+  end
+  else if (x.Parent <> nil) then
+  begin
+    y := x.Parent;
+    while (x = y.Left) do
+    begin
+      x := y;
+      y := y.Parent;
+    end;
+    x := y;
+  end
+  else
+    x := FRoot;
+  if x = nil then
+    exit(False);
+  Key := x.Key;
+  FLastNode := x;
+  Value := x.Value;
+  Result := True;
+end;
+
+function GRedBlackTree<TKey, TValue>.GetFirst: TKey;
+begin
+  Result := FLeftmost.Key;
+end;
+
+function GRedBlackTree<TKey, TValue>.GetLast: TKey;
+begin
+  Result := FRightmost.Key;
+end;
+
+procedure GRedBlackTree<TKey, TValue>.ForEach(AProc: TForEachProc);
+var
+  x, y, z: TRBNode;
+  cont: Boolean;
+begin
+  if Assigned(FLeftmost) then
+  begin
+    x := FLeftmost;
+    repeat
+      z := x;
+      repeat
+        AProc(z.Key, z.Value, cont);
+        if not cont then
+          exit;
+        z := z.Twin;
+      until z = nil;
+      // Next node
+      if (x.Right <> nil) then
+      begin
+        x := x.Right;
+        while (x.Left <> nil) do
+        begin
+          x := x.Left;
+        end;
+      end
+      else if (x.Parent <> nil) then
+      begin
+        y := x.Parent;
+        while (x = y.Right) do
+        begin
+          x := y;
+          y := y.Parent;
+        end;
+        if (x.Right <> y) then
+          x := y;
+      end
+      else
+        x := FRoot;
+    until x = FRightmost;
+    if cont and (FLeftmost <> FRightmost) then
+      AProc(FRightmost.Key, FRightmost.Value, cont);
+  end;
+end;
+
+procedure GRedBlackTree<TKey, TValue>.SetDuplicateKeys(Value: Boolean);
+begin
+  if Value and Assigned(FValueCompareFunc) then
+    FDuplicateKeys := True
+  else
+    FDuplicateKeys := False;
+end;
+
+end.

+ 3 - 3
Sourcex/GXS.Canvas.pas

@@ -166,9 +166,7 @@ type
     property ArcDirection: TgxArcDirection read FArcDirection write FArcDirection;
     property ArcDirection: TgxArcDirection read FArcDirection write FArcDirection;
   end;
   end;
 
 
-//-------------------------------------------------------------
-implementation
-//-------------------------------------------------------------
+implementation //-------------------------------------------------------------
 
 
 const
 const
   cNoPrimitive = MaxInt;
   cNoPrimitive = MaxInt;
@@ -763,5 +761,7 @@ begin
   pY^ := tmp;
   pY^ := tmp;
 end;
 end;
 
 
+//--------------------------------------------------------------------------
+
 end.
 end.
 
 

+ 12 - 13
Sourcex/GXS.CelShader.pas

@@ -22,22 +22,25 @@ uses
 
 
   GLScene.VectorTypes,
   GLScene.VectorTypes,
   GLScene.VectorGeometry,
   GLScene.VectorGeometry,
+  GLScene.Color,
+  GLScene.TextureFormat,
+
   GXS.Texture,
   GXS.Texture,
   GXS.Context,
   GXS.Context,
   GXS.Graphics,
   GXS.Graphics,
   GXS.ImageUtils,
   GXS.ImageUtils,
-  GLScene.Color,
   GXS.RenderContextInfo,
   GXS.RenderContextInfo,
   GXS.Material,
   GXS.Material,
-  GXS.State,
-  GLScene.TextureFormat;
+  GXS.State;
 
 
 type
 type
-  { Cel shading options.
+  (*
+   Cel shading options.
      csoOutlines: Render a second outline pass.
      csoOutlines: Render a second outline pass.
      csoTextured: Allows for a primary texture that the cel shading
      csoTextured: Allows for a primary texture that the cel shading
                   is modulated with and forces the shade definition
                   is modulated with and forces the shade definition
-                  to render as a second texture. }
+                  to render as a second texture.
+  *)
   TgxCelShaderOption = (csoOutlines, csoTextured, csoNoBuildShadeTexture);
   TgxCelShaderOption = (csoOutlines, csoTextured, csoNoBuildShadeTexture);
   TgxCelShaderOptions = set of TgxCelShaderOption;
   TgxCelShaderOptions = set of TgxCelShaderOption;
 
 
@@ -45,7 +48,7 @@ type
   TgxCelShaderGetIntensity = procedure(Sender: TObject; var intensity: Byte) of
   TgxCelShaderGetIntensity = procedure(Sender: TObject; var intensity: Byte) of
     object;
     object;
 
 
-  { A generic cel shader.  }
+  // A generic cel shader.
   TgxCelShader = class(TgxShader)
   TgxCelShader = class(TgxShader)
   private
   private
     FOutlineWidth: Single;
     FOutlineWidth: Single;
@@ -63,16 +66,12 @@ type
     procedure BuildShadeTexture;
     procedure BuildShadeTexture;
     procedure Loaded; override;
     procedure Loaded; override;
     function GenerateVertexProgram: string;
     function GenerateVertexProgram: string;
-
   public
   public
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
-
     procedure DoApply(var rci: TgxRenderContextInfo; Sender: TObject); override;
     procedure DoApply(var rci: TgxRenderContextInfo; Sender: TObject); override;
     function DoUnApply(var rci: TgxRenderContextInfo): Boolean; override;
     function DoUnApply(var rci: TgxRenderContextInfo): Boolean; override;
-
     property ShadeTexture: TgxTexture read FShadeTexture;
     property ShadeTexture: TgxTexture read FShadeTexture;
-
   published
   published
     property CelShaderOptions: TgxCelShaderOptions read FCelShaderOptions write
     property CelShaderOptions: TgxCelShaderOptions read FCelShaderOptions write
       SetCelShaderOptions;
       SetCelShaderOptions;
@@ -82,9 +81,7 @@ type
       FOnGetIntensity;
       FOnGetIntensity;
   end;
   end;
 
 
-// ------------------------------------------------------------------
-implementation
-// ------------------------------------------------------------------
+implementation // -----------------------------------------------------------
 
 
 // ------------------
 // ------------------
 // ------------------ TgxCelShader ------------------
 // ------------------ TgxCelShader ------------------
@@ -326,5 +323,7 @@ begin
   end;
   end;
 end;
 end;
 
 
+//--------------------------------------------------------------------------
+
 end.
 end.
 
 

+ 9 - 12
Sourcex/GXS.Collision.pas

@@ -14,13 +14,14 @@ uses
   System.SysUtils,
   System.SysUtils,
 
 
   GLScene.XCollection,
   GLScene.XCollection,
-  GXS.Scene,
   GLScene.VectorGeometry,
   GLScene.VectorGeometry,
   GLScene.VectorLists,
   GLScene.VectorLists,
-  GXS.VectorFileObjects,
   GLScene.GeometryBB,
   GLScene.GeometryBB,
   GLScene.Manager,
   GLScene.Manager,
-  GLScene.VectorTypes;
+  GLScene.VectorTypes,
+
+  GXS.Scene,
+  GXS.VectorFileObjects;
 
 
 type
 type
   TgxBCollision = class;
   TgxBCollision = class;
@@ -83,7 +84,7 @@ type
     class function FriendlyName: String; override;
     class function FriendlyName: String; override;
     class function FriendlyDescription: String; override;
     class function FriendlyDescription: String; override;
   published
   published
-    { Refers the collision manager. }
+    // Refers the collision manager.
     property Manager: TgxCollisionManager read FManager write SetManager;
     property Manager: TgxCollisionManager read FManager write SetManager;
     property BoundingMode: TCollisionBoundingMode read FBoundingMode
     property BoundingMode: TCollisionBoundingMode read FBoundingMode
       write FBoundingMode;
       write FBoundingMode;
@@ -127,9 +128,7 @@ function GetOrCreateCollision(behaviours: TgxBehaviours)
   This helper function is convenient way to access a TgxBCollision. *)
   This helper function is convenient way to access a TgxBCollision. *)
 function GetOrCreateCollision(obj: TgxBaseSceneObject): TgxBCollision; overload;
 function GetOrCreateCollision(obj: TgxBaseSceneObject): TgxBCollision; overload;
 
 
-// ------------------------------------------------------------------
-implementation
-// ------------------------------------------------------------------
+implementation // ------------------------------------------------------------
 
 
 const
 const
   cEpsilon: Single = 1E-6;
   cEpsilon: Single = 1E-6;
@@ -950,15 +949,13 @@ begin
   Result := GetOrCreateCollision(obj.behaviours);
   Result := GetOrCreateCollision(obj.behaviours);
 end;
 end;
 
 
-// ------------------------------------------------------------------
-initialization
-
-// ------------------------------------------------------------------
+initialization // -----------------------------------------------------------
 
 
 RegisterXCollectionItemClass(TgxBCollision);
 RegisterXCollectionItemClass(TgxBCollision);
 
 
-finalization
+finalization // -------------------------------------------------------------
 
 
 UnregisterXCollectionItemClass(TgxBCollision);
 UnregisterXCollectionItemClass(TgxBCollision);
 
 
+
 end.
 end.

+ 5 - 7
Sourcex/GXS.CompositeImage.pas

@@ -14,9 +14,10 @@ uses
   System.Classes,
   System.Classes,
   FMX.Graphics,
   FMX.Graphics,
 
 
+  GLScene.TextureFormat,
+
   GXS.Graphics,
   GXS.Graphics,
   GXS.Texture,
   GXS.Texture,
-  GLScene.TextureFormat,
   GXS.Context;
   GXS.Context;
 
 
 type
 type
@@ -51,9 +52,7 @@ type
     property Depth: Integer read GetDepth write SetDepth;
     property Depth: Integer read GetDepth write SetDepth;
   end;
   end;
 
 
-//=========================================================
-implementation
-//=========================================================
+implementation //------------------------------------------------------------
 
 
 // ------------------
 // ------------------
 // ------------------ TgxCompositeImage ------------------
 // ------------------ TgxCompositeImage ------------------
@@ -268,9 +267,8 @@ begin
     Result := ttNoShape;
     Result := ttNoShape;
 end;
 end;
 
 
-//=========================================================
-initialization
-//=========================================================
+initialization //-------------------------------------------------------------
+
   RegisterTextureImageClass(TgxCompositeImage);
   RegisterTextureImageClass(TgxCompositeImage);
 
 
 end.
 end.

+ 1 - 1
Sourcex/GXS.Console.pas

@@ -48,8 +48,8 @@ uses
   GLScene.PersistentClasses,
   GLScene.PersistentClasses,
   GLScene.Strings,
   GLScene.Strings,
   GLScene.Utils,
   GLScene.Utils,
-
   GLScene.Coordinates,
   GLScene.Coordinates,
+
   GXS.Scene,
   GXS.Scene,
   GXS.Objects,
   GXS.Objects,
   GXS.HUDObjects,
   GXS.HUDObjects,

+ 118 - 0
Sourcex/GXS.CyborgManager.pas

@@ -0,0 +1,118 @@
+unit GXS.CyborgManager;
+
+(*
+  The CyborgManager is a class that provides a way to manage
+  AI smart objects and thier swarms or proxies at runtime.
+  You need to have the model filename and it will load it
+  into the list or return the already existing model
+*)
+
+interface
+
+uses
+  System.SysUtils,
+  System.Classes,
+
+  GXS.SmartObjects,
+
+  GXS.Scene,
+  GXS.Objects,
+  GXS.FileGLTF,
+  GXS.File3DS,
+  GXS.FilePly,
+  GXS.FileOBJ;
+
+type
+  TgxCyborgManager = class
+  private
+    FMasterObject: TgxDummyCube;
+    FModelList: TStringList;
+    FModelPath: string;
+    (* Changing the path to the models and refresh the
+      already existing freeforms *)
+    procedure SetPathToModel(const Value: String);
+  public
+    (* It will create the list, assign the path to the
+      models and the master object where the new models will be loaded *)
+    constructor Create(AMaster: TgxDummyCube; APath: string); virtual;
+    (* It will free all the loaded models *)
+    destructor Destroy; override;
+    (* It will load a new model if it's not in the list and then return the new
+      freeform.  If it,s already in the list, it will return the existing freeform *)
+    function LoadModel(AFilename: string): TgxCyborg;
+    property MasterObject: TgxDummyCube read FMasterObject;
+    property ModelList: TStringList read FModelList;
+    property Path: string read FModelPath write SetPathToModel;
+  end;
+
+implementation //-------------------------------------------------------------
+
+constructor TgxCyborgManager.Create(AMaster: TgxDummyCube; APath: string);
+begin
+  // Set the master object
+  FMasterObject := AMaster;
+  // Create the model list
+  FModelList := TStringList.Create;
+  FModelList.CaseSensitive := false;
+  FModelList.Sorted := true;
+  // Set the path to the models
+  SetPathToModel(APath);
+end;
+
+// --------------------------------
+destructor TgxCyborgManager.Destroy;
+var
+  i: Integer;
+begin
+  // Destroy every models
+  for i := 0 to Pred(FModelList.Count) do
+    FModelList.Objects[i].Destroy;
+  // Destroy the list
+  FModelList.Destroy;
+  inherited;
+end;
+
+// --------------------------------------------------------------
+function TgxCyborgManager.LoadModel(AFilename: string): TgxCyborg;
+var
+  i: Integer;
+  NewFreeForm: TgxCyborg;
+begin
+  with FModelList do
+  begin
+    if Find(AFilename, i) then
+      Result := TgxCyborg(Objects[i])
+    else
+    begin
+      NewFreeForm := TgxCyborg(FMasterObject.AddNewChild(TgxCyborg));
+      NewFreeForm.LoadFromFile(FModelPath + AFilename);
+      FModelList.AddObject(AFilename, NewFreeForm);
+      Result := NewFreeForm;
+    end;
+  end;
+end;
+
+// ----------------------------------------------------------
+procedure TgxCyborgManager.SetPathToModel(const Value: String);
+var
+  Len: Integer;
+  i: Integer;
+begin
+  // Set the path
+  FModelPath := Value;
+  Len := Length(Value);
+  // Correct it if there is no '\'
+  if (Len > 0) then
+    if (Value[Len - 1] <> '\') then
+      FModelPath := Value + '\';
+  // Reload the models
+  for i := 0 to Pred(FModelList.Count) do
+    TgxCyborg(FModelList.Objects[i])
+      .LoadFromFile(FModelPath + FModelList.Strings[i]);
+end;
+
+initialization //-------------------------------------------------------------
+
+// RegisterClasses([TgxCyborgManager]);
+
+end.

+ 8 - 11
Sourcex/GXS.DCE.pas

@@ -37,16 +37,16 @@ uses
   GLScene.Manager,
   GLScene.Manager,
   GLScene.VectorTypes,
   GLScene.VectorTypes,
   GLScene.Strings,
   GLScene.Strings,
+  GLScene.Coordinates,
 
 
   GXS.Scene,
   GXS.Scene,
   GXS.VectorFileObjects,
   GXS.VectorFileObjects,
   GXS.DCEMisc,
   GXS.DCEMisc,
   GXS.EllipseCollision,
   GXS.EllipseCollision,
-  GXS.TerrainRenderer,
-  GLScene.Coordinates;
+  GXS.TerrainRenderer;
 
 
 type
 type
-  // Only csEllipsoid can have dynamic behaviour 
+  // Only csEllipsoid can have dynamic behaviour
   TgxDCEShape = (csEllipsoid, csBox, csFreeform, csTerrain);
   TgxDCEShape = (csEllipsoid, csBox, csFreeform, csTerrain);
 
 
   (* Indicates which type of layer comparison is made when trying to detect
   (* Indicates which type of layer comparison is made when trying to detect
@@ -177,7 +177,7 @@ type
     FBounceFactor: single; // 0 (don't bounce); 1 (bounce forever)
     FBounceFactor: single; // 0 (don't bounce); 1 (bounce forever)
     FSize: TgCoordinates;
     FSize: TgCoordinates;
     //Number of iterations of the collision method
     //Number of iterations of the collision method
-	FMaxRecursionDepth: byte;
+   	FMaxRecursionDepth: byte;
     FSlideOrBounce: TgxDCESlideOrBounce; // gak20041122
     FSlideOrBounce: TgxDCESlideOrBounce; // gak20041122
     // Movement
     // Movement
     FAccel: TAffineVector; // Current acceleration
     FAccel: TAffineVector; // Current acceleration
@@ -239,9 +239,7 @@ function GetOrCreateDCEStatic(obj: TgxBaseSceneObject): TgxDCEStatic; overload;
 function GetOrCreateDCEDynamic(behaviours: TgxBehaviours): TgxDCEDynamic; overload;
 function GetOrCreateDCEDynamic(behaviours: TgxBehaviours): TgxDCEDynamic; overload;
 function GetOrCreateDCEDynamic(obj: TgxBaseSceneObject): TgxDCEDynamic; overload;
 function GetOrCreateDCEDynamic(obj: TgxBaseSceneObject): TgxDCEDynamic; overload;
 
 
-// -------------------------------------------------------------------
-implementation
-// -------------------------------------------------------------------
+implementation // ------------------------------------------------------------
 
 
 function RotateVectorByObject(obj: TgxBaseSceneObject; v: TAffineVector): TAffineVector;
 function RotateVectorByObject(obj: TgxBaseSceneObject; v: TAffineVector): TAffineVector;
 var
 var
@@ -1115,17 +1113,16 @@ begin
   result := GetOrCreateDCEDynamic(obj.behaviours);
   result := GetOrCreateDCEDynamic(obj.behaviours);
 end;
 end;
 
 
-// ------------------------------------------------------------------
-initialization
-// ------------------------------------------------------------------
+initialization // ------------------------------------------------------------
 
 
 
 
 RegisterXCollectionItemClass(TgxDCEStatic);
 RegisterXCollectionItemClass(TgxDCEStatic);
 RegisterXCollectionItemClass(TgxDCEDynamic);
 RegisterXCollectionItemClass(TgxDCEDynamic);
 
 
-finalization
+finalization // --------------------------------------------------------------
 
 
 UnregisterXCollectionItemClass(TgxDCEStatic);
 UnregisterXCollectionItemClass(TgxDCEStatic);
 UnregisterXCollectionItemClass(TgxDCEDynamic);
 UnregisterXCollectionItemClass(TgxDCEDynamic);
 
 
+
 end.
 end.

+ 1 - 0
Sourcex/GXS.DCEMisc.pas

@@ -258,5 +258,6 @@ begin
   end;
   end;
 end;
 end;
 
 
+// ---------------------------------------------------------------------------
 
 
 end.
 end.

+ 2 - 2
Sourcex/GXS.EllipseCollision.pas

@@ -47,7 +47,7 @@ type
   TECTriMeshList = Array of TECTriMesh;
   TECTriMeshList = Array of TECTriMesh;
 
 
   TECFreeForm = record
   TECFreeForm = record
-    OctreeNodes: array of POctreeNode;
+    OctreeNodes: array of PgxOctreeNode;
     triangleFiler: ^TgAffineVectorList;
     triangleFiler: ^TgAffineVectorList;
     InvertedNormals: Boolean;
     InvertedNormals: Boolean;
     ObjectInfo: TECObjectInfo;
     ObjectInfo: TECObjectInfo;
@@ -685,7 +685,7 @@ end;
 procedure CheckCollisionFreeForm(var MP: TECMovePack);
 procedure CheckCollisionFreeForm(var MP: TECMovePack);
 var
 var
   n, i, t, k: Integer;
   n, i, t, k: Integer;
-  p: POctreeNode;
+  p: PgxOctreeNode;
   p1, p2, p3: PAffineVector;
   p1, p2, p3: PAffineVector;
   v1, v2, v3: TAffineVector;
   v1, v2, v3: TAffineVector;
   Collided: Boolean;
   Collided: Boolean;

+ 1 - 3
Sourcex/GXS.Material.pas

@@ -2957,9 +2957,7 @@ begin
   Result := (Abs(AlphaFuncRef) > 0.001);
   Result := (Abs(AlphaFuncRef) > 0.001);
 end;
 end;
 
 
-//-------------------------------------------------
-initialization
-//-------------------------------------------------
+initialization //--------------------------------------------------------------
 
 
 RegisterClasses([TgxMaterialLibrary, TgxMaterial, TgxShader]);
 RegisterClasses([TgxMaterialLibrary, TgxMaterial, TgxShader]);
 
 

+ 48 - 54
Sourcex/GXS.Octree.pas

@@ -21,21 +21,18 @@ uses
   GXS.Context;
   GXS.Context;
 
 
 type
 type
-
   TProcInt = procedure(I: Integer) of object;
   TProcInt = procedure(I: Integer) of object;
   TProcAffineAffineAffine = procedure(V1, V2, V3: TAffineFLTVector) of object;
   TProcAffineAffineAffine = procedure(V1, V2, V3: TAffineFLTVector) of object;
 
 
-  // Stores information about an intersected triangle. 
-  TOctreeTriangleInfo = record
+  // Stores information about an intersected triangle.
+  TgxOctreeTriangleInfo = record
     Index: Integer;
     Index: Integer;
     Vertex: array [0 .. 2] of TAffineVector;
     Vertex: array [0 .. 2] of TAffineVector;
   end;
   end;
+  PgxOctreeTriangleInfo = ^TgxOctreeTriangleInfo;
 
 
-  POctreeTriangleInfo = ^TOctreeTriangleInfo;
-
-  POctreeNode = ^TOctreeNode;
-
-  TOctreeNode = record
+  PgxOctreeNode = ^TgxOctreeNode;
+  TgxOctreeNode = record
     MinExtent: TAffineFLTVector;
     MinExtent: TAffineFLTVector;
     MaxExtent: TAffineFLTVector;
     MaxExtent: TAffineFLTVector;
     // TextureHandle:TgxTextureHandle;
     // TextureHandle:TgxTextureHandle;
@@ -43,7 +40,7 @@ type
     WillDraw: Boolean; // temporary change
     WillDraw: Boolean; // temporary change
     // Duplicates possible?
     // Duplicates possible?
     TriArray: array of Integer; // array of triangle references
     TriArray: array of Integer; // array of triangle references
-    ChildArray: array [0 .. 7] of POctreeNode; // Octree's 8 children
+    ChildArray: array [0 .. 7] of PgxOctreeNode; // Octree's 8 children
   end;
   end;
 
 
   // Manages an Octree containing references to triangles.
   // Manages an Octree containing references to triangles.
@@ -63,38 +60,38 @@ type
     // Check if a sphere (at point C with radius) lies within the AABB specified by min and max entents
     // Check if a sphere (at point C with radius) lies within the AABB specified by min and max entents
     function SphereInNode(const MinExtent, MaxExtent: TAffineVector;
     function SphereInNode(const MinExtent, MaxExtent: TAffineVector;
       const C: TVector4f; Radius: Single): Boolean;
       const C: TVector4f; Radius: Single): Boolean;
-    procedure WalkTriToLeafx(Onode: POctreeNode;
+    procedure WalkTriToLeafx(Onode: PgxOctreeNode;
       const V1, V2, V3: TAffineFLTVector);
       const V1, V2, V3: TAffineFLTVector);
-    procedure WalkPointToLeafx(ONode: POctreeNode; const P: TAffineVector);
-    procedure WalkSphereToLeafx(Onode: POctreeNode; const P: TVector4f;
+    procedure WalkPointToLeafx(ONode: PgxOctreeNode; const P: TAffineVector);
+    procedure WalkSphereToLeafx(Onode: PgxOctreeNode; const P: TVector4f;
       Radius: Single);
       Radius: Single);
-    procedure WalkRayToLeafx(Onode: POctreeNode; const P, V: TVector4f);
-    function GetExtent(const Flags: array of Byte; ParentNode: POctreeNode)
+    procedure WalkRayToLeafx(Onode: PgxOctreeNode; const P, V: TVector4f);
+    function GetExtent(const Flags: array of Byte; ParentNode: PgxOctreeNode)
       : TAffineFLTVector;
       : TAffineFLTVector;
     // Recursive routine to build nodes from parent to max depth level.
     // Recursive routine to build nodes from parent to max depth level.
-    procedure Refine(ParentNode: POctreeNode; Level: Integer);
+    procedure Refine(ParentNode: PgxOctreeNode; Level: Integer);
     // Main "walking" routines.  Walks the item through the Octree down to a leaf node.
     // Main "walking" routines.  Walks the item through the Octree down to a leaf node.
-    procedure WalkPointToLeaf(ONode: POctreeNode; const P: TAffineVector);
-    procedure WalkTriToLeaf(Onode: POctreeNode;
+    procedure WalkPointToLeaf(ONode: PgxOctreeNode; const P: TAffineVector);
+    procedure WalkTriToLeaf(Onode: PgxOctreeNode;
       const V1, V2, V3: TAffineVector);
       const V1, V2, V3: TAffineVector);
-    procedure WalkRayToLeaf(Onode: POctreeNode; const P, V: TVector4f);
+    procedure WalkRayToLeaf(Onode: PgxOctreeNode; const P, V: TVector4f);
     // Example of how to process each node in the tree
     // Example of how to process each node in the tree
-    procedure ConvertR4(ONode: POctreeNode; const Scale: TAffineFLTVector);
+    procedure ConvertR4(ONode: PgxOctreeNode; const Scale: TAffineFLTVector);
     procedure CreateTree(Depth: Integer);
     procedure CreateTree(Depth: Integer);
     procedure CutMesh;
     procedure CutMesh;
   public
   public
     WorldMinExtent, WorldMaxExtent: TAffineFLTVector;
     WorldMinExtent, WorldMaxExtent: TAffineFLTVector;
-    RootNode: POctreeNode; // always points to root node
-    MaxOlevel: Integer; // max depth level of TOctreeNode
+    RootNode: PgxOctreeNode; // always points to root node
+    MaxOlevel: Integer; // max depth level of TgxOctreeNode
     NodeCount: Integer;
     NodeCount: Integer;
     // number of nodes (ex: 8 for level 1, 72 for level 2 etc).
     // number of nodes (ex: 8 for level 1, 72 for level 2 etc).
     TriCountMesh: Integer; // total number of triangles in the mesh
     TriCountMesh: Integer; // total number of triangles in the mesh
     TriCountOctree: Integer; // total number of triangles cut into the octree
     TriCountOctree: Integer; // total number of triangles cut into the octree
     MeshCount: Integer; // number of meshes currently cut into the Octree
     MeshCount: Integer; // number of meshes currently cut into the Octree
-    ResultArray: array of POctreeNode; // holds the result nodes of various calls
+    ResultArray: array of PgxOctreeNode; // holds the result nodes of various calls
     // Needed this change - Used in ECMisc.pas
     // Needed this change - Used in ECMisc.pas
     TriangleFiler: TgAffineVectorList;
     TriangleFiler: TgAffineVectorList;
-    procedure WalkSphereToLeaf(Onode: POctreeNode; const P: TVector4f;
+    procedure WalkSphereToLeaf(Onode: PgxOctreeNode; const P: TVector4f;
       Radius: Single);
       Radius: Single);
     (* Initializes the tree from the triangle list.
     (* Initializes the tree from the triangle list.
       All triangles must be contained in the world extent to be properly
       All triangles must be contained in the world extent to be properly
@@ -106,7 +103,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     function RayCastIntersect(const RayStart, RayVector: TVector4f;
     function RayCastIntersect(const RayStart, RayVector: TVector4f;
       IntersectPoint: PVector4f = nil; IntersectNormal: PVector4f = nil;
       IntersectPoint: PVector4f = nil; IntersectNormal: PVector4f = nil;
-      TriangleInfo: POctreeTriangleInfo = nil): Boolean;
+      TriangleInfo: PgxOctreeTriangleInfo = nil): Boolean;
     function SphereSweepIntersect(const RayStart, RayVector: TVector4f;
     function SphereSweepIntersect(const RayStart, RayVector: TVector4f;
       const Velocity, Radius: Single; IntersectPoint: PVector4f = nil;
       const Velocity, Radius: Single; IntersectPoint: PVector4f = nil;
       IntersectNormal: PVector4f = nil): Boolean;
       IntersectNormal: PVector4f = nil): Boolean;
@@ -123,9 +120,7 @@ type
     // function SphereIntersect(position:TAffineVector; radius:single);
     // function SphereIntersect(position:TAffineVector; radius:single);
   end;
   end;
 
 
-//===================================================================
-implementation
-//===================================================================
+implementation //--------------------------------------------------------
 
 
 // ----------------------------------------------------------------------
 // ----------------------------------------------------------------------
 // Name  : CheckPointInSphere()
 // Name  : CheckPointInSphere()
@@ -815,8 +810,7 @@ begin
 end;
 end;
 
 
 procedure TgxOctree.DisposeTree;
 procedure TgxOctree.DisposeTree;
-
-  procedure WalkDispose(var Node: POctreeNode);
+  (*sub*)procedure WalkDispose(var Node: PgxOctreeNode);
   var
   var
     I: Integer;
     I: Integer;
   begin
   begin
@@ -847,7 +841,7 @@ procedure TgxOctree.CutMesh;
   procedure AddTriangleToNodes(N: Integer);
   procedure AddTriangleToNodes(N: Integer);
   var
   var
     X, K: Integer;
     X, K: Integer;
-    P: POctreeNode;
+    P: PgxOctreeNode;
   begin
   begin
     for X := 0 to High(ResultArray) do
     for X := 0 to High(ResultArray) do
     begin
     begin
@@ -887,7 +881,7 @@ begin
   // This formula is non-quadrant specific; ie: good.
   // This formula is non-quadrant specific; ie: good.
 end;
 end;
 
 
-function TgxOctree.GetExtent(const Flags: array of Byte; ParentNode: POctreeNode)
+function TgxOctree.GetExtent(const Flags: array of Byte; ParentNode: PgxOctreeNode)
   : TAffineFLTVector;
   : TAffineFLTVector;
 var
 var
   Emin, Emax: TAffineFLTVector;
   Emin, Emax: TAffineFLTVector;
@@ -914,7 +908,7 @@ procedure TgxOctree.InitializeTree(const AWorldMinExtent, AWorldMaxExtent
   const ATreeDepth: Integer);
   const ATreeDepth: Integer);
 var
 var
   N: Integer;
   N: Integer;
-  Newnode: POctreeNode;
+  Newnode: PgxOctreeNode;
 begin
 begin
   Self.WorldMinExtent := AWorldMinExtent;
   Self.WorldMinExtent := AWorldMinExtent;
   Self.WorldMaxExtent := AWorldMaxExtent;
   Self.WorldMaxExtent := AWorldMaxExtent;
@@ -939,12 +933,12 @@ begin
   CutMesh;
   CutMesh;
 end;
 end;
 
 
-procedure TgxOctree.Refine(ParentNode: POctreeNode; Level: Integer);
+procedure TgxOctree.Refine(ParentNode: PgxOctreeNode; Level: Integer);
 var
 var
   N, X, Z: Integer;
   N, X, Z: Integer;
-  Pwork: array [0 .. 7] of POctreeNode;
+  Pwork: array [0 .. 7] of PgxOctreeNode;
   // Stores addresses of newly created children.
   // Stores addresses of newly created children.
-  Newnode: POctreeNode;
+  Newnode: PgxOctreeNode;
 begin
 begin
   if Level < MaxOlevel then
   if Level < MaxOlevel then
   begin
   begin
@@ -971,7 +965,7 @@ begin
   end; // end if
   end; // end if
 end;
 end;
 
 
-procedure TgxOctree.ConvertR4(ONode: POctreeNode; const Scale: TAffineFLTVector);
+procedure TgxOctree.ConvertR4(ONode: PgxOctreeNode; const Scale: TAffineFLTVector);
 var
 var
   N: Smallint;
   N: Smallint;
 begin
 begin
@@ -994,13 +988,13 @@ begin
     (APoint.Z <= Max.Z);
     (APoint.Z <= Max.Z);
 end;
 end;
 
 
-procedure TgxOctree.WalkPointToLeaf(Onode: POctreeNode; const P: TAffineVector);
+procedure TgxOctree.WalkPointToLeaf(Onode: PgxOctreeNode; const P: TAffineVector);
 begin
 begin
   Finalize(Resultarray);
   Finalize(Resultarray);
   WalkPointToLeafx(Onode, P);
   WalkPointToLeafx(Onode, P);
 end;
 end;
 
 
-procedure TgxOctree.WalkPointToLeafx(Onode: POctreeNode; const P: TAffineVector);
+procedure TgxOctree.WalkPointToLeafx(Onode: PgxOctreeNode; const P: TAffineVector);
 var
 var
   N: Integer;
   N: Integer;
 begin
 begin
@@ -1047,14 +1041,14 @@ begin
     Result := FALSE;
     Result := FALSE;
 end;
 end;
 
 
-procedure TgxOctree.WalkSphereToLeaf(Onode: POctreeNode; const P: TVector4f;
+procedure TgxOctree.WalkSphereToLeaf(Onode: PgxOctreeNode; const P: TVector4f;
   Radius: Single);
   Radius: Single);
 begin
 begin
   Finalize(Resultarray);
   Finalize(Resultarray);
   WalkSphereToLeafx(Onode, P, Radius);
   WalkSphereToLeafx(Onode, P, Radius);
 end;
 end;
 
 
-procedure TgxOctree.WalkSphereToLeafx(Onode: POctreeNode; const P: TVector4f;
+procedure TgxOctree.WalkSphereToLeafx(Onode: PgxOctreeNode; const P: TVector4f;
   Radius: Single);
   Radius: Single);
 var
 var
   N: Integer;
   N: Integer;
@@ -1073,14 +1067,14 @@ begin
 end;
 end;
 
 
 // Cast a ray (point p, vector v) into the Octree (ie: ray-box intersect).
 // Cast a ray (point p, vector v) into the Octree (ie: ray-box intersect).
-procedure TgxOctree.WalkRayToLeaf(Onode: POctreeNode; const P, V: TVector4f);
+procedure TgxOctree.WalkRayToLeaf(Onode: PgxOctreeNode; const P, V: TVector4f);
 begin
 begin
   Finalize(Resultarray);
   Finalize(Resultarray);
 
 
   WalkRayToLeafx(Onode, P, V);
   WalkRayToLeafx(Onode, P, V);
 end;
 end;
 
 
-procedure TgxOctree.WalkRayToLeafx(Onode: POctreeNode; const P, V: TVector4f);
+procedure TgxOctree.WalkRayToLeafx(Onode: PgxOctreeNode; const P, V: TVector4f);
 var
 var
   N: Integer;
   N: Integer;
   Coord: TVector4f;
   Coord: TVector4f;
@@ -1139,14 +1133,14 @@ end;
 
 
 //-----------------------------------------------------
 //-----------------------------------------------------
 
 
-procedure TgxOctree.WalkTriToLeaf(Onode: POctreeNode;
+procedure TgxOctree.WalkTriToLeaf(Onode: PgxOctreeNode;
   const V1, V2, V3: TAffineFLTVector);
   const V1, V2, V3: TAffineFLTVector);
 begin
 begin
   Finalize(Resultarray);
   Finalize(Resultarray);
   WalkTriToLeafx(Onode, V1, V2, V3);
   WalkTriToLeafx(Onode, V1, V2, V3);
 end;
 end;
 
 
-procedure TgxOctree.WalkTriToLeafx(Onode: POctreeNode;
+procedure TgxOctree.WalkTriToLeafx(Onode: PgxOctreeNode;
   const V1, V2, V3: TAffineFLTVector);
   const V1, V2, V3: TAffineFLTVector);
 var
 var
   M: Integer;
   M: Integer;
@@ -1169,13 +1163,13 @@ end;
 
 
 function TgxOctree.RayCastIntersect(const RayStart, RayVector: TVector4f;
 function TgxOctree.RayCastIntersect(const RayStart, RayVector: TVector4f;
   IntersectPoint: PVector4f = nil; IntersectNormal: PVector4f = nil;
   IntersectPoint: PVector4f = nil; IntersectNormal: PVector4f = nil;
-  TriangleInfo: POctreeTriangleInfo = nil): Boolean;
+  TriangleInfo: PgxOctreeTriangleInfo = nil): Boolean;
 const
 const
   CInitialMinD: Single = 1E40;
   CInitialMinD: Single = 1E40;
 var
 var
   I, T, K: Integer;
   I, T, K: Integer;
   D, MinD: Single;
   D, MinD: Single;
-  P: POctreeNode;
+  P: PgxOctreeNode;
   IPoint, INormal: TVector4f;
   IPoint, INormal: TVector4f;
 begin
 begin
   WalkRayToLeaf(RootNode, RayStart, RayVector);
   WalkRayToLeaf(RootNode, RayStart, RayVector);
@@ -1261,7 +1255,7 @@ var
   I, T, K: Integer;
   I, T, K: Integer;
   MinD2, Sd2, Radius2: Single;
   MinD2, Sd2, Radius2: Single;
   DistanceToTravel, DistanceToTravelMinusRadius2: Single;
   DistanceToTravel, DistanceToTravelMinusRadius2: Single;
-  P: POctreeNode;
+  P: PgxOctreeNode;
   PNormal: TAffineVector;
   PNormal: TAffineVector;
   PNormal4: TVector4f;
   PNormal4: TVector4f;
   NEGpNormal4: TVector4f;
   NEGpNormal4: TVector4f;
@@ -1418,7 +1412,7 @@ end;
 function TgxOctree.TriangleIntersect(const V1, V2, V3: TAffineVector): Boolean;
 function TgxOctree.TriangleIntersect(const V1, V2, V3: TAffineVector): Boolean;
 var
 var
   I, T, K: Integer;
   I, T, K: Integer;
-  P: POctreeNode;
+  P: PgxOctreeNode;
   P1, P2, P3: PAffineVector;
   P1, P2, P3: PAffineVector;
 begin
 begin
   Result := False; // default: no collision
   Result := False; // default: no collision
@@ -1478,7 +1472,6 @@ begin
       { // } I := I + 3;
       { // } I := I + 3;
     end;
     end;
   end;
   end;
-
   TriList.Free;
   TriList.Free;
 end;
 end;
 
 
@@ -1487,7 +1480,7 @@ function TgxOctree.GetTrianglesFromNodesIntersectingAABB(const ObjAABB: TAABB)
 var
 var
   AABB1: TAABB;
   AABB1: TAABB;
 
 
-  procedure HandleNode(Onode: POctreeNode);
+  procedure HandleNode(Onode: PgxOctreeNode);
   var
   var
     AABB2: TAABB;
     AABB2: TAABB;
     I: Integer;
     I: Integer;
@@ -1512,7 +1505,7 @@ var
 
 
 var
 var
   I, K: Integer;
   I, K: Integer;
-  P: POctreeNode;
+  P: PgxOctreeNode;
   TriangleIndices: TgIntegerList;
   TriangleIndices: TgIntegerList;
 
 
 begin
 begin
@@ -1543,7 +1536,6 @@ begin
   finally
   finally
     TriangleIndices.Free;
     TriangleIndices.Free;
   end;
   end;
-
 end;
 end;
 
 
 function TgxOctree.GetTrianglesFromNodesIntersectingCube(const ObjAABB: TAABB;
 function TgxOctree.GetTrianglesFromNodesIntersectingCube(const ObjAABB: TAABB;
@@ -1552,7 +1544,7 @@ var
   AABB1: TAABB;
   AABB1: TAABB;
   M1To2, M2To1: TMatrix4f;
   M1To2, M2To1: TMatrix4f;
 
 
-  procedure HandleNode(Onode: POctreeNode);
+  procedure HandleNode(Onode: PgxOctreeNode);
   var
   var
     AABB2: TAABB;
     AABB2: TAABB;
     I: Integer;
     I: Integer;
@@ -1577,7 +1569,7 @@ var
 
 
 var
 var
   I, K: Integer;
   I, K: Integer;
-  P: POctreeNode;
+  P: PgxOctreeNode;
   TriangleIndices: TgIntegerList;
   TriangleIndices: TgIntegerList;
 begin
 begin
   // Calc AABBs
   // Calc AABBs
@@ -1612,4 +1604,6 @@ begin
   end;
   end;
 end;
 end;
 
 
+//---------------------------------------------------------------------------
+
 end.
 end.

+ 2 - 4
Sourcex/GXS.OpenGLAdapter.pas

@@ -4792,15 +4792,13 @@ begin
   Result := GetProcAddressGLS('glResizeBuffersMESA') <> nil;
   Result := GetProcAddressGLS('glResizeBuffersMESA') <> nil;
 end;
 end;
 
 
-//--------------------------------------
-initialization
-//--------------------------------------
+initialization //-------------------------------------------------------------
 
 
 {$IFNDEF CROSSVCL}
 {$IFNDEF CROSSVCL}
 Set8087CW($133F);
 Set8087CW($133F);
 {$ENDIF}
 {$ENDIF}
 
 
-finalization
+finalization //---------------------------------------------------------------
 
 
 CloseOpenGL;
 CloseOpenGL;
 
 

+ 2 - 7
Sourcex/GXS.PAKArchive.pas

@@ -19,7 +19,6 @@ const
   SIGN = 'PACK';
   SIGN = 'PACK';
 
 
 type
 type
-
   TPakHeader = record
   TPakHeader = record
     Signature: array [0 .. 3] of AnsiChar;
     Signature: array [0 .. 3] of AnsiChar;
     DirOffset: integer;
     DirOffset: integer;
@@ -58,9 +57,7 @@ type
     procedure Extract(ContentName, NewName: string); override;
     procedure Extract(ContentName, NewName: string); override;
   end;
   end;
 
 
-//=======================================================
-implementation
-//=======================================================
+implementation //-------------------------------------------------------------
 
 
 var
 var
   Dir: TFileSection;
   Dir: TFileSection;
@@ -286,9 +283,7 @@ begin
     Extract(FContentList.IndexOf(ContentName), NewName);
     Extract(FContentList.IndexOf(ContentName), NewName);
 end;
 end;
 
 
-//----------------------------------------
-initialization
-//----------------------------------------
+initialization //-------------------------------------------------------------
 
 
 RegisterArchiveFormat('pak', 'PAK File', TPAKArchive);
 RegisterArchiveFormat('pak', 'PAK File', TPAKArchive);
 
 

+ 1 - 3
Sourcex/GXS.Particles.pas

@@ -110,9 +110,7 @@ type
     property OnAfterRenderParticles: TDirectRenderEvent read FOnAfterRenderParticles write FOnAfterRenderParticles;
     property OnAfterRenderParticles: TDirectRenderEvent read FOnAfterRenderParticles write FOnAfterRenderParticles;
   end;
   end;
 
 
-// ------------------------------------------------------------------
-implementation
-//---------------------------------------------------------------------
+implementation //-------------------------------------------------------------
 
 
 //----------------- TgxParticles --------------------------------------
 //----------------- TgxParticles --------------------------------------
 //---------------------------------------------------------------------
 //---------------------------------------------------------------------

+ 1 - 3
Sourcex/GXS.PictureRegisteredFormats.pas

@@ -25,9 +25,7 @@ function GraphicClassForExtension(const anExtension: string): TGraphicClass;
    the corresponding TGraphicClass (extensions do not include the '.'). *)
    the corresponding TGraphicClass (extensions do not include the '.'). *)
 procedure HackTPictureRegisteredFormats(destList: TStrings);
 procedure HackTPictureRegisteredFormats(destList: TStrings);
 
 
-// ------------------------------------------------------------------
-implementation
-// ------------------------------------------------------------------
+implementation // -----------------------------------------------------------
 
 
 type
 type
   PInteger = ^integer;
   PInteger = ^integer;

+ 1 - 3
Sourcex/GXS.PolygonTesselation.pas

@@ -25,9 +25,7 @@ uses
 procedure DoTesselate(Vertexes: TgAffineVectorList;
 procedure DoTesselate(Vertexes: TgAffineVectorList;
   Mesh: TgxBaseMesh; normal: PAffineVector = nil; invertNormals: Boolean = False);
   Mesh: TgxBaseMesh; normal: PAffineVector = nil; invertNormals: Boolean = False);
 
 
-//------------------------------------------------
-implementation
-//------------------------------------------------
+implementation //-------------------------------------------------------------
 
 
 var
 var
   TessMesh: TgxMeshObject;
   TessMesh: TgxMeshObject;

+ 19 - 23
Sourcex/GXS.ProxyObjects.pas

@@ -54,9 +54,11 @@ type
       write SetMasterMaterialObject;
       write SetMasterMaterialObject;
   end;
   end;
 
 
-  { A proxy object with its own material.
-     This proxy object can take a mesh from one master and a materia from
-     a material library. }
+  (*
+    A proxy object with its own material.
+    This proxy object can take a mesh from one master and a materia from
+    a material library.
+  *)
   TgxMaterialProxy = class(TgxProxyObject, IgxMaterialLibrarySupported)
   TgxMaterialProxy = class(TgxProxyObject, IgxMaterialLibrarySupported)
   private
   private
     FTempLibMaterialName: string;
     FTempLibMaterialName: string;
@@ -76,13 +78,15 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
     procedure DoRender(var ARci: TgxRenderContextInfo;
     procedure DoRender(var ARci: TgxRenderContextInfo;
       ARenderSelf, ARenderChildren: Boolean); override;
       ARenderSelf, ARenderChildren: Boolean); override;
-    { Specifies the Material, that current master object will use.
-       Provides a faster way to access FMasterLibMaterial, compared to
-       MasterLibMaterialName }
+    (*
+      Specifies the Material, that current master object will use.
+      Provides a faster way to access FMasterLibMaterial, compared to
+      MasterLibMaterialName
+    *)
     property MasterLibMaterial: TgxLibMaterial read FMasterLibMaterial write
     property MasterLibMaterial: TgxLibMaterial read FMasterLibMaterial write
       FMasterLibMaterial stored False;
       FMasterLibMaterial stored False;
   published
   published
-    
+
     property MaterialLibrary: TgxMaterialLibrary read FMaterialLibrary write
     property MaterialLibrary: TgxMaterialLibrary read FMaterialLibrary write
       SetMaterialLibrary;
       SetMaterialLibrary;
     // Specifies the Material, that current master object will use.
     // Specifies the Material, that current master object will use.
@@ -172,12 +176,15 @@ type
     property EndFrame: Integer read FEndFrame;
     property EndFrame: Integer read FEndFrame;
     property CurrentFrameDelta: Single read FCurrentFrameDelta;
     property CurrentFrameDelta: Single read FCurrentFrameDelta;
     property CurrentTime: TGProgressTimes read FCurrentTime;
     property CurrentTime: TGProgressTimes read FCurrentTime;
-    { Gets the Bones Matrix in the current animation frame.
-     (since the masterobject is shared between all proxies, each proxy will have it's bones matrices) }
+    (*
+     Gets the Bones Matrix in the current animation frame.
+     (since the masterobject is shared between all proxies,
+      each proxy will have it's bones matrices)
+     *)
     function BoneMatrix(BoneIndex: integer): TMatrix4f; overload;
     function BoneMatrix(BoneIndex: integer): TMatrix4f; overload;
     function BoneMatrix(BoneName: string): TMatrix4f; overload;
     function BoneMatrix(BoneName: string): TMatrix4f; overload;
     procedure BoneMatricesClear;
     procedure BoneMatricesClear;
-    { A standard version of the RayCastIntersect function. }
+    // A standard version of the RayCastIntersect function
     function RayCastIntersect(const rayStart, rayVector: TVector4f;
     function RayCastIntersect(const rayStart, rayVector: TVector4f;
       intersectPoint: PVector4f = nil;
       intersectPoint: PVector4f = nil;
       intersectNormal: PVector4f = nil): Boolean; override;
       intersectNormal: PVector4f = nil): Boolean; override;
@@ -221,9 +228,7 @@ type
       SetOnBeforeRender;
       SetOnBeforeRender;
   end;
   end;
 
 
-//-------------------------------------------------------------
-implementation
-//-------------------------------------------------------------
+implementation //-------------------------------------------------------------
 
 
 // ------------------
 // ------------------
 // ------------------ TgxColorProxy ------------------
 // ------------------ TgxColorProxy ------------------
@@ -238,7 +243,6 @@ end;
 destructor TgxColorProxy.Destroy;
 destructor TgxColorProxy.Destroy;
 begin
 begin
   FFrontColor.Free;
   FFrontColor.Free;
-
   inherited Destroy;
   inherited Destroy;
 end;
 end;
 
 
@@ -376,7 +380,6 @@ begin
         SetVector(intersectNormal^, LocalToAbsolute(intersectNormal^));
         SetVector(intersectNormal^, LocalToAbsolute(intersectNormal^));
       end;
       end;
     end;
     end;
-
   end;
   end;
 end;
 end;
 
 
@@ -509,9 +512,7 @@ begin
 
 
           if Assigned(FOnBeforeRender) then
           if Assigned(FOnBeforeRender) then
             FOnBeforeRender(self, FCurrentTime.deltaTime, FCurrentTime.newTime);
             FOnBeforeRender(self, FCurrentTime.deltaTime, FCurrentTime.newTime);
-
           DoRender(ARci, ARenderSelf, Count > 0);
           DoRender(ARci, ARenderSelf, Count > 0);
-
           // Stores Bones matrices of the current frame
           // Stores Bones matrices of the current frame
           if (FStoreBonesMatrix) and (MasterActor.Skeleton <> nil) then
           if (FStoreBonesMatrix) and (MasterActor.Skeleton <> nil) then
             DoStoreBonesMatrices;
             DoStoreBonesMatrices;
@@ -523,7 +524,6 @@ begin
           startframe := sf;
           startframe := sf;
           endframe := ef;
           endframe := ef;
         end;
         end;
-
         ARci.proxySubObject := oldProxySubObject;
         ARci.proxySubObject := oldProxySubObject;
       end;
       end;
     end;
     end;
@@ -584,7 +584,6 @@ begin
           Bmo.BoneIndex := Bone.BoneID;
           Bmo.BoneIndex := Bone.BoneID;
           FBonesMatrices.AddObject(Bone.Name, Bmo);
           FBonesMatrices.AddObject(Bone.Name, Bmo);
         end;
         end;
-
       end;
       end;
     end;
     end;
   end;
   end;
@@ -664,7 +663,6 @@ begin
 
 
     // FORCE ACTOR TO ASSUME ACTORPROXY CURRENT ANIMATION FRAME
     // FORCE ACTOR TO ASSUME ACTORPROXY CURRENT ANIMATION FRAME
     TgxDummyActor(RefActor).DoAnimate();
     TgxDummyActor(RefActor).DoAnimate();
-
     HaspooTransformation := pooTransformation in self.ProxyOptions;
     HaspooTransformation := pooTransformation in self.ProxyOptions;
 
 
     // transform RAYSTART
     // transform RAYSTART
@@ -915,9 +913,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-//-------------------------------------------------------------
-initialization
-//-------------------------------------------------------------
+initialization //-------------------------------------------------------------
 
 
   RegisterClasses([TgxColorProxy, TgxFreeFormProxy, TgxActorProxy,
   RegisterClasses([TgxColorProxy, TgxFreeFormProxy, TgxActorProxy,
     TgxMaterialProxy]);
     TgxMaterialProxy]);

+ 12 - 14
Sourcex/GXS.ROAMPatch.pas

@@ -27,13 +27,13 @@ type
   // Exception use by splitter for SafeTesselation
   // Exception use by splitter for SafeTesselation
   EGLROAMException = class(Exception);
   EGLROAMException = class(Exception);
 
 
-  PROAMTriangleNode = ^TROAMTriangleNode;
-  TROAMTriangleNode = packed record
+  PROAMTriangleNode = ^TgxROAMTriangleNode;
+  TgxROAMTriangleNode = packed record
     Base, Left, Right: PROAMTriangleNode;
     Base, Left, Right: PROAMTriangleNode;
     LeftChild, RightChild: PROAMTriangleNode;
     LeftChild, RightChild: PROAMTriangleNode;
   end;
   end;
 
 
-  TROAMRenderPoint = packed record
+  TgxROAMRenderPoint = packed record
     X, Y: Integer;
     X, Y: Integer;
     Idx: Integer;
     Idx: Integer;
   end;
   end;
@@ -130,9 +130,7 @@ function GetROAMTrianglesCapacity: Integer;
 procedure DrawContours(Vertices: TgAffineVectorList; VertexIndices: TgIntegerList;
 procedure DrawContours(Vertices: TgAffineVectorList; VertexIndices: TgIntegerList;
   ContourInterval: Integer; ContourWidth: Integer; DecVal: Integer);
   ContourInterval: Integer; ContourWidth: Integer; DecVal: Integer);
 
 
-// ------------------------------------------------------------------
-implementation
-// ------------------------------------------------------------------
+implementation // -----------------------------------------------------------
 
 
 var
 var
   FVBOVertHandle, FVBOTexHandle: TgxVBOArrayBufferHandle;
   FVBOVertHandle, FVBOTexHandle: TgxVBOArrayBufferHandle;
@@ -140,7 +138,7 @@ var
 
 
   vNextPatchID: Integer;
   vNextPatchID: Integer;
   vNbTris, vTriangleNodesCapacity: Integer;
   vNbTris, vTriangleNodesCapacity: Integer;
-  vTriangleNodes: array of TROAMTriangleNode;
+  vTriangleNodes: array of TgxROAMTriangleNode;
 
 
   RenderRaster: PSmallIntRaster;
   RenderRaster: PSmallIntRaster;
   RenderIndices: PIntegerArray;
   RenderIndices: PIntegerArray;
@@ -821,9 +819,9 @@ begin
 end;
 end;
 
 
 procedure RecursRender(const tri: PROAMTriangleNode;
 procedure RecursRender(const tri: PROAMTriangleNode;
-  const Left, Right, apex: TROAMRenderPoint);
+  const Left, Right, apex: TgxROAMRenderPoint);
 var
 var
-  half: TROAMRenderPoint;
+  half: TgxROAMRenderPoint;
   LocalIndices: PIntegerArray;
   LocalIndices: PIntegerArray;
 begin
 begin
   if Assigned(tri.LeftChild) then
   if Assigned(tri.LeftChild) then
@@ -849,7 +847,7 @@ end;
 procedure TgxROAMPatch.RenderROAM(Vertices: TgAffineVectorList;
 procedure TgxROAMPatch.RenderROAM(Vertices: TgAffineVectorList;
   VertexIndices: TgIntegerList; TexCoords: TGTexPointList);
   VertexIndices: TgIntegerList; TexCoords: TGTexPointList);
 
 
-  procedure ROAMRenderPoint(var p: TROAMRenderPoint; anX, anY: Integer);
+  procedure ROAMRenderPoint(var p: TgxROAMRenderPoint; anX, anY: Integer);
   begin
   begin
     p.X := anX;
     p.X := anX;
     p.Y := anY;
     p.Y := anY;
@@ -858,7 +856,7 @@ procedure TgxROAMPatch.RenderROAM(Vertices: TgAffineVectorList;
   end;
   end;
 
 
 var
 var
-  rtl, rtr, rbl, rbr: TROAMRenderPoint;
+  rtl, rtr, rbl, rbr: TgxROAMRenderPoint;
 begin
 begin
   RenderVertices := Vertices;
   RenderVertices := Vertices;
   RenderTexCoords := TexCoords;
   RenderTexCoords := TexCoords;
@@ -960,9 +958,7 @@ FVBOVertHandle := TgxVBOArrayBufferHandle.Create;
 FVBOTexHandle := TgxVBOArrayBufferHandle.Create;
 FVBOTexHandle := TgxVBOArrayBufferHandle.Create;
 FVBOIndicesHandle := TgxVBOElementArrayHandle.Create;
 FVBOIndicesHandle := TgxVBOElementArrayHandle.Create;
 
 
-//---------------------------------------
-finalization
-//---------------------------------------
+finalization //-------------------------------------------------------------
 
 
 FVBOVertHandle.Free;
 FVBOVertHandle.Free;
 FVBOTexHandle.Free;
 FVBOTexHandle.Free;
@@ -970,4 +966,6 @@ FVBOIndicesHandle.Free;
 
 
 SetROAMTrianglesCapacity(0);
 SetROAMTrianglesCapacity(0);
 
 
+// -------------------------------------------------------------------------
+
 end.
 end.

+ 3 - 3
Sourcex/GXS.Ragdoll.pas

@@ -107,9 +107,7 @@ type
     property Enabled : Boolean read FEnabled;
     property Enabled : Boolean read FEnabled;
 	end;
 	end;
 
 
-//-----------------------------------------------------------------------
-implementation
-//-----------------------------------------------------------------------
+implementation //-------------------------------------------------------------
 
 
 //--------------------------------
 //--------------------------------
 // TgxRagdolBoneList
 // TgxRagdolBoneList
@@ -386,4 +384,6 @@ begin
   FBuilt := True;
   FBuilt := True;
 end;
 end;
 
 
+//-----------------------------------------------------------------------
+
 end.
 end.

+ 6 - 8
Sourcex/GXS.RandomHDS.pas

@@ -202,8 +202,10 @@ type
     property LightSmoothing: boolean read FLightSmoothing write SetLightSmoothing;
     property LightSmoothing: boolean read FLightSmoothing write SetLightSmoothing;
     (* Not used *)
     (* Not used *)
     property MaterialName: string read FMaterialName write SetMaterialName;
     property MaterialName: string read FMaterialName write SetMaterialName;
-    { If true, the height-field will not be emptied and generation will take the
-      existing heights to shape the new landscape }
+    (*
+      If true, the height-field will not be emptied and generation will take the
+      existing heights to shape the new landscape
+    *)
     property PrimerLandscape: boolean read FPrimerLandscape write SetPrimerLandscape;
     property PrimerLandscape: boolean read FPrimerLandscape write SetPrimerLandscape;
     // Enable the sea surface truncation
     // Enable the sea surface truncation
     property Sea: boolean read FSea write SetSea;
     property Sea: boolean read FSea write SetSea;
@@ -604,9 +606,7 @@ procedure PrimerIsland(LowZ, HighZ: single; var z: TMapOfSingle);
 const
 const
   VerticalScalingFactor = 128;
   VerticalScalingFactor = 128;
 
 
-// ==========================================================================
-implementation
-// ==========================================================================
+implementation //-------------------------------------------------------------
 
 
 const // Neighbourhood vectors and weight
 const // Neighbourhood vectors and weight
   NeighX: array [0 .. 8] of integer = (-1, 0, 1, 1, 1, 0, -1, -1, 0);
   NeighX: array [0 .. 8] of integer = (-1, 0, 1, 1, 1, 0, -1, -1, 0);
@@ -3116,9 +3116,7 @@ begin
   end; // for i
   end; // for i
 end;
 end;
 
 
-//----------------------------------------------
-initialization
-//----------------------------------------------
+initialization //-------------------------------------------------------------
 
 
 rhdsStartTime := GetTickCount;
 rhdsStartTime := GetTickCount;
 
 

+ 0 - 788
Sourcex/GXS.RedBlackTree.pas

@@ -1,788 +0,0 @@
-//
-// The graphics engine GXScene https://github.com/glscene
-//
-unit GXS.RedBlackTree;
-
-(*
-  USAGE
-  The TRedBlackTree generic class behaves somewhat like a TList:
-  it stores _Value_ by _Key_
-  and uses the same comparison function as TList.Sort (TListSortCompare).
-  Functions Clear, Add, Delete, First and Last are equivalent,
-  except that First and Last return a _Key_ so they
-  can be used for comparisons in loops.
-
-  All _Key_ occur only once in the tree if DuplicateKeys is False:
-  when the same value is added twice, the second one is not stored.
-
-  When DuplicateKeys is enabled the second comparison function is used
-  for sort _Value_ and it duplicates not allowed.
-
-  To be able to manage the tree, the Create constructor has an argument
-  specifying the comparison function that should be used.
-
-  The function Find can be used to find a _Value_ that was put in the tree,
-  it searches for the given _Key_ using the comparison function given
-  at time of object creation.
-
-  The functions NextKey and PrevKey can be used to "walk" through the tree:
-  given a _Key_, NextKey replace it with the smallest key that
-  is larger than _Key_, PrevKey returns the largest key that is
-  smaller than _Key_. For Last and First key result not returned.
-*)
-
-interface
-
-{$I GLScene.Defines.inc}
-
-uses
-  System.Classes;
-
-type
-
-  TRBColor = (clRed, clBlack);
-
-{$IFDEF GENERIC_PREFIX}
-  generic
-{$ENDIF}
-  GRedBlackTree < TKey, TValue > = class
-  public
-    type
-      TKeyCompareFunc = function(const Item1, Item2: TKey): Integer;
-      TValueCompareFunc = function(const Item1, Item2: TValue): Boolean;
-      TForEachProc = procedure (AKey: TKey; AValue: TValue; out AContinue: Boolean);
-      TRBNode = class
-         Key: TKey;
-         Left, Right, Parent, Twin: TRBNode;
-         Color: TRBColor;
-         Value: TValue;
-      end;
-    var
-      FRoot: TRBNode;
-      FLeftmost: TRBNode;
-      FRightmost: TRBNode;
-      FLastFound: TRBNode;
-      FLastNode: TRBNode;
-      FCount: Integer;
-      FKeyCompareFunc: TKeyCompareFunc;
-      FDuplicateKeys: Boolean;
-      FValueCompareFunc: TValueCompareFunc;
-      FOnChange: TNotifyEvent;
-    function FindNode(const key: TKey): TRBNode;
-    procedure RotateLeft(var x: TRBNode);
-    procedure RotateRight(var x: TRBNode);
-    function Minimum(var x: TRBNode): TRBNode;
-    function Maximum(var x: TRBNode): TRBNode;
-    function GetFirst: TKey;
-    function GetLast: TKey;
-    procedure SetDuplicateKeys(Value: Boolean);
-    class procedure FastErase(x: TRBNode);
-  public
-    constructor Create(KeyCompare: TKeyCompareFunc; ValueCompare: TValueCompareFunc);
-    destructor Destroy; override;
-    procedure Clear;
-    // Find value by key.
-    function Find(const key: TKey; out Value: TValue): Boolean;
-    function NextKey(var key: TKey; out Value: TValue): Boolean;
-    function PrevKey(var key: TKey; out Value: TValue): Boolean;
-    function NextDublicate(out Value: TValue): Boolean;
-    procedure Add(const key: TKey; const Value: TValue);
-    procedure Delete(const key: TKey);
-    procedure ForEach(AProc: TForEachProc);
-    property Count: Integer read FCount;
-    property First: TKey read GetFirst;
-    property Last: TKey read GetLast;
-    property DuplicateKeys: Boolean read FDuplicateKeys write SetDuplicateKeys;
-    property OnChange: TNotifyEvent read FOnChange write FOnChange;
-  end;
-
-function CompareInteger(const Item1, Item2: Integer): Integer;
-
-//---------------------------------------------------------------------
-implementation
-//---------------------------------------------------------------------
-
-function CompareInteger(const Item1, Item2: Integer): Integer;
-begin
-  if Item1 < Item2 then
-  begin
-    Result := -1;
-  end
-  else if (Item1 = Item2) then
-  begin
-    Result := 0;
-  end
-  else
-  begin
-    Result := 1;
-  end
-end;
-
-constructor GRedBlackTree
-< TKey, TValue >.Create(KeyCompare: TKeyCompareFunc; ValueCompare: TValueCompareFunc);
-begin
-  inherited Create;
-  Assert(Assigned(KeyCompare));
-  FKeyCompareFunc := KeyCompare;
-  FValueCompareFunc := ValueCompare;
-  FRoot := nil;
-  FLeftmost := nil;
-  FRightmost := nil;
-  FDuplicateKeys := Assigned(ValueCompare);
-end;
-
-destructor GRedBlackTree < TKey, TValue >.Destroy;
-begin
-  Clear;
-  inherited Destroy;
-end;
-
-class procedure GRedBlackTree < TKey, TValue >.FastErase(x: TRBNode);
-var
-  y: TRBNode;
-begin
-  if (x.left <> nil) then
-    FastErase(x.left);
-  if (x.right <> nil) then
-    FastErase(x.right);
-  repeat
-    y := x;
-    x := x.Twin;
-    y.Destroy;
-  until x = nil;
-end;
-
-procedure GRedBlackTree < TKey, TValue >.Clear;
-begin
-  if (FRoot <> nil) then
-    FastErase(FRoot);
-  FRoot := nil;
-  FLeftmost := nil;
-  FRightmost := nil;
-  FCount := 0;
-  if Assigned(FOnChange) then
-    FOnChange(Self);
-end;
-
-function GRedBlackTree< TKey, TValue >.Find(const key: TKey;
-  out Value: TValue): Boolean;
-begin
-  FLastFound := FindNode(key);
-  Result := Assigned(FLastFound);
-  if Result then
-    Value := FLastFound.Value;
-end;
-
-function GRedBlackTree
-< TKey, TValue >.FindNode(const key: TKey): TRBNode;
-var
-  cmp: integer;
-begin
-  Result := FRoot;
-  while (Result <> nil) do
-  begin
-    cmp := FKeyCompareFunc(Result.Key, key);
-    if cmp < 0 then
-    begin
-      Result := Result.right;
-    end
-    else if cmp > 0 then
-    begin
-      Result := Result.left;
-    end
-    else
-    begin
-      break;
-    end;
-  end;
-end;
-
-function GRedBlackTree < TKey, TValue >.NextDublicate(out Value: TValue): Boolean;
-begin
-  if Assigned(FLastFound) then
-  begin
-    if Assigned(FLastFound.Twin) then
-    begin
-      FLastFound := FLastFound.Twin;
-      Value := FLastFound.Value;
-      exit(True);
-    end;
-  end;
-  Result := False;
-end;
-
-procedure GRedBlackTree < TKey, TValue >.RotateLeft(var x: TRBNode);
-var
-  y: TRBNode;
-begin
-  y := x.right;
-  x.right := y.left;
-  if (y.left <> nil) then
-  begin
-    y.left.parent := x;
-  end;
-  y.parent := x.parent;
-  if (x = FRoot) then
-  begin
-    FRoot := y;
-  end
-  else if (x = x.parent.left) then
-  begin
-    x.parent.left := y;
-  end
-  else
-  begin
-    x.parent.right := y;
-  end;
-  y.left := x;
-  x.parent := y;
-end;
-
-procedure GRedBlackTree < TKey, TValue >.RotateRight(var x: TRBNode);
-var
-  y: TRBNode;
-begin
-  y := x.left;
-  x.left := y.right;
-  if (y.right <> nil) then
-  begin
-    y.right.parent := x;
-  end;
-  y.parent := x.parent;
-  if (x = FRoot) then
-  begin
-    FRoot := y;
-  end
-  else if (x = x.parent.right) then
-  begin
-    x.parent.right := y;
-  end
-  else
-  begin
-    x.parent.left := y;
-  end;
-  y.right := x;
-  x.parent := y;
-end;
-
-function GRedBlackTree
-< TKey, TValue >.Minimum(var x: TRBNode): TRBNode;
-begin
-  Result := x;
-  while (Result.left <> nil) do
-    Result := Result.left;
-end;
-
-function GRedBlackTree
-< TKey, TValue >.Maximum(var x: TRBNode): TRBNode;
-begin
-  Result := x;
-  while (Result.right <> nil) do
-    Result := Result.right;
-end;
-
-procedure GRedBlackTree < TKey, TValue >.Add(const key: TKey; const Value: TValue);
-var
-  x, y, z, zpp: TRBNode;
-  cmp: Integer;
-begin
-  z := TRBNode.Create;
-
-  { Initialize fields in new node z }
-  z.Key := key;
-  z.left := nil;
-  z.right := nil;
-  z.color := clRed;
-  z.Value := Value;
-  z.Twin := nil;
-
-  { Maintain FLeftmost and FRightmost nodes }
-  if ((FLeftmost = nil) or (FKeyCompareFunc(key, FLeftmost.Key) < 0)) then
-  begin
-    FLeftmost := z;
-  end;
-  if ((FRightmost = nil) or (FKeyCompareFunc(FRightmost.Key, key) < 0)) then
-  begin
-    FRightmost := z;
-  end;
-
-  { Insert node z }
-  y := nil;
-  x := FRoot;
-  while (x <> nil) do
-  begin
-    y := x;
-    cmp := FKeyCompareFunc(key, x.Key);
-    if cmp < 0 then
-      x := x.left
-    else if cmp > 0 then
-      x := x.right
-    else
-    begin
-      { Key already exists in tree. }
-      if FDuplicateKeys then
-      begin
-        { Check twins chain for value dublicate. }
-        repeat
-          if FValueCompareFunc(Value, x.Value) then
-          begin
-            y := nil;
-            break;
-          end;
-          y := x;
-          x := x.Twin;
-        until x = nil;
-        if Assigned(y) then
-        begin
-          { Add dublicate key to end of twins chain. }
-          y.Twin := z;
-          Inc(FCount);
-          if Assigned(FOnChange) then
-            FOnChange(Self);
-          exit;
-        end;
-        // Value already exists in tree.
-      end;
-      z.Destroy;
-      //a jzombi: memory leak: if we don't put it in the tree, we shouldn't hold it in the memory
-      exit;
-    end;
-  end;
-  z.parent := y;
-  if (y = nil) then
-  begin
-    FRoot := z;
-  end
-  else if (FKeyCompareFunc(key, y.Key) < 0) then
-  begin
-    y.left := z;
-  end
-  else
-  begin
-    y.right := z;
-  end;
-
-  { Rebalance tree }
-  while ((z <> FRoot) and (z.parent.color = clRed)) do
-  begin
-    zpp := z.parent.parent;
-    if (z.parent = zpp.left) then
-    begin
-      y := zpp.right;
-      if ((y <> nil) and (y.color = clRed)) then
-      begin
-        z.parent.color := clBlack;
-        y.color := clBlack;
-        zpp.color := clRed;
-        z := zpp;
-      end
-      else
-      begin
-        if (z = z.parent.right) then
-        begin
-          z := z.parent;
-          rotateLeft(z);
-        end;
-        z.parent.color := clBlack;
-        zpp.color := clRed;
-        rotateRight(zpp);
-      end;
-    end
-    else
-    begin
-      y := zpp.left;
-      if ((y <> nil) and (y.color = clRed)) then
-      begin
-        z.parent.color := clBlack;
-        y.color := clBlack;
-        zpp.color := clRed; //c jzombi: zpp.color := clRed;
-        z := zpp;
-      end
-      else
-      begin
-        if (z = z.parent.left) then
-        begin
-          z := z.parent;
-          rotateRight(z);
-        end;
-        z.parent.color := clBlack;
-        zpp.color := clRed; //c jzombi: zpp.color := clRed;
-        rotateLeft(zpp);
-      end;
-    end;
-  end;
-  FRoot.color := clBlack;
-  Inc(FCount);
-  if Assigned(FOnChange) then
-    FOnChange(Self);
-end;
-
-procedure GRedBlackTree
-< TKey, TValue >.Delete(const key: TKey);
-var
-  w, x, y, z, x_parent: TRBNode;
-  tmpcol: TRBColor;
-begin
-  z := FindNode(key);
-  if z = nil then
-    exit;
-
-  y := z;
-  x := nil;
-  x_parent := nil;
-
-  if (y.left = nil) then
-  begin // z has at most one non-null child. y = z.
-    x := y.right; // x might be null.
-  end
-  else
-  begin
-    if (y.right = nil) then
-    begin // z has exactly one non-null child. y = z.
-      x := y.left; // x is not null.
-    end
-    else
-    begin
-      // z has two non-null children.  Set y to
-      y := y.right; //   z's successor.  x might be null.
-      while (y.left <> nil) do
-      begin
-        y := y.left;
-      end;
-      x := y.right;
-    end;
-  end;
-
-  if (y <> z) then
-  begin
-    (* "copy y's sattelite data into z"
-      relink y in place of z.  y is z's successor *)
-    z.left.parent := y;
-    y.left := z.left;
-    if (y <> z.right) then
-    begin
-      x_parent := y.parent;
-      if (x <> nil) then
-      begin
-        x.parent := y.parent;
-      end;
-      y.parent.left := x; // y must be a child of left
-      y.right := z.right;
-      z.right.parent := y;
-    end
-    else
-    begin
-      x_parent := y;
-    end;
-    if (FRoot = z) then
-    begin
-      FRoot := y;
-    end
-    else if (z.parent.left = z) then
-    begin
-      z.parent.left := y;
-    end
-    else
-    begin
-      z.parent.right := y;
-    end;
-    y.parent := z.parent;
-    tmpcol := y.color;
-    y.color := z.color;
-    z.color := tmpcol;
-    y := z;
-    // y now points to node to be actually deleted
-  end
-  else
-  begin // y = z
-    x_parent := y.parent;
-    if (x <> nil) then
-    begin
-      x.parent := y.parent;
-    end;
-    if (FRoot = z) then
-    begin
-      FRoot := x;
-    end
-    else
-    begin
-      if (z.parent.left = z) then
-      begin
-        z.parent.left := x;
-      end
-      else
-      begin
-        z.parent.right := x;
-      end;
-    end;
-    if (FLeftmost = z) then
-    begin
-      if (z.right = nil) then
-      begin // z.left must be null also
-        FLeftmost := z.parent;
-      end
-      else
-      begin
-        FLeftmost := minimum(x);
-      end;
-    end;
-    if (FRightmost = z) then
-    begin
-      if (z.left = nil) then
-      begin // z.right must be null also
-        FRightmost := z.parent;
-      end
-      else
-      begin // x == z.left
-        FRightmost := maximum(x);
-      end;
-    end;
-  end;
-
-  // Rebalance tree
-  if (y.color = clBlack) then
-  begin
-    while ((x <> FRoot) and ((x = nil) or (x.color = clBlack))) do
-    begin
-      if (x = x_parent.left) then
-      begin
-        w := x_parent.right;
-        if (w.color = clRed) then
-        begin
-          w.color := clBlack;
-          x_parent.color := clRed;
-          rotateLeft(x_parent);
-          w := x_parent.right;
-        end;
-        if (((w.left = nil) or
-          (w.left.color = clBlack)) and
-          ((w.right = nil) or
-          (w.right.color = clBlack))) then
-        begin
-          w.color := clRed;
-          x := x_parent;
-          x_parent := x_parent.parent;
-        end
-        else
-        begin
-          if ((w.right = nil) or (w.right.color = clBlack)) then
-          begin
-            w.left.color := clBlack;
-            w.color := clRed;
-            rotateRight(w);
-            w := x_parent.right;
-          end;
-          w.color := x_parent.color;
-          x_parent.color := clBlack;
-          if (w.right <> nil) then
-          begin
-            w.right.color := clBlack;
-          end;
-          rotateLeft(x_parent);
-          x := FRoot; { break; }
-        end
-      end
-      else
-      begin
-        { same as above, with right <. left. }
-        w := x_parent.left;
-        if (w.color = clRed) then
-        begin
-          w.color := clBlack;
-          x_parent.color := clRed;
-          rotateRight(x_parent);
-          w := x_parent.left;
-        end;
-        if (((w.right = nil) or
-          (w.right.color = clBlack)) and
-          ((w.left = nil) or
-          (w.left.color = clBlack))) then
-        begin
-          w.color := clRed;
-          x := x_parent;
-          x_parent := x_parent.parent;
-        end
-        else
-        begin
-          if ((w.left = nil) or (w.left.color = clBlack)) then
-          begin
-            w.right.color := clBlack;
-            w.color := clRed;
-            rotateLeft(w);
-            w := x_parent.left;
-          end;
-          w.color := x_parent.color;
-          x_parent.color := clBlack;
-          if (w.left <> nil) then
-          begin
-            w.left.color := clBlack;
-          end;
-          rotateRight(x_parent);
-          x := FRoot; // break;
-        end;
-      end;
-    end;
-    if (x <> nil) then
-    begin
-      x.color := clBlack;
-    end;
-  end;
-  while Assigned(y.Twin) do
-  begin
-    z := y;
-    y := y.Twin;
-    z.Destroy;
-  end;
-  y.Destroy;
-  Dec(FCount);
-  if Assigned(FOnChange) then
-    FOnChange(Self);
-end;
-
-function GRedBlackTree
-< TKey, TValue >.NextKey(var key: TKey; out Value: TValue): Boolean;
-var
-  x, y: TRBNode;
-begin
-  if Assigned(FLastNode) and (FKeyCompareFunc(FLastNode.Key, key) = 0) then
-    x := FLastNode
-  else
-    x := FindNode(key);
-  if x = nil then
-    exit;
-  if (x.right <> nil) then
-  begin
-    x := x.right;
-    while (x.left <> nil) do
-    begin
-      x := x.left;
-    end;
-  end
-  else if (x.parent <> nil) then
-  begin
-    y := x.parent;
-    while Assigned(y) and (x = y.right) do
-    begin
-      x := y;
-      y := y.parent;
-    end;
-    if (x.right <> y) then
-      x := y;
-  end
-  else
-    x := FRoot;
-  if x = nil then
-    exit(False);
-  key := x.Key;
-  FLastNode := x;
-  Value := x.Value;
-  Result := True;
-end;
-
-function GRedBlackTree
-< TKey, TValue >.PrevKey(var key: TKey; out Value: TValue): Boolean;
-var
-  x, y: TRBNode;
-begin
-  if Assigned(FLastNode) and (FKeyCompareFunc(FLastNode.Key, key) = 0) then
-    x := FLastNode
-  else
-    x := FindNode(key);
-  if x = nil then
-    exit(False);
-  if (x.left <> nil) then
-  begin
-    y := x.left;
-    while (y.right <> nil) do
-    begin
-      y := y.right;
-    end;
-    x := y;
-  end
-  else if (x.parent <> nil) then
-  begin
-    y := x.parent;
-    while (x = y.left) do
-    begin
-      x := y;
-      y := y.parent;
-    end;
-    x := y;
-  end
-  else
-    x := FRoot;
-  if x = nil then
-    exit(False);
-  key := x.Key;
-  FLastNode := x;
-  Value := x.Value;
-  Result := True;
-end;
-
-function GRedBlackTree
-< TKey, TValue >.GetFirst: TKey;
-begin
-  Result := FLeftMost.Key;
-end;
-
-function GRedBlackTree
-< TKey, TValue >.GetLast: TKey;
-begin
-  Result := FRightMost.Key;
-end;
-
-procedure GRedBlackTree
-< TKey, TValue >.ForEach(AProc: TForEachProc);
-var
-  x, y, z: TRBNode;
-  cont: Boolean;
-begin
-  if Assigned(FLeftMost) then
-  begin
-    x := FLeftMost;
-    repeat
-      z := x;
-      repeat
-        AProc(z.Key, z.Value, cont);
-        if not cont then
-          exit;
-        z := z.Twin;
-      until z = nil;
-      // Next node
-      if (x.right <> nil) then
-      begin
-        x := x.right;
-        while (x.left <> nil) do
-        begin
-          x := x.left;
-        end;
-      end
-      else if (x.parent <> nil) then
-      begin
-        y := x.parent;
-        while (x = y.right) do
-        begin
-          x := y;
-          y := y.parent;
-        end;
-        if (x.right <> y) then
-          x := y;
-      end
-      else
-        x := FRoot;
-    until x = FRightMost;
-    if cont and (FLeftMost <> FRightMost) then
-      AProc(FRightMost.Key, FRightMost.Value, cont);
-  end;
-end;
-
-procedure GRedBlackTree
-< TKey, TValue >.SetDuplicateKeys(Value: Boolean);
-begin
-  if Value and Assigned(FValueCompareFunc) then
-    FDuplicateKeys := True
-  else
-    FDuplicateKeys := False;
-end;
-
-end.

+ 13 - 16
Sourcex/GXS.SceneViewer.pas

@@ -28,7 +28,7 @@ uses
   GXS.WinContext;
   GXS.WinContext;
 
 
 type
 type
-  TCreateParams = record
+  TgxCreateParams = record
     Caption: PChar;
     Caption: PChar;
     Style: DWORD;
     Style: DWORD;
     ExStyle: DWORD;
     ExStyle: DWORD;
@@ -40,7 +40,8 @@ type
     WinClassName: array[0..63] of Char;
     WinClassName: array[0..63] of Char;
   end;
   end;
 
 
-  TTouchEvent = procedure(X, Y, TouchWidth, TouchHeight : integer; TouchID : Cardinal; MultiTouch : boolean) of object;
+  TgxTouchEvent = procedure(X, Y, TouchWidth, TouchHeight : integer;
+    TouchID : Cardinal; MultiTouch : boolean) of object;
 
 
   (* Component where the GLScene objects get rendered.
   (* Component where the GLScene objects get rendered.
      This component delimits the area where OpenGL renders the scene,
      This component delimits the area where OpenGL renders the scene,
@@ -60,9 +61,9 @@ type
     FMouseInControl: Boolean;
     FMouseInControl: Boolean;
     FLastScreenPos: TPoint;
     FLastScreenPos: TPoint;
     FPenAsTouch: boolean;
     FPenAsTouch: boolean;
-    FOnTouchMove: TTouchEvent;
-    FOnTouchUp: TTouchEvent;
-    FOnTouchDown: TTouchEvent;
+    FOnTouchMove: TgxTouchEvent;
+    FOnTouchUp: TgxTouchEvent;
+    FOnTouchDown: TgxTouchEvent;
     procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
     procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
     procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
     procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
     procedure WMSize(var Message: TWMSize); message WM_SIZE;
     procedure WMSize(var Message: TWMSize); message WM_SIZE;
@@ -86,7 +87,7 @@ type
     procedure SetCamera(const val: TgxCamera);
     procedure SetCamera(const val: TgxCamera);
     function GetCamera: TgxCamera;
     function GetCamera: TgxCamera;
     procedure SetBuffer(const val: TgxSceneBuffer);
     procedure SetBuffer(const val: TgxSceneBuffer);
-    procedure CreateParams(var Params: TCreateParams); /// Vcl - override;
+    procedure CreateParams(var Params: TgxCreateParams); /// Vcl - override;
     procedure CreateWnd; /// Vcl - override;
     procedure CreateWnd; /// Vcl - override;
     procedure DestroyWnd; /// Vcl - override;
     procedure DestroyWnd; /// Vcl - override;
     procedure Loaded; override;
     procedure Loaded; override;
@@ -143,9 +144,9 @@ type
     property PenAsTouch: boolean read FPenAsTouch write FPenAsTouch;
     property PenAsTouch: boolean read FPenAsTouch write FPenAsTouch;
     property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
     property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
     property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
     property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
-    property OnTouchMove: TTouchEvent read FOnTouchMove write FOnTouchMove;
-    property OnTouchUp: TTouchEvent read FOnTouchUp write FOnTouchUp;
-    property OnTouchDown: TTouchEvent read FOnTouchDown write FOnTouchDown;
+    property OnTouchMove: TgxTouchEvent read FOnTouchMove write FOnTouchMove;
+    property OnTouchUp: TgxTouchEvent read FOnTouchUp write FOnTouchUp;
+    property OnTouchDown: TgxTouchEvent read FOnTouchDown write FOnTouchDown;
     property Align;
     property Align;
     property Anchors;
     property Anchors;
 ///    property DragCursor;
 ///    property DragCursor;
@@ -183,9 +184,7 @@ procedure SetupVSync(const AVSyncMode : TgxSyncMode);
 var
 var
  Handle: HWND;
  Handle: HWND;
 
 
-// ------------------------------------------------------------------
-implementation
-// ------------------------------------------------------------------
+implementation // -----------------------------------------------------------
 
 
 // ------------------
 // ------------------
 // ------------------ TgxSceneViewerFMX ------------------
 // ------------------ TgxSceneViewerFMX ------------------
@@ -304,7 +303,7 @@ begin
   FBuffer.Assign(val);
   FBuffer.Assign(val);
 end;
 end;
 
 
-procedure TgxSceneViewer.CreateParams(var Params: TCreateParams);
+procedure TgxSceneViewer.CreateParams(var Params: TgxCreateParams);
 begin
 begin
   inherited;  /// Vcl -  inherited CreateParams(Params);
   inherited;  /// Vcl -  inherited CreateParams(Params);
   with Params do
   with Params do
@@ -554,9 +553,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-// ------------------------------------------------------------------
-initialization
-// ------------------------------------------------------------------
+initialization // ------------------------------------------------------------
 
 
   RegisterClass(TgxSceneViewer);
   RegisterClass(TgxSceneViewer);
 
 

+ 1 - 3
Sourcex/GXS.Screen.pas

@@ -334,9 +334,7 @@ begin
   Result := Trunc(Screen.Height);
   Result := Trunc(Screen.Height);
 end;
 end;
 
 
-// ------------------------------------------------------------------
-initialization
-// ------------------------------------------------------------------
+initialization // -----------------------------------------------------------
 
 
 finalization
 finalization
 
 

+ 5 - 7
Sourcex/GXS.ScriptBase.pas

@@ -89,9 +89,7 @@ type
     property Scripts: TgxScripts read FScripts;
     property Scripts: TgxScripts read FScripts;
   end;
   end;
 
 
-// ------------------------------------------
-implementation
-// ------------------------------------------
+implementation // ------------------------------------------------------------
 
 
 // ---------------
 // ---------------
 // --------------- TgxScriptBase ---------------
 // --------------- TgxScriptBase ---------------
@@ -249,11 +247,11 @@ begin
   inherited;
   inherited;
 end;
 end;
 
 
-// -------------------------------------
-initialization
-
-// -------------------------------------
+initialization //----------------------------------------------------------
 
 
 RegisterClasses([TgxScriptLibrary, TgxScripts, TgxScriptBase]);
 RegisterClasses([TgxScriptLibrary, TgxScripts, TgxScriptBase]);
 
 
+//-------------------------------------------------------------------------
+
+
 end.
 end.

+ 265 - 0
Sourcex/GXS.SmartObjects.pas

@@ -0,0 +1,265 @@
+//
+// The graphics engine GLScene https://github.com/glscene
+//
+unit GXS.SmartObjects;
+
+(*
+  The objects that have built-in properties and methods to support sound, vision,
+  physics, and finding shortest paths through mezza obstacles, hightfields or terrains. 
+  They should have AI to conduct dialogues and make independent decisions. 
+  The smart spatial objects are used to interact with other smart objects and cyborgs.
+
+  The registered classes:
+   [TGLSmartGerm, TGLSmartCells, TGLSmartSwarm, TGLSmartNet, TgxCyborg, TgxCyborgs]
+*)
+
+interface
+
+{$I GLScene.Defines.inc}
+
+uses
+  Winapi.OpenGL,
+  Winapi.OpenGLext,
+  System.Classes,
+  System.SysUtils,
+  System.Types,
+  System.Math,
+
+  GLScene.OpenGLTokens,
+  GLScene.VectorTypes,
+  GLScene.PersistentClasses,
+  GLScene.VectorGeometry,
+  GLScene.VectorTypesExt,
+  GLScene.VectorLists,
+  GLScene.BaseClasses,
+  GLScene.PipelineTransform,
+  GLScene.Coordinates,
+  GLScene.GeometryBB,
+  GLScene.Color,
+  GLScene.Strings,
+
+  GXS.Scene,
+  GXS.Silhouette,
+  GXS.Texture,
+  GXS.Material,
+  GXS.Mesh,
+  GXS.Octree,
+  GXS.Objects,
+  GXS.GeomObjects,
+  GXS.ApplicationFileIO,
+  GXS.Context,
+  GXS.Selection,
+  GXS.RenderContextInfo,
+  GXS.VectorFileObjects,
+  GXS.SoundManager,
+  GXS.SoundFileObjects;
+
+
+type
+
+  TgxSmartSwarmMode = (isNone, isRandom, isTetra, isGrid);
+
+  TgxCyborgReference = (crNone, crWeak, crStrong);
+  TgxCyborgThinkMode = (ctmSelf, ctmSleep, ctmOutside, ctmZombie, ctmDeath);
+
+  TgxCyborgOption = (coCollide, coContact, coJoin);
+  TgxCyborgSenceOrgans = (csoVision, csoHearing, csoSmell, csoTouch, taste);
+
+  TgxCyborgOptions = set of TgxCyborgOption;
+  TgxCyborgThinks = class(TCollection);
+
+  // A list of thinking periods for TgxCyborgThinkMode
+  TgxCyborgThinksList = class(TgPersistentObjectList);
+
+const
+  cDefaultCyborgOptions = [coCollide];
+
+type
+  (* The Cyborg class specialized as a smart actor with AI.
+    The TgxCyborg  provides a quick interface to animated actors based on morph
+    or skeleton frames, it is capable of performing frame interpolation and
+    thinking blending (via TGLThinkingController components). *)
+  TgxCyborg = class(TgxActor)
+  private
+    FBirthTime, FDeathTime: TDateTime;
+    FReference: TgxCyborgReference;
+    FThinkMode: TgxCyborgThinkMode;
+    FControlers: TList;
+    FInterval: Integer;
+    FOptions: TgxCyborgOptions;
+    FThinkings: TgxCyborgThinks;
+  protected
+    procedure SetReference(val: TgxCyborgReference);
+    procedure SetThinking(const val: TgxCyborgThinkMode);
+    function StoreThinking: Boolean;
+    procedure SetOptions(const val: TgxCyborgOptions);
+    procedure DoThink; virtual;
+  public
+    constructor Create(aOwner: TComponent); override;
+    destructor Destroy; override;
+    procedure Assign(Source: TPersistent); override;
+    procedure BuildList(var rci: TgxRenderContextInfo); override;
+    procedure DoProgress(const progressTime: TGProgressTimes); override;
+    procedure LoadFromStream(const Filename: string; aStream: TStream); override;
+    procedure SwitchToThinking(anThinking: TgxCyborgThinks; smooth: Boolean = False);
+    function CurrentThinking: string;
+    // Indicates whether the cyborg is currently thinking
+    function IsThinking: Boolean;
+  published
+    // See TgxCyborgThinkMode.
+    property ThinkingMode: TgxCyborgThinkMode read FThinkMode
+	  write FThinkMode default ctmSelf;
+    // Reference Frame Animation mode. Allows specifying if the model is primarily morph or skeleton based
+    property SmartReference: TgxCyborgReference read FReference
+      write FReference default crNone;
+
+    // Interval between thinking frames, in milliseconds.
+    property Interval: Integer read FInterval write FInterval;
+    // Cyborg and thinking miscellanious options.
+    property Options: TgxCyborgOptions read FOptions write SetOptions default cDefaultCyborgOptions;
+    // Collection of thinking sequences.
+    ///property Thinkings: TgxCyborgThinks read FThinkings write SetThinking stored StoreThinking;
+  end;
+
+  (*
+     Synchronize self thinking with an other thinkers in the swarm
+     Copies Ai/Current/End values,ThinkingMode and GridInterpolation.
+     procedure Synchronize(IntelSwarm: TGLIntelSwarm);
+   *)
+  TgxSwartSwarm = class(TgxPoints)
+  private
+    FBirthTime, FDeathTime: TDateTime;
+    FReference: TgxCyborgReference;
+    FThinkMode: TgxSmartSwarmMode;
+  public
+    constructor Create(aOwner: TComponent); override;
+    destructor Destroy; override;
+    procedure Assign(Source: TPersistent); override;
+  published
+    property ThinkingMode: TgxSmartSwarmMode read FThinkMode;
+  end;
+
+var
+  vGLSmartObjectsAllocate: Boolean = True;
+  vGLSmartObjectsEnableByDefault: Boolean = True;
+
+implementation // ----------------------------------------------------------
+
+var
+  vCyborgsFileFormat: TgxCyborgThinksList;
+  vNextRenderGroupID: Integer = 1;
+
+
+// ------------------------------------------------------------------
+{ TgxCyborg }
+
+procedure TgxCyborg.Assign(Source: TPersistent);
+begin
+  inherited;
+//
+end;
+
+procedure TgxCyborg.BuildList(var rci: TgxRenderContextInfo);
+begin
+  inherited;
+//
+end;
+
+constructor TgxCyborg.Create(aOwner: TComponent);
+begin
+  inherited;
+//
+end;
+
+function TgxCyborg.CurrentThinking: string;
+begin
+//
+end;
+
+destructor TgxCyborg.Destroy;
+begin
+//
+  inherited;
+end;
+
+procedure TgxCyborg.DoProgress(const progressTime: TGProgressTimes);
+begin
+  inherited;
+//
+end;
+
+procedure TgxCyborg.DoThink;
+begin
+//
+end;
+
+function TgxCyborg.IsThinking: Boolean;
+begin
+//
+end;
+
+procedure TgxCyborg.LoadFromStream(const Filename: string; aStream: TStream);
+begin
+  inherited;
+//
+end;
+
+procedure TgxCyborg.SetOptions(const val: TgxCyborgOptions);
+begin
+//
+end;
+
+procedure TgxCyborg.SetReference(val: TgxCyborgReference);
+begin
+//
+end;
+
+procedure TgxCyborg.SetThinking(const val: TgxCyborgThinkMode);
+begin
+//
+end;
+
+
+function TgxCyborg.StoreThinking: Boolean;
+begin
+//
+end;
+
+procedure TgxCyborg.SwitchToThinking(anThinking: TgxCyborgThinks; smooth: Boolean);
+begin
+//
+end;
+
+
+// ------------------------------------------------------------------
+{ TgxSwartSwarm }
+
+procedure TgxSwartSwarm.Assign(Source: TPersistent);
+begin
+  inherited;
+  //
+end;
+
+constructor TgxSwartSwarm.Create(aOwner: TComponent);
+begin
+  inherited;
+  //
+end;
+
+destructor TgxSwartSwarm.Destroy;
+begin
+  //
+  inherited;
+end;
+
+initialization
+// ------------------------------------------------------------------
+
+  RegisterClasses([TgxCyborg (*, TGLSmartSwarm*)]);
+
+finalization
+
+FreeAndNil(vCyborgsFileFormat);
+
+end.
+

+ 41 - 45
Sourcex/GXS.Sound.pas → Sourcex/GXS.SoundManager.pas

@@ -1,32 +1,31 @@
 //
 //
 // The graphics engine GXScene https://github.com/glscene
 // The graphics engine GXScene https://github.com/glscene
 //
 //
-unit GXS.Sound;
+unit GXS.SoundManager;
 
 
 (* Base classes and interface for GLScene Sound System *)
 (* Base classes and interface for GLScene Sound System *)
 
 
 interface
 interface
 
 
+{$I GLScene.Defines.inc}
+
 uses
 uses
   System.Classes,
   System.Classes,
   System.SysUtils,
   System.SysUtils,
   System.Types,
   System.Types,
 
 
-  GLScene.XCollection,
   GLScene.VectorTypes,
   GLScene.VectorTypes,
+  GLScene.VectorGeometry,
+  GLScene.BaseClasses,
+  GLScene.XCollection,
   GXS.SoundFileObjects,
   GXS.SoundFileObjects,
   GXS.Scene,
   GXS.Scene,
-  GLScene.VectorGeometry,
   GXS.Cadencer,
   GXS.Cadencer,
-  GLScene.BaseClasses,
   GLScene.Utils,
   GLScene.Utils,
   GXS.ImageUtils;
   GXS.ImageUtils;
 
 
-{$I GLScene.Defines.inc}
-
 type
 type
-
-  { Stores a single PCM coded sound sample. }
+  // Stores a single PCM coded sound sample.
   TgxSoundSample = class(TCollectionItem)
   TgxSoundSample = class(TCollectionItem)
   private
   private
     FName: string;
     FName: string;
@@ -91,7 +90,7 @@ type
 
 
   TgxBSoundEmitter = class;
   TgxBSoundEmitter = class;
 
 
-  { Base class for origin of sound playback. }
+  // Base class for origin of sound playback.
   TgxBaseSoundSource = class(TCollectionItem)
   TgxBaseSoundSource = class(TCollectionItem)
   private
   private
     FBehaviourToNotify: TgxBSoundEmitter;
     FBehaviourToNotify: TgxBSoundEmitter;
@@ -138,32 +137,35 @@ type
     function Sample: TgxSoundSample;
     function Sample: TgxSoundSample;
     // This Tag is reserved for sound manager use only
     // This Tag is reserved for sound manager use only
     property ManagerTag: Cardinal read FTag write FTag;
     property ManagerTag: Cardinal read FTag write FTag;
-    { Origin object for the sound sources.
+    (*
+      Origin object for the sound sources.
        Absolute object position/orientation are taken into account, the
        Absolute object position/orientation are taken into account, the
        object's TgxBInertia is considered if any.
        object's TgxBInertia is considered if any.
        If origin is nil, the source is assumed to be static at the origin.
        If origin is nil, the source is assumed to be static at the origin.
         Note :  since TCollectionItem do not support the "Notification"
         Note :  since TCollectionItem do not support the "Notification"
        scheme, it is up to the Origin object to take care of updating this
        scheme, it is up to the Origin object to take care of updating this
-       property prior to release/destruction. }
+       property prior to release/destruction.
+    *)
     property Origin: TgxBaseSceneObject read FOrigin write SetOrigin;
     property Origin: TgxBaseSceneObject read FOrigin write SetOrigin;
   published
   published
     property SoundLibrary: TgxSoundLibrary read GetSoundLibrary write
     property SoundLibrary: TgxSoundLibrary read GetSoundLibrary write
       SetSoundLibrary;
       SetSoundLibrary;
     property SoundName: string read FSoundName write SetSoundName;
     property SoundName: string read FSoundName write SetSoundName;
-    { Volume of the source, [0.0; 1.0] range }
+    // Volume of the source, [0.0; 1.0] range
     property Volume: Single read FVolume write SetVolume;
     property Volume: Single read FVolume write SetVolume;
-    { Nb of playing loops. }
+    // Nb of playing loops.
     property NbLoops: Integer read FNbLoops write SetNbLoops default 1;
     property NbLoops: Integer read FNbLoops write SetNbLoops default 1;
     property Mute: Boolean read FMute write SetMute default False;
     property Mute: Boolean read FMute write SetMute default False;
     property Pause: Boolean read FPause write SetPause default False;
     property Pause: Boolean read FPause write SetPause default False;
-    { Sound source priority, the higher the better.
-       When maximum number of sound sources is reached, only the sources
-       with the highest priority will continue to play, however, even
-       non-playing sources should be tracked by the manager, thus allowing
-       an "unlimited" amount of sources from the application point of view. }
+    (*
+      Sound source priority, the higher the better.
+      When maximum number of sound sources is reached, only the sources
+      with the highest priority will continue to play, however, even
+      non-playing sources should be tracked by the manager, thus allowing
+      an "unlimited" amount of sources from the application point of view.
+    *)
     property Priority: Integer read FPriority write SetPriority default 0;
     property Priority: Integer read FPriority write SetPriority default 0;
-    { Min distance before spatial attenuation occurs.
-       1.0 by default }
+    // Min distance before spatial attenuation occurs. 1.0 by default
     property MinDistance: Single read FMinDistance write SetMinDistance;
     property MinDistance: Single read FMinDistance write SetMinDistance;
     { Max distance, if source is further away, it will not be heard.
     { Max distance, if source is further away, it will not be heard.
        100.0 by default }
        100.0 by default }
@@ -187,11 +189,10 @@ type
        Values null or negative are interpreted as 'default frequency'. }
        Values null or negative are interpreted as 'default frequency'. }
     property Frequency: Integer read FFrequency write SetFrequency default -1;
     property Frequency: Integer read FFrequency write SetFrequency default -1;
   end;
   end;
-
-    { Origin of sound playback.
-       Just publishes the 'Origin' property.
-       Note that the "orientation" is the the source's Direction, ie. the "Z"
-       vector. }
+  (*
+    Origin of sound playback. Just publishes the 'Origin' property.
+    Note: "orientation" is the the source's Direction, ie. the "Z" vector.
+  *)
   TgxSoundSource = class(TgxBaseSoundSource)
   TgxSoundSource = class(TgxBaseSoundSource)
   public
   public
     destructor Destroy; override;
     destructor Destroy; override;
@@ -213,7 +214,7 @@ type
       default;
       default;
   end;
   end;
 
 
-  { EAX standard sound environments. }
+  // EAX standard sound environments
   TgxSoundEnvironment = (seDefault, sePaddedCell, seRoom, seBathroom,
   TgxSoundEnvironment = (seDefault, sePaddedCell, seRoom, seBathroom,
     seLivingRoom, seStoneroom, seAuditorium,
     seLivingRoom, seStoneroom, seAuditorium,
     seConcertHall, seCave, seArena, seHangar,
     seConcertHall, seCave, seArena, seHangar,
@@ -222,13 +223,15 @@ type
     sePlain, seParkingLot, seSewerPipe, seUnderWater,
     sePlain, seParkingLot, seSewerPipe, seUnderWater,
     seDrugged, seDizzy, sePsychotic);
     seDrugged, seDizzy, sePsychotic);
 
 
-    { Base class for sound manager components.
-       The sound manager component is the interface to a low-level audio API
-       (like DirectSound), there can only be one active manager at any time
-       (this class takes care of this).
-       Subclass should override the DoActivate and DoDeActivate protected methods
-       to "initialize/unitialize" their sound layer, actual data releases should
-       occur in destructor however. }
+   (*
+   Base class for sound manager components.
+     The sound manager component is the interface to a low-level audio API
+     (like DirectSound), there can only be one active manager at any time
+     (this class takes care of this).
+     Subclass should override the DoActivate and DoDeActivate protected methods
+     to "initialize/unitialize" their sound layer, actual data releases should
+     occur in destructor however.
+   *)
   TgxSoundManager = class(TGCadenceAbleComponent)
   TgxSoundManager = class(TGCadenceAbleComponent)
   private
   private
     FActive: Boolean;
     FActive: Boolean;
@@ -277,8 +280,8 @@ type
     // Invoked AFTER all sources have been stopped
     // Invoked AFTER all sources have been stopped
     procedure DoDeActivate; virtual;
     procedure DoDeActivate; virtual;
     { Effect mute of all sounds.
     { Effect mute of all sounds.
-       Default implementation call MuteSource for all non-muted sources
-       with "True" as parameter. }
+      Default implementation call MuteSource for all non-muted sources
+      with "True" as parameter. }
     function DoMute: Boolean; virtual;
     function DoMute: Boolean; virtual;
     { Effect un-mute of all sounds.
     { Effect un-mute of all sounds.
        Default implementation call MuteSource for all non-muted sources
        Default implementation call MuteSource for all non-muted sources
@@ -423,9 +426,7 @@ var
   // If this variable is true, errors in GLSM may be displayed to the user
   // If this variable is true, errors in GLSM may be displayed to the user
   vVerboseGLSMErrors: Boolean = True;
   vVerboseGLSMErrors: Boolean = True;
 
 
-// ------------------------------------------------------------------
-implementation
-// ------------------------------------------------------------------
+implementation // -----------------------------------------------------------
 
 
 var
 var
   vActiveSoundManager: TgxSoundManager;
   vActiveSoundManager: TgxSoundManager;
@@ -1529,18 +1530,13 @@ begin
   FPlayingSource := nil;
   FPlayingSource := nil;
 end;
 end;
 
 
-// ------------------------------------------------------------------
-initialization
-// ------------------------------------------------------------------
+initialization // ---------------------------------------------------------
 
 
-   
   RegisterClasses([TgxSoundLibrary]);
   RegisterClasses([TgxSoundLibrary]);
   RegisterXCollectionItemClass(TgxBSoundEmitter);
   RegisterXCollectionItemClass(TgxBSoundEmitter);
   vSoundLibraries := TList.Create;
   vSoundLibraries := TList.Create;
 
 
-// ------------------------------------------------------------------
-finalization
-// ------------------------------------------------------------------
+finalization // -----------------------------------------------------------
 
 
   if Assigned(vActiveSoundManager) then
   if Assigned(vActiveSoundManager) then
     vActiveSoundManager.Active := False;
     vActiveSoundManager.Active := False;