Sfoglia il codice sorgente

CoreData / Data reorganization.
Comments cleanup.
Removed the fallback-data mechanism from IndexBuffer and VertexBuffer as unnecessary.

Lasse Öörni 14 anni fa
parent
commit
de67af8825
100 ha cambiato i file con 3204 aggiunte e 3208 eliminazioni
  1. 0 0
      Bin/Data/Fonts/Anonymous Pro.ttf
  2. 0 0
      Bin/Data/Fonts/OFL.txt
  3. 1 1
      Bin/Data/Scripts/Chat.as
  4. 7 7
      Bin/Data/Scripts/NinjaSnowWar.as
  5. 0 0
      Bin/Data/Scripts/NinjaSnowWar/AIController.as
  6. 0 0
      Bin/Data/Scripts/NinjaSnowWar/GameObject.as
  7. 1 1
      Bin/Data/Scripts/NinjaSnowWar/LightFlash.as
  8. 2 2
      Bin/Data/Scripts/NinjaSnowWar/Ninja.as
  9. 0 0
      Bin/Data/Scripts/NinjaSnowWar/Player.as
  10. 1 1
      Bin/Data/Scripts/NinjaSnowWar/Potion.as
  11. 1 1
      Bin/Data/Scripts/NinjaSnowWar/SnowBall.as
  12. 1 1
      Bin/Data/Scripts/NinjaSnowWar/SnowCrate.as
  13. 4 1
      Bin/Data/Scripts/TestScene.as
  14. 0 0
      Bin/Data/Scripts/Utilities/Network.as
  15. BIN
      Bin/Data/Textures/UI.png
  16. 5 0
      Bin/Data/Textures/UI.xml
  17. 0 0
      Bin/Data/UI/DefaultStyle.xml
  18. 129 0
      Bin/Data/UI/EditorSettingsDialog.xml
  19. 24 12
      Docs/Reference.dox
  20. 14 14
      Engine/Audio/Audio.cpp
  21. 41 41
      Engine/Audio/Audio.h
  22. 1 1
      Engine/Audio/AudioDefs.h
  23. 1 1
      Engine/Audio/Sound.cpp
  24. 41 41
      Engine/Audio/Sound.h
  25. 60 60
      Engine/Audio/SoundSource.h
  26. 15 15
      Engine/Audio/SoundSource3D.h
  27. 22 22
      Engine/Container/Allocator.h
  28. 66 72
      Engine/Container/ArrayPtr.h
  29. 13 13
      Engine/Container/Hash.h
  30. 23 23
      Engine/Container/HashBase.h
  31. 74 82
      Engine/Container/HashMap.h
  32. 63 68
      Engine/Container/HashSet.h
  33. 68 88
      Engine/Container/List.h
  34. 18 18
      Engine/Container/ListBase.h
  35. 79 100
      Engine/Container/Map.h
  36. 11 11
      Engine/Container/Pair.h
  37. 69 75
      Engine/Container/Ptr.h
  38. 17 17
      Engine/Container/RefCounted.h
  39. 69 90
      Engine/Container/Set.h
  40. 6 6
      Engine/Container/Sort.h
  41. 14 0
      Engine/Container/String.cpp
  42. 111 139
      Engine/Container/StringBase.h
  43. 1 1
      Engine/Container/Swap.h
  44. 24 27
      Engine/Container/TreeBase.h
  45. 112 148
      Engine/Container/Vector.h
  46. 44 44
      Engine/Container/VectorBase.h
  47. 7 7
      Engine/Core/AreaAllocator.h
  48. 20 20
      Engine/Core/Attribute.h
  49. 51 77
      Engine/Core/Context.h
  50. 6 6
      Engine/Core/CoreEvents.h
  51. 1 1
      Engine/Core/MiniDump.h
  52. 10 10
      Engine/Core/Mutex.h
  53. 56 66
      Engine/Core/Object.h
  54. 10 10
      Engine/Core/ProcessUtils.h
  55. 52 52
      Engine/Core/Profiler.h
  56. 43 43
      Engine/Core/StringHash.h
  57. 10 7
      Engine/Core/StringUtils.cpp
  58. 15 15
      Engine/Core/StringUtils.h
  59. 1 1
      Engine/Core/Thread.cpp
  60. 9 9
      Engine/Core/Thread.h
  61. 31 31
      Engine/Core/Timer.h
  62. 137 140
      Engine/Core/Variant.h
  63. 25 25
      Engine/Engine/APITemplates.h
  64. 31 31
      Engine/Engine/Console.h
  65. 18 0
      Engine/Engine/CoreAPI.cpp
  66. 25 25
      Engine/Engine/DebugHud.h
  67. 32 32
      Engine/Engine/Engine.h
  68. 5 1
      Engine/Engine/SceneAPI.cpp
  69. 13 13
      Engine/Engine/ScriptAPI.h
  70. 80 80
      Engine/Graphics/AnimatedModel.h
  71. 32 32
      Engine/Graphics/Animation.h
  72. 56 56
      Engine/Graphics/AnimationController.h
  73. 31 31
      Engine/Graphics/AnimationState.h
  74. 68 68
      Engine/Graphics/Batch.h
  75. 56 56
      Engine/Graphics/BillboardSet.h
  76. 55 55
      Engine/Graphics/Camera.h
  77. 27 27
      Engine/Graphics/DebugRenderer.h
  78. 9 9
      Engine/Graphics/Direct3D9/D3D9GPUObject.h
  79. 231 231
      Engine/Graphics/Direct3D9/D3D9Graphics.h
  80. 30 30
      Engine/Graphics/Direct3D9/D3D9GraphicsImpl.h
  81. 28 38
      Engine/Graphics/Direct3D9/D3D9IndexBuffer.cpp
  82. 23 25
      Engine/Graphics/Direct3D9/D3D9IndexBuffer.h
  83. 25 25
      Engine/Graphics/Direct3D9/D3D9RenderSurface.h
  84. 13 13
      Engine/Graphics/Direct3D9/D3D9Shader.h
  85. 23 23
      Engine/Graphics/Direct3D9/D3D9ShaderVariation.h
  86. 39 39
      Engine/Graphics/Direct3D9/D3D9Texture.h
  87. 15 15
      Engine/Graphics/Direct3D9/D3D9Texture2D.h
  88. 18 18
      Engine/Graphics/Direct3D9/D3D9TextureCube.h
  89. 27 37
      Engine/Graphics/Direct3D9/D3D9VertexBuffer.cpp
  90. 42 44
      Engine/Graphics/Direct3D9/D3D9VertexBuffer.h
  91. 11 11
      Engine/Graphics/Direct3D9/D3D9VertexDeclaration.h
  92. 80 80
      Engine/Graphics/Drawable.h
  93. 39 39
      Engine/Graphics/Geometry.h
  94. 18 18
      Engine/Graphics/GraphicsDefs.h
  95. 4 11
      Engine/Graphics/GraphicsEvents.h
  96. 109 109
      Engine/Graphics/Light.h
  97. 3 3
      Engine/Graphics/Material.cpp
  98. 50 50
      Engine/Graphics/Material.h
  99. 54 22
      Engine/Graphics/Model.cpp
  100. 47 47
      Engine/Graphics/Model.h

+ 0 - 0
Bin/CoreData/Fonts/Anonymous Pro.ttf → Bin/Data/Fonts/Anonymous Pro.ttf


+ 0 - 0
Bin/CoreData/Fonts/OFL.txt → Bin/Data/Fonts/OFL.txt


+ 1 - 1
Bin/Data/Scripts/Chat.as

@@ -1,4 +1,4 @@
-#include "Scripts/Network.as"
+#include "Scripts/Utilities/Network.as"
 
 Text@ chatHistoryText;
 UIElement@ buttonLayout;

+ 7 - 7
Bin/Data/Scripts/NinjaSnowWar.as

@@ -1,12 +1,12 @@
 // Remake of NinjaSnowWar in script
 
-#include "Scripts/LightFlash.as"
-#include "Scripts/Network.as"
-#include "Scripts/Ninja.as"
-#include "Scripts/Player.as"
-#include "Scripts/Potion.as"
-#include "Scripts/SnowBall.as"
-#include "Scripts/SnowCrate.as"
+#include "Scripts/NinjaSnowWar/LightFlash.as"
+#include "Scripts/NinjaSnowWar/Ninja.as"
+#include "Scripts/NinjaSnowWar/Player.as"
+#include "Scripts/NinjaSnowWar/Potion.as"
+#include "Scripts/NinjaSnowWar/SnowBall.as"
+#include "Scripts/NinjaSnowWar/SnowCrate.as"
+#include "Scripts/Utilities/Network.as"
 
 const float mouseSensitivity = 0.125;
 const float cameraMinDist = 25;

+ 0 - 0
Bin/Data/Scripts/AIController.as → Bin/Data/Scripts/NinjaSnowWar/AIController.as


+ 0 - 0
Bin/Data/Scripts/GameObject.as → Bin/Data/Scripts/NinjaSnowWar/GameObject.as


+ 1 - 1
Bin/Data/Scripts/LightFlash.as → Bin/Data/Scripts/NinjaSnowWar/LightFlash.as

@@ -1,4 +1,4 @@
-#include "Scripts/GameObject.as"
+#include "Scripts/NinjaSnowWar/GameObject.as"
 
 class LightFlash : GameObject
 {

+ 2 - 2
Bin/Data/Scripts/Ninja.as → Bin/Data/Scripts/NinjaSnowWar/Ninja.as

@@ -1,5 +1,5 @@
-#include "Scripts/GameObject.as"
-#include "Scripts/AIController.as"
+#include "Scripts/NinjaSnowWar/GameObject.as"
+#include "Scripts/NinjaSnowWar/AIController.as"
 
 const int LAYER_MOVE = 0;
 const int LAYER_ATTACK = 1;

+ 0 - 0
Bin/Data/Scripts/Player.as → Bin/Data/Scripts/NinjaSnowWar/Player.as


+ 1 - 1
Bin/Data/Scripts/Potion.as → Bin/Data/Scripts/NinjaSnowWar/Potion.as

@@ -1,4 +1,4 @@
-#include "Scripts/GameObject.as"
+#include "Scripts/NinjaSnowWar/GameObject.as"
 
 const int potionHealAmount = 5;
 const float potionMass = 10;

+ 1 - 1
Bin/Data/Scripts/SnowBall.as → Bin/Data/Scripts/NinjaSnowWar/SnowBall.as

@@ -1,4 +1,4 @@
-#include "Scripts/GameObject.as"
+#include "Scripts/NinjaSnowWar/GameObject.as"
 
 const float snowballMass = 10;
 const float snowballFriction = 0.5;

+ 1 - 1
Bin/Data/Scripts/SnowCrate.as → Bin/Data/Scripts/NinjaSnowWar/SnowCrate.as

@@ -1,4 +1,4 @@
-#include "Scripts/GameObject.as"
+#include "Scripts/NinjaSnowWar/GameObject.as"
 
 const int snowcrateHealth = 5;
 const float snowcrateMass = 200;

+ 4 - 1
Bin/Data/Scripts/TestScene.as

@@ -1,4 +1,4 @@
-#include "Scripts/Network.as"
+#include "Scripts/Utilities/Network.as"
 
 Scene@ testScene;
 Camera@ camera;
@@ -92,6 +92,9 @@ void InitScene()
     PhysicsWorld@ world = testScene.CreateComponent("PhysicsWorld");
     testScene.CreateComponent("Octree");
     testScene.CreateComponent("DebugRenderer");
+    
+    testScene.RegisterVar("Score");
+    testScene.RegisterVar("Health");
 
     world.gravity = Vector3(0.0, -9.81, 0.0);
     world.fps = 100;

+ 0 - 0
Bin/Data/Scripts/Network.as → Bin/Data/Scripts/Utilities/Network.as


BIN
Bin/Data/Textures/UI.png


+ 5 - 0
Bin/Data/Textures/UI.xml

@@ -0,0 +1,5 @@
+<texture>
+    <mipmap enable="false" />
+    <quality low="0" />
+</texture>
+

+ 0 - 0
Bin/CoreData/UI/DefaultStyle.xml → Bin/Data/UI/DefaultStyle.xml


+ 129 - 0
Bin/Data/UI/EditorSettingsDialog.xml

@@ -0,0 +1,129 @@
+<element type="Window" name="CameraDialog">
+    <movable enable="true" />
+    <layout mode="vertical" spacing="4" border="6 6 6 6" />
+    <element>
+        <fixedheight value="16" />
+        <layout mode="horizontal" />
+        <element type="Text">
+            <text value="Editor camera settings" />
+        </element>
+        <element type="Button" style="CloseButton" name="CloseButton" />
+    </element>
+    <element type="BorderImage" style="EditorDivider">
+        <fixedheight value="4" />
+    </element>
+    <element>
+        <fixedheight value="17" />
+        <layout mode="horizontal" spacing="20" />
+        <element type="Text">
+            <text value="Near clip distance" />
+        </element>
+        <element type="LineEdit" name="NearClipEdit">
+            <fixedwidth value="80" />
+        </element>
+    </element>
+    <element>
+        <fixedheight value="17" />
+        <layout mode="horizontal" spacing="20" />
+        <element type="Text">
+            <text value="Far clip distance" />
+        </element>
+        <element type="LineEdit" name="FarClipEdit">
+            <fixedwidth value="80" />
+         </element>
+    </element>
+    <element>
+        <fixedheight value="17" />
+        <layout mode="horizontal" spacing="20" />
+        <element type="Text">
+            <text value="Field of view" />
+        </element>
+        <element type="LineEdit" name="FOVEdit">
+            <fixedwidth value="80" />
+        </element>
+    </element>
+    <element>
+        <fixedheight value="17" />
+        <layout mode="horizontal" spacing="20" />
+        <element type="Text">
+            <text value="Movement speed" />
+        </element>
+        <element type="LineEdit" name="SpeedEdit">
+            <fixedwidth value="80" />
+        </element>
+    </element>
+    <element type="BorderImage" style="EditorDivider">
+        <fixedheight value="4" />
+    </element>
+    <element>
+        <fixedheight value="17" />
+        <layout mode="horizontal" spacing="20" />
+        <element type="Text">
+            <text value="New node distance" />
+        </element>
+        <element type="LineEdit" name="DistanceEdit">
+            <fixedwidth value="80" />
+        </element>
+    </element>
+    <element>
+        <fixedheight value="17" />
+        <layout mode="horizontal" spacing="8" />
+        <element type="Text">
+            <text value="Node move step" />
+        </element>
+        <element type="CheckBox" name="MoveSnapToggle">
+            <fixedsize value="16 16" />
+        </element>
+        <element type="Text">
+            <fixedwidth value="34" />
+            <text value="Snap" />
+        </element>
+        <element type="LineEdit" name="MoveStepEdit">
+            <fixedwidth value="80" />
+        </element>
+    </element>
+    <element>
+        <fixedheight value="17" />
+        <layout mode="horizontal" spacing="8" />
+        <element type="Text">
+            <text value="Node rotate step" />
+        </element>
+        <element type="CheckBox" name="RotateSnapToggle">
+            <fixedsize value="16 16" />
+        </element>
+        <element type="Text">
+            <fixedwidth value="34" />
+            <text value="Snap" />
+        </element>
+        <element type="LineEdit" name="RotateStepEdit">
+            <fixedwidth value="80" />
+        </element>
+    </element>
+    <element>
+        <fixedheight value="17" />
+        <layout mode="horizontal" spacing="8" />
+        <element type="Text">
+            <text value="Node scale step" />
+        </element>
+        <element type="CheckBox" name="ScaleSnapToggle">
+            <fixedsize value="16 16" />
+        </element>
+        <element type="Text">
+            <fixedwidth value="34" />
+            <text value="Snap" />
+        </element>
+        <element type="LineEdit" name="ScaleStepEdit">
+            <fixedwidth value="80" />
+        </element>
+    </element>
+    <element>
+        <fixedheight value="17" />
+        <layout mode="horizontal" spacing="8" />
+        <element type="CheckBox" name="LocalIDToggle">
+            <fixedsize value="16 16" />
+        </element>
+        <element type="Text">
+            <text value="Use local entity IDs on import" />
+        </element>
+    </element>
+</element>

+ 24 - 12
Docs/Reference.dox

@@ -135,11 +135,11 @@ Variable timestep logic updates are preferable to fixed timestep, because they a
 
 \page SceneModel %Scene model
 
-Urho3D's scene model can be described as a component-based scene graph. The Scene consists of a hierarchy of scene nodes, starting from the root node, which also represents the whole scene. Each Node has a 3D transform (position, rotation and scale) and a name, but no other functionality. Rendering 3D objects, sound playback, physics and scripted logic updates are all enabled by creating different \ref Component "Components" into the nodes by calling \ref Node::CreateComponent "CreateComponent()".
+Urho3D's scene model can be described as a component-based scene graph. The Scene consists of a hierarchy of scene nodes, starting from the root node, which also represents the whole scene. Each Node has a 3D transform (position, rotation and scale), a name and an ID, and a freeform VariantMap for \ref Node::GetVars "user variables", but no other functionality.
 
-Components do not have names; components inside the same node are only identified by their type, and index in the node's component list, which is filled in creation order. See the various overloads of \ref Node::GetComponent "GetComponent()" or \ref Node::GetComponents "GetComponents()" for details.
+\section SceneModel_Components Components
 
-As with events, in C++ components are identified by type name hashes, and template forms of the component creation and retrieval functions exist for convenience. For example:
+Rendering 3D objects, sound playback, physics and scripted logic updates are all enabled by creating different \ref Component "Components" into the nodes by calling \ref Node::CreateComponent "CreateComponent()". As with events, in C++ components are identified by type name hashes, and template forms of the component creation and retrieval functions exist for convenience. For example:
 
 \code
 Light* light = lightNode->CreateComponent<Light>();
@@ -152,25 +152,35 @@ Light@ light = lightNode.CreateComponent("Light");
 
 Because components are created using \ref ObjectTypes "object factories", a factory must be registered for each component type.
 
-When created, nodes and components get scene-global integer IDs. They can be queried from the Scene by using the functions \ref Scene::GetNodeByID "GetNodeByID()" and \ref Scene::GetComponentByID "GetComponentByID()". This is much faster than for example doing recursive name-based scene node queries.
+Components created into the Scene itself have a special role: to implement scene-wide functionality. They should be created before all other components, and include the following:
+
+- Octree: implements spatial partitioning and accelerated visibility queries. Without this 3D objects can not be rendered.
+- PhysicsWorld: implements physics simulation. Physics components such as RigidBody or CollisionShape can not function properly without this.
+- DebugRenderer: implements debug geometry rendering.
+
+"Ordinary" components like Light, Camera or StaticModel should not be created directly into the Scene, but rather into child nodes.
+
+\section SceneModel_Identification Identification and scene hierarchy
 
-There is no inbuilt concept of an entity or a game object; rather it is up to the programmer to decide the node hierarchy, and to decide in which nodes to place any scripted logic. Typically, free-moving objects in the 3D world would be created as children of the root node. Nodes can be created either with or without a name, see \ref Node::CreateChild "CreateChild()". Uniqueness of node names is not enforced.
+Unlike nodes, components do not have names; components inside the same node are only identified by their type, and index in the node's component list, which is filled in creation order. See the various overloads of \ref Node::GetComponent "GetComponent()" or \ref Node::GetComponents "GetComponents()" for details.
+
+When created, both nodes and components get scene-global integer IDs. They can be queried from the Scene by using the functions \ref Scene::GetNodeByID "GetNodeByID()" and \ref Scene::GetComponentByID "GetComponentByID()". This is much faster than for example doing recursive name-based scene node queries.
+
+There is no inbuilt concept of an entity or a game object; rather it is up to the programmer to decide the node hierarchy, and in which nodes to place any scripted logic. Typically, free-moving objects in the 3D world would be created as children of the root node. Nodes can be created either with or without a name, see \ref Node::CreateChild "CreateChild()". Uniqueness of node names is not enforced.
 
 Whenever there is some hierarchical composition, it is recommended (and in fact necessary, because components do not have their own 3D transforms) to create a child node. For example if a character was holding an object in his hand, the object should have its own node, which would be parented to the character's hand bone (also a Node.) The exception is the physics CollisionShape, which can be offsetted and rotated individually in relation to the node. See \ref Physics "Physics" for more details.
 
 %Scene nodes can be freely reparented. In contrast components are always created to the node they belong to, and can not be moved between nodes. Both child nodes and components are stored using SharedPtr containers; this means that detaching a child node from its parent or removing a component will also destroy it, if no other references to it exist. Both Node & Component provide the \ref Node::Remove() "Remove()" function to accomplish this without having to go through the parent. Note that no operations on the node or component in question are safe after calling that function.
 
-Components created into the Scene itself have a special role: to implement scene-wide functionality. They should be created before all other components, and include the following:
+It is also legal to create a Node that does not belong to a scene. This is particularly useful with cameras, because then the camera will not be serialized along with the actual scene, which is perhaps not always wanted.
 
-- Octree: implements spatial partitioning and accelerated visibility queries. Without this 3D objects can not be rendered.
-- PhysicsWorld: implements physics simulation. Physics components such as RigidBody or CollisionShape can not function properly without this.
-- DebugRenderer: implements debug geometry rendering.
+\section SceneModel_Update Scene updates and serialization
 
-"Ordinary" components like Light, Camera or StaticModel should not be created directly into the Scene, but rather into child nodes.
+A Scene can be either active or inactive (paused.) Active scenes will be automatically updated on each main loop iteration. 
 
-A Scene can be either active or inactive (paused.) Active scenes will be automatically updated on each main loop iteration. Scenes can be loaded and saved in either binary or XML format; see \ref Serialization "Serialization" for details.
+Scenes can be loaded and saved in either binary or XML format; see \ref Serialization "Serialization" for details.
 
-It is also legal to create a Node that does not belong to a scene. This particularly useful with cameras, because then the Camera will not be serialized along with the actual scene, which is perhaps not always wanted.
+\section SceneModel_FurtherInformation Further information
 
 For more information on the component-based scene model, see for example http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/.
 
@@ -285,6 +295,8 @@ Much of the Urho3D classes are exposed to scripts, however things that require l
 
 - Whenever only a single parameter is needed, setter and getter functions are replaced with properties. Such properties start with a lowercase letter. If an index parameter is needed, the property will be indexed. Indexed properties are in plural.
 
+- The element count property of arrays and other dynamic structures such as VariantMap and ResourceRefList is called "length", though the corresponding C++ function is usually Size().
+
 - Subsystems exist as global properties: time, fileSystem, log, cache, network, input, ui, audio, engine, graphics, renderer, script, console, debugHud.
 
 - Additional global properties exist for accessing the script object's node, the scene and the scene-wide components: node, scene, octree, physicsWorld, debugRenderer. When an object method is not executing, these are null. An exception: when the default scene for immediate execution has been set by calling \ref Script::SetDefaultScene "SetDefaultScene()", it is always available as "scene".

+ 14 - 14
Engine/Audio/Audio.cpp

@@ -59,11 +59,11 @@ static unsigned numInstances = 0;
 static int AudioCallback(const void* inputBuffer, void* outputBuffer, unsigned long framesPerBuffer,
     const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void* userData);
 #else
-/// DirectSound audio output stream
+/// DirectSound audio output stream.
 class AudioStream : public Thread
 {
 public:
-    /// Construct
+    /// Construct.
     AudioStream(Audio* owner) :
         owner_(owner),
         dsObject_(0),
@@ -71,7 +71,7 @@ public:
     {
     }
     
-    /// Destruct
+    /// Destruct.
     ~AudioStream()
     {
         Close();
@@ -83,7 +83,7 @@ public:
         }
     }
     
-    /// Create the DirectSound buffer
+    /// Create the DirectSound buffer.
     bool Open(unsigned windowHandle, int bufferLengthMSec, int mixRate, bool stereo)
     {
         Close();
@@ -125,7 +125,7 @@ public:
         return dsObject_->CreateSoundBuffer(&bufferDesc, &dsBuffer_, 0) == DS_OK;
     }
     
-    /// Destroy the DirectSound buffer
+    /// Destroy the DirectSound buffer.
     void Close()
     {
         StopPlayback();
@@ -137,7 +137,7 @@ public:
         }
     }
     
-    /// Start playback
+    /// Start playback.
     bool StartPlayback()
     {
         if (IsStarted())
@@ -166,14 +166,14 @@ public:
             return false;
     }
     
-    /// Stop playback
+    /// Stop playback.
     void StopPlayback()
     {
         if (dsBuffer_ && IsStarted())
             Stop();
     }
     
-    /// Mixing thread function
+    /// Mixing thread function.
     void ThreadFunction()
     {
         DWORD playCursor = 0;
@@ -240,17 +240,17 @@ public:
     }
     
 private:
-    /// Audio subsystem
+    /// Audio subsystem.
     Audio* owner_;
-    /// DirectSound interface
+    /// DirectSound interface.
     IDirectSound* dsObject_;
-    /// DirectSound buffer
+    /// DirectSound buffer.
     IDirectSoundBuffer* dsBuffer_;
-    /// Sound buffer size in bytes
+    /// Sound buffer size in bytes.
     unsigned bufferSize_;
-    /// Sound buffer sample size
+    /// Sound buffer sample size.
     unsigned sampleSize_;
-    /// Playing flag
+    /// Playing flag.
     bool playing_;
 };
 #endif

+ 41 - 41
Engine/Audio/Audio.h

@@ -34,102 +34,102 @@ class AudioImpl;
 class Sound;
 class SoundSource;
 
-/// Audio subsystem. Uses PortAudio for the actual sound output
+/// Audio subsystem. Uses either DirectSound or PortAudio for the actual sound output.
 class Audio : public Object
 {
     OBJECT(Audio);
     
 public:
-    /// Construct
+    /// Construct.
     Audio(Context* context);
-    /// Destruct. Terminate the audio thread and free the audio buffer
+    /// Destruct. Terminate the audio thread and free the audio buffer.
     virtual ~Audio();
     
-    /// Initialize sound output with specified buffer length and output mode
+    /// Initialize sound output with specified buffer length and output mode.
     bool SetMode(int bufferLengthMSec, int mixRate, bool stereo, bool interpolate = true);
     /// Run update on sound sources. Not required for continued playback, but frees unused sound sources & sounds and updates 3D positions.
     void Update(float timeStep);
-    /// Restart sound output
+    /// Restart sound output.
     bool Play();
-    /// Suspend sound output
+    /// Suspend sound output.
     void Stop();
     /// %Set master gain on a specific sound type such as sound effects, music or voice.
     void SetMasterGain(SoundType type, float gain);
-    /// %Set listener position
+    /// %Set listener position.
     void SetListenerPosition(const Vector3& position);
-    /// %Set listener rotation
+    /// %Set listener rotation.
     void SetListenerRotation(const Quaternion& rotation);
-    /// %Set listener position and rotation
+    /// %Set listener position and rotation.
     void SetListenerTransform(const Vector3& position, const Quaternion& rotation);
-    /// Stop any sound source playing a certain sound clip
+    /// Stop any sound source playing a certain sound clip.
     void StopSound(Sound* sound);
     
-    /// Return byte size of one sample
+    /// Return byte size of one sample.
     unsigned GetSampleSize() const { return sampleSize_; }
-    /// Return mixing rate
+    /// Return mixing rate.
     int GetMixRate() const { return mixRate_; }
-    /// Return whether output is stereo
+    /// Return whether output is stereo.
     bool IsStereo() const { return stereo_; }
-    /// Return whether output is interpolated
+    /// Return whether output is interpolated.
     bool IsInterpolated() const { return interpolate_; }
-    /// Return whether audio is being output
+    /// Return whether audio is being output.
     bool IsPlaying() const { return playing_; }
-    /// Return whether an audio stream has been reserved
+    /// Return whether an audio stream has been reserved.
     bool IsInitialized() const { return stream_ != 0; }
-    /// Return master gain for a specific sound source type
+    /// Return master gain for a specific sound source type.
     float GetMasterGain(SoundType type) const;
-    /// Return listener position
+    /// Return listener position.
     const Vector3& GetListenerPosition() const { return listenerPosition_; }
-    /// Return listener rotation
+    /// Return listener rotation.
     const Quaternion& GetListenerRotation() const { return listenerRotation_; }
-    /// Return all sound sources
+    /// Return all sound sources.
     const PODVector<SoundSource*>& GetSoundSources() const { return soundSources_; }
     
-    /// Add a sound source to keep track of. Called by SoundSource
+    /// Add a sound source to keep track of. Called by SoundSource.
     void AddSoundSource(SoundSource* soundSource);
-    /// Remove a sound source. Called by SoundSource
+    /// Remove a sound source. Called by SoundSource.
     void RemoveSoundSource(SoundSource* soundSource);
-    /// Return audio thread mutex
+    /// Return audio thread mutex.
     Mutex& GetMutex() { return audioMutex_; }
-    /// Return sound type specific gain multiplied by master gain
+    /// Return sound type specific gain multiplied by master gain.
     float GetSoundSourceMasterGain(SoundType type) const { return masterGain_[SOUND_MASTER] * masterGain_[type]; }
     
-    /// Mix sound sources into the buffer
+    /// Mix sound sources into the buffer.
     void MixOutput(void *dest, unsigned samples);
     
 private:
-    /// Handle render update event
+    /// Handle render update event.
     void HandleRenderUpdate(StringHash eventType, VariantMap& eventData);
-    /// Stop sound output and release the sound buffer
+    /// Stop sound output and release the sound buffer.
     void Release();
     
-    /// Sound output stream
+    /// Sound output stream.
     void* stream_;
-    /// Clipping buffer for mixing
+    /// Clipping buffer for mixing.
     SharedArrayPtr<int> clipBuffer_;
-    /// Audio thread mutex
+    /// Audio thread mutex.
     Mutex audioMutex_;
-    /// Sample size
+    /// Sample size.
     unsigned sampleSize_;
-    /// Clip buffer size in samples
+    /// Clip buffer size in samples.
     unsigned fragmentSize_;
-    /// Mixing rate
+    /// Mixing rate.
     int mixRate_;
-    /// Stereo flag
+    /// Stereo flag.
     bool stereo_;
-    /// Interpolation flag
+    /// Interpolation flag.
     bool interpolate_;
-    /// Playing flag
+    /// Playing flag.
     bool playing_;
-    /// Master gain by sound source type
+    /// Master gain by sound source type.
     float masterGain_[MAX_SOUND_TYPES];
-    /// Sound sources
+    /// Sound sources.
     PODVector<SoundSource*> soundSources_;
-    /// Listener position
+    /// Listener position.
     Vector3 listenerPosition_;
-    /// Listener rotation
+    /// Listener rotation.
     Quaternion listenerRotation_;
 };
 
-/// Register Sound library objects
+/// Register Sound library objects.
 void RegisterAudioLibrary(Context* context);

+ 1 - 1
Engine/Audio/AudioDefs.h

@@ -23,7 +23,7 @@
 
 #pragma once
 
-/// SoundSource type enumeration for master gain control
+/// SoundSource type enumeration for master gain control.
 enum SoundType
 {
     SOUND_MASTER = 0,

+ 1 - 1
Engine/Audio/Sound.cpp

@@ -35,7 +35,7 @@
 
 #include "DebugNew.h"
 
-/// WAV format header
+/// WAV format header.
 struct WavHeader
 {
     unsigned char riffText_[4];

+ 41 - 41
Engine/Audio/Sound.h

@@ -26,97 +26,97 @@
 #include "Resource.h"
 #include "ArrayPtr.h"
 
-/// Sound resource
+/// Sound resource.
 class Sound : public Resource
 {
     OBJECT(Sound);
     
 public:
-    /// Construct
+    /// Construct.
     Sound(Context* context);
-    /// Destruct and free sound data
+    /// Destruct and free sound data.
     virtual ~Sound();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Load resource. Return true if successful
+    /// Load resource. Return true if successful.
     virtual bool Load(Deserializer& source);
     
-    /// Load raw sound data
+    /// Load raw sound data.
     bool LoadRaw(Deserializer& source);
-    /// Load WAV format sound data
+    /// Load WAV format sound data.
     bool LoadWav(Deserializer& source);
-    /// Load Ogg Vorbis format sound data. Does not Decode at load, will be Decoded while playing
+    /// Load Ogg Vorbis format sound data. Does not decode at load, but will be rather be decoded while playing.
     bool LoadOggVorbis(Deserializer& source);
-    /// %Set sound size in bytes. Also resets the sound to be uncompressed and one-shot
+    /// %Set sound size in bytes. Also resets the sound to be uncompressed and one-shot.
     void SetSize(unsigned dataSize);
-    /// %Set uncompressed sound data
+    /// %Set uncompressed sound data.
     void SetData(const void* data, unsigned dataSize);
-    /// %Set uncompressed sound data format
+    /// %Set uncompressed sound data format.
     void SetFormat(unsigned frequency, bool sixteenBit, bool stereo);
-    /// %Set loop on/off. If loop is enabled, sets the full sound as loop range
+    /// %Set loop on/off. If loop is enabled, sets the full sound as loop range.
     void SetLooped(bool enable);
-    /// Define loop
+    /// Define loop.
     void SetLoop(unsigned repeatOffset, unsigned endOffset);
-    /// Fix interpolation by copying data from loop start to loop end (looped), or adding silence (oneshot)
+    /// Fix interpolation by copying data from loop start to loop end (looped), or adding silence (oneshot.)
     void FixInterpolation();
     
-    /// Create and return a Decoder. Return null if fails
+    /// Create and return a Decoder. Return null if fails.
     void* AllocateDecoder();
-    /// Decode compressed audio data. Return number of actually Decoded bytes
+    /// Decode compressed audio data. Return number of actually decoded bytes.
     unsigned Decode(void* Decoder, signed char* dest, unsigned bytes);
-    /// Rewind Decoder to beginning of audio data
+    /// Rewind the decoder to beginning of audio data.
     void RewindDecoder(void* Decoder);
-    /// Free Decoder
+    /// Free the decoder.
     void FreeDecoder(void* Decoder);
     
-    /// Return sound data start
+    /// Return sound data start.
     signed char* GetStart() const { return data_.Get(); }
-    /// Return loop start
+    /// Return loop start.
     signed char* GetRepeat() const { return repeat_; }
-    /// Return sound data end
+    /// Return sound data end.
     signed char* GetEnd() const { return end_; }
-    /// Return length in seconds
+    /// Return length in seconds.
     float GetLength() const;
-    /// Return total sound data size
+    /// Return total sound data size.
     unsigned GetDataSize() const { return dataSize_; }
-    /// Return sample size
+    /// Return sample size.
     unsigned GetSampleSize() const;
-    /// Return default frequency
+    /// Return default frequency as a float.
     float GetFrequency() { return (float)frequency_; }
-    /// Return default frequency
+    /// Return default frequency as an integer.
     unsigned GetIntFrequency() { return frequency_; }
-    /// Return whether is looped
+    /// Return whether is looped.
     bool IsLooped() const { return looped_; }
-    /// Return whether data is sixteen bit
+    /// Return whether data is sixteen bit.
     bool IsSixteenBit() const { return sixteenBit_; }
-    /// Return whether data is stereo
+    /// Return whether data is stereo.
     bool IsStereo() const { return stereo_; }
-    /// Return whether is compressed in Ogg Vorbis format
+    /// Return whether is compressed in Ogg Vorbis format.
     bool IsCompressed() const { return compressed_; }
     
 private:
-    /// Load optional parameters from an XML file
+    /// Load optional parameters from an XML file.
     void LoadParameters();
     
-    /// Sound data
+    /// Sound data.
     SharedArrayPtr<signed char> data_;
-    /// Loop start
+    /// Loop start.
     signed char* repeat_;
-    /// Sound data end
+    /// Sound data end.
     signed char* end_;
-    /// Sound data size in bytes
+    /// Sound data size in bytes.
     unsigned dataSize_;
-    /// Default frequency
+    /// Default frequency.
     unsigned frequency_;
-    /// Looped flag
+    /// Looped flag.
     bool looped_;
-    /// Sixteen bit flag
+    /// Sixteen bit flag.
     bool sixteenBit_;
-    /// Stereo flag
+    /// Stereo flag.
     bool stereo_;
-    /// Compressed flag
+    /// Compressed flag.
     bool compressed_;
-    /// Compressed sound length
+    /// Compressed sound length.
     float compressedLength_;
 };

+ 60 - 60
Engine/Audio/SoundSource.h

@@ -32,139 +32,139 @@ class Sound;
 // Compressed audio decode buffer length in milliseconds
 static const int DECODE_BUFFER_LENGTH = 100;
 
-/// Sound source component with stereo position
+/// Sound source component with stereo position.
 class SoundSource : public Component
 {
     OBJECT(SoundSource);
     
 public:
-    /// Construct
+    /// Construct.
     SoundSource(Context* context);
     /// Destruct. Remove self from the audio subsystem
     virtual ~SoundSource();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Play a sound
+    /// Play a sound.
     void Play(Sound* sound);
-    /// Play a sound with specified frequency
+    /// Play a sound with specified frequency.
     void Play(Sound* sound, float frequency);
-    /// Play a sound with specified frequency and gain
+    /// Play a sound with specified frequency and gain.
     void Play(Sound* sound, float frequency, float gain);
-    /// Play a sound with specified frequency, gain and panning
+    /// Play a sound with specified frequency, gain and panning.
     void Play(Sound* sound, float frequency, float gain, float panning);
-    /// Stop playback
+    /// Stop playback.
     void Stop();
-    /// %Set sound type, determines which master gain control it uses
+    /// %Set sound type, determines the master gain group.
     void SetSoundType(SoundType type);
-    /// %Set frequency
+    /// %Set frequency.
     void SetFrequency(float frequency);
-    /// %Set gain. 0.0 is silence, 1.0 is full volume
+    /// %Set gain. 0.0 is silence, 1.0 is full volume.
     void SetGain(float gain);
-    /// %Set attenuation. 1.0 is unaltered. Used for distance attenuated playback
+    /// %Set attenuation. 1.0 is unaltered. Used for distance attenuated playback.
     void SetAttenuation(float attenuation);
-    /// %Set stereo panning. -1.0 is full left and 1.0 is full right
+    /// %Set stereo panning. -1.0 is full left and 1.0 is full right.
     void SetPanning(float panning);
-   /// %Set whether sound source will be automatically removed from the scene node when playback stops
+   /// %Set whether sound source will be automatically removed from the scene node when playback stops.
     void SetAutoRemove(bool enable);
-    /// %Set new playback position
+    /// %Set new playback position.
     void SetPlayPosition(signed char* pos);
     
-    /// Return sound
+    /// Return sound.
     Sound* GetSound() const { return sound_; }
-    /// Return playback position
+    /// Return playback position.
     volatile signed char* GetPlayPosition() const { return position_; }
-    /// Return sound type
+    /// Return sound type, determines the master gain group.
     SoundType GetSoundType() const { return soundType_; }
-    /// Return playback time position
+    /// Return playback time position.
     float GetTimePosition() const { return timePosition_; }
-    /// Return frequency
+    /// Return frequency.
     float GetFrequency() const { return frequency_; }
-    /// Return gain
+    /// Return gain.
     float GetGain() const { return gain_; }
-    /// Return attenuation
+    /// Return attenuation.
     float GetAttenuation() const { return attenuation_; }
-    /// Return stereo panning
+    /// Return stereo panning.
     float GetPanning() const { return panning_; }
-    /// Return autoremove mode
+    /// Return autoremove mode.
     bool GetAutoRemove() const { return autoRemove_; }
-    /// Return whether is playing
+    /// Return whether is playing.
     bool IsPlaying() const;
     
-    /// Play a sound without locking the audio mutex. Called internally
+    /// Play a sound without locking the audio mutex. Called internally.
     void PlayLockless(Sound* sound);
-    /// Stop sound without locking the audio mutex. Called internally
+    /// Stop sound without locking the audio mutex. Called internally.
     void StopLockless();
-    /// %Set new playback position without locking the audio mutex. Called internally
+    /// %Set new playback position without locking the audio mutex. Called internally.
     void SetPlayPositionLockless(signed char* position);
-    /// Update the sound source. Perform subclass specific operations. Called by Sound
+    /// Update the sound source. Perform subclass specific operations. Called by Sound.
     virtual void Update(float timeStep);
-    /// Mix sound source output to a 32-bit clipping buffer. Called by Sound
+    /// Mix sound source output to a 32-bit clipping buffer. Called by Sound.
     void Mix(int* dest, unsigned samples, int mixRate, bool stereo, bool interpolate);
     
-    /// %Set sound attribute
+    /// %Set sound attribute.
     void SetSoundAttr(ResourceRef value);
-    /// %Set sound position attribute
+    /// %Set sound position attribute.
     void SetPositionAttr(int value);
-    /// Return sound attribute
+    /// Return sound attribute.
     ResourceRef GetSoundAttr() const;
-    /// Return sound position attribute
+    /// Return sound position attribute.
     int GetPositionAttr() const;
     
 protected:
-    /// Audio subsystem
+    /// Audio subsystem.
     WeakPtr<Audio> audio_;
-    /// SoundSource type
+    /// SoundSource type, determines the master gain group.
     SoundType soundType_;
-    /// Frequency
+    /// Frequency.
     float frequency_;
-    /// Gain
+    /// Gain.
     float gain_;
-    /// Attenuation
+    /// Attenuation.
     float attenuation_;
-    /// Stereo panning
+    /// Stereo panning.
     float panning_;
-    /// Autoremove timer
+    /// Autoremove timer.
     float autoRemoveTimer_;
-    /// Autoremove flag
+    /// Autoremove flag.
     bool autoRemove_;
     
 private:
-    /// Mix mono sample to mono buffer
+    /// Mix mono sample to mono buffer.
     void MixMonoToMono(Sound* sound, int* dest, unsigned samples, int mixRate);
-    /// Mix mono sample to stereo buffer
+    /// Mix mono sample to stereo buffer.
     void MixMonoToStereo(Sound* sound, int* dest, unsigned samples, int mixRate);
-    /// Mix mono sample to mono buffer interpolated
+    /// Mix mono sample to mono buffer interpolated.
     void MixMonoToMonoIP(Sound* sound, int* dest, unsigned samples, int mixRate);
-    /// Mix mono sample to stereo buffer interpolated
+    /// Mix mono sample to stereo buffer interpolated.
     void MixMonoToStereoIP(Sound* sound, int* dest, unsigned samples, int mixRate);
-    /// Mix stereo sample to mono buffer
+    /// Mix stereo sample to mono buffer.
     void MixStereoToMono(Sound* sound, int* dest, unsigned samples, int mixRate);
-    /// Mix stereo sample to stereo buffer
+    /// Mix stereo sample to stereo buffer.
     void MixStereoToStereo(Sound* sound, int* dest, unsigned samples, int mixRate);
-    /// Mix stereo sample to mono buffer interpolated
+    /// Mix stereo sample to mono buffer interpolated.
     void MixStereoToMonoIP(Sound* sound, int* dest, unsigned samples, int mixRate);
-    /// Mix stereo sample to stereo buffer interpolated
+    /// Mix stereo sample to stereo buffer interpolated.
     void MixStereoToStereoIP(Sound* sound, int* dest, unsigned samples, int mixRate);
-    /// Advance playback pointer without producing audible output
+    /// Advance playback pointer without producing audible output.
     void MixZeroVolume(Sound* sound, unsigned samples, int mixRate);
-    /// Advance playback pointer to simulate audio playback in headless mode
+    /// Advance playback pointer to simulate audio playback in headless mode.
     void MixNull(float timeStep);
-    /// Free Decoder if any
+    /// Free the decoder if any.
     void FreeDecoder();
     
-    /// Sound
+    /// Sound.
     SharedPtr<Sound> sound_;
-    /// Playback position
+    /// Playback position.
     volatile signed char *position_;
-    /// Playback fractional position
+    /// Playback fractional position.
     volatile int fractPosition_;
-    /// Playback time position
+    /// Playback time position.
     volatile float timePosition_;
-    /// Sound data Decoder
+    /// Ogg Vorbis decoder.
     void* decoder_;
-    /// Decode buffer
+    /// Decode buffer.
     SharedPtr<Sound> decodeBuffer_;
-    /// Previous decode buffer position
+    /// Previous decode buffer position.
     unsigned decodePosition_;
 };

+ 15 - 15
Engine/Audio/SoundSource3D.h

@@ -27,43 +27,43 @@
 
 class Audio;
 
-/// Sound source component with three-dimensional position
+/// Sound source component with three-dimensional position.
 class SoundSource3D : public SoundSource
 {
     OBJECT(SoundSource3D);
     
 public:
-    /// Construct
+    /// Construct.
     SoundSource3D(Context* context);
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Update sound source
+    /// Update sound source.
     virtual void Update(float timeStep);
     
-    /// %Set attenuation parameters
+    /// %Set attenuation parameters.
     void SetDistanceAttenuation(float nearDistance, float farDistance, float rolloffFactor);
-    /// %Set near distance. Distances closer than this do not have an effect
+    /// %Set near distance. Distances closer than this do not have an effect.
     void SetNearDistance(float distance);
-    /// %Set far distance. Beyond this sound will be completely attenuated
+    /// %Set far distance. Beyond this sound will be completely attenuated.
     void SetFarDistance(float distance);
-    /// %Set rolloff power factor, defines attenuation function shape
+    /// %Set rolloff power factor, defines attenuation function shape.
     void SetRolloffFactor(float factor);
-    /// Calculate attenuation and panning based on current position and listener position
+    /// Calculate attenuation and panning based on current position and listener position.
     void CalculateAttenuation();
     
-    /// Return near distance
+    /// Return near distance.
     float GetNearDistance() const { return nearDistance_; }
-    /// Return far distance
+    /// Return far distance.
     float GetFarDistance() const { return farDistance_; }
-    /// Return rolloff power factor
+    /// Return rolloff power factor.
     float RollAngleoffFactor() const { return rolloffFactor_; }
     
 protected:
-    /// Near distance
+    /// Near distance.
     float nearDistance_;
-    /// Far distance
+    /// Far distance.
     float farDistance_;
-    /// Rolloff power factor
+    /// Rolloff power factor.
     float rolloffFactor_;
 };

+ 22 - 22
Engine/Container/Allocator.h

@@ -28,42 +28,42 @@
 struct AllocatorBlock;
 struct AllocatorNode;
 
-/// Allocator memory block
+/// Allocator memory block.
 struct AllocatorBlock
 {
-    /// Node data size
+    /// Node data size.
     unsigned nodeSize_;
-    /// Number of nodes in this block
+    /// Number of nodes in this block.
     unsigned capacity_;
-    /// First free node
+    /// First free node.
     AllocatorNode* free_;
-    /// Next allocator block
+    /// Next allocator block.
     AllocatorBlock* next_;
-    /// Nodes follow
+    /// Nodes follow.
 };
 
-/// Allocator node
+/// Allocator node.
 struct AllocatorNode
 {
-    /// Next free node
+    /// Next free node.
     AllocatorNode* next_;
-    /// Data follows
+    /// Data follows.
 };
 
-/// Initialize a fixed-size allocator with the node size and initial capacity
+/// Initialize a fixed-size allocator with the node size and initial capacity.
 AllocatorBlock* AllocatorInitialize(unsigned nodeSize, unsigned initialCapacity = 1);
-/// Uninitialize a fixed-size allocator. Frees all blocks in the chain
+/// Uninitialize a fixed-size allocator. Frees all blocks in the chain.
 void AllocatorUninitialize(AllocatorBlock* allocator);
-/// Reserve a node. Creates a new block if necessary
+/// Reserve a node. Creates a new block if necessary.
 void* AllocatorReserve(AllocatorBlock* allocator);
-/// Free a node. Does not free any blocks
+/// Free a node. Does not free any blocks.
 void AllocatorFree(AllocatorBlock* allocator, void* ptr);
 
-/// Template allocator class. Allocates fixed-size objects of a specific class
+/// Template allocator class. Allocates fixed-size objects of a specific class.
 template <class T> class Allocator
 {
 public:
-    /// Construct
+    /// Construct.
     Allocator(unsigned initialCapacity = 0) :
         allocator_(0)
     {
@@ -71,13 +71,13 @@ public:
             allocator_ = AllocatorInitialize(sizeof(T), initialCapacity);
     }
     
-    /// Destruct
+    /// Destruct.
     ~Allocator()
     {
         AllocatorUninitialize(allocator_);
     }
     
-    /// Reserve and default-construct an object
+    /// Reserve and default-construct an object.
     T* Reserve()
     {
         if (!allocator_)
@@ -88,7 +88,7 @@ public:
         return newObject;
     }
     
-    /// Reserve and copy-construct an object
+    /// Reserve and copy-construct an object.
     T* Reserve(const T& object)
     {
         if (!allocator_)
@@ -99,7 +99,7 @@ public:
         return newObject;
     }
     
-    /// Destruct and free an object
+    /// Destruct and free an object.
     void Free(T* object)
     {
         (object)->~T();
@@ -107,11 +107,11 @@ public:
     }
     
 private:
-    /// Prevent copy construction
+    /// Prevent copy construction.
     Allocator(const Allocator<T>& rhs);
-    /// Prevent assignment
+    /// Prevent assignment.
     Allocator<T>& operator = (const Allocator<T>& rhs);
     
-    /// Allocator block
+    /// Allocator block.
     AllocatorBlock* allocator_;
 };

+ 66 - 72
Engine/Container/ArrayPtr.h

@@ -28,18 +28,18 @@
 
 #include <cassert>
 
-/// Shared array pointer template class. Uses non-intrusive reference counting
+/// Shared array pointer template class. Uses non-intrusive reference counting.
 template <class T> class SharedArrayPtr
 {
 public:
-    /// Construct a null shared array pointer
+    /// Construct a null shared array pointer.
     SharedArrayPtr() :
         ptr_(0),
         refCount_(0)
     {
     }
     
-    /// Copy-construct from another shared array pointer
+    /// Copy-construct from another shared array pointer.
     SharedArrayPtr(const SharedArrayPtr<T>& rhs) :
         ptr_(rhs.ptr_),
         refCount_(rhs.refCount_)
@@ -48,7 +48,7 @@ public:
             ++(refCount_->refs_);
     }
     
-    /// Construct from a raw pointer
+    /// Construct from a raw pointer.
     explicit SharedArrayPtr(T* ptr) :
         ptr_(ptr),
         refCount_(new RefCount())
@@ -56,13 +56,13 @@ public:
         ++(refCount_->refs_);
     }
     
-    /// Destruct. Release the array reference
+    /// Destruct. Release the array reference.
     ~SharedArrayPtr()
     {
         Release();
     }
     
-    /// Assign from another shared array pointer
+    /// Assign from another shared array pointer.
     SharedArrayPtr<T>& operator = (const SharedArrayPtr<T>& rhs)
     {
         if (ptr_ == rhs.ptr_)
@@ -78,7 +78,7 @@ public:
         return *this;
     }
     
-    /// Assign from a raw pointer
+    /// Assign from a raw pointer.
     SharedArrayPtr<T>& operator = (T* ptr)
     {
         if (ptr_ == ptr)
@@ -96,30 +96,27 @@ public:
         return *this;
     }
     
-    /// Point to the array
+    /// Point to the array.
     T* operator -> () const { assert(ptr_); return ptr_; }
-    /// Dereference the array
+    /// Dereference the array.
     T& operator * () const { assert(ptr_); return *ptr_; }
-    /// Subscript the array
+    /// Subscript the array.
     T& operator [] (const int index) { assert(ptr_); return ptr_[index]; }
-    /// Test for equality with another shared array pointer
+    /// Test for equality with another shared array pointer.
     bool operator == (const SharedArrayPtr<T>& rhs) const { return ptr_ == rhs.ptr_; }
-    /// Test for inequality with another shared array pointer
+    /// Test for inequality with another shared array pointer.
     bool operator != (const SharedArrayPtr<T>& rhs) const { return ptr_ != rhs.ptr_; }
-    /// Test for less than with another array pointer
+    /// Test for less than with another array pointer.
     bool operator < (const SharedArrayPtr<T>& rhs) const { return ptr_ < rhs.ptr_; }
-    /// Return true if points to an array
+    /// Return true if points to an array.
     operator bool () const { return ptr_ != 0; }
-    /// Convert to a raw pointer
+    /// Convert to a raw pointer.
     operator T* () const { return ptr_; }
     
-    /// Reset to null and release the array reference
-    void Reset()
-    {
-        Release();
-    }
+    /// Reset to null and release the array reference.
+    void Reset() { Release(); }
     
-    /// Perform a static cast from a shared array pointer of another type
+    /// Perform a static cast from a shared array pointer of another type.
     template <class U> void StaticCast(const SharedArrayPtr<U>& rhs)
     {
         Release();
@@ -130,7 +127,7 @@ public:
             ++(refCount_->refs_);
     }
     
-    /// Perform a dynatic cast from a shared array pointer of another type
+    /// Perform a dynatic cast from a shared array pointer of another type.
     template <class U> void DynamicCast(const SharedArrayPtr<U>& rhs)
     {
         Release();
@@ -146,26 +143,26 @@ public:
             refCount_ = 0;
     }
     
-    /// Check if the pointer is null
+    /// Check if the pointer is null.
     bool Null() const { return ptr_ == 0; }
-    /// Check if the pointer is not null
+    /// Check if the pointer is not null.
     bool NotNull() const { return ptr_ != 0; }
-    /// Return the raw pointer
+    /// Return the raw pointer.
     T* Get() const { return ptr_; }
-    /// Return the array's reference count, or 0 if the pointer is null
+    /// Return the array's reference count, or 0 if the pointer is null.
     unsigned Refs() const { return refCount_ ? refCount_->refs_ : 0; }
-    /// Return the array's weak reference count, or 0 if the pointer is null
+    /// Return the array's weak reference count, or 0 if the pointer is null.
     unsigned WeakRefs() const { return refCount_ ? refCount_->weakRefs_ : 0; }
-    /// Return pointer to the RefCount structure
+    /// Return pointer to the RefCount structure.
     RefCount* RefCountPtr() const { return refCount_; }
-    /// Return hash value for HashSet & HashMap
+    /// Return hash value for HashSet & HashMap.
     unsigned ToHash() const { return ((unsigned)ptr_) / sizeof(T); }
     
 private:
-    /// Prevent direct assignment from a shared array pointer of different type
+    /// Prevent direct assignment from a shared array pointer of different type.
     template <class U> SharedArrayPtr<T>& operator = (const SharedArrayPtr<U>& rhs);
     
-    /// Release the array reference and delete it and the RefCount structure as applicable
+    /// Release the array reference and delete it and the RefCount structure if necessary.
     void Release()
     {
         if (refCount_)
@@ -188,13 +185,13 @@ private:
         refCount_ = 0;
     }
     
-    /// Pointer to the array
+    /// Pointer to the array.
     T* ptr_;
-    /// Pointer to the RefCount structure
+    /// Pointer to the RefCount structure.
     RefCount* refCount_;
 };
 
-/// Perform a static cast from one shared array pointer type to another
+/// Perform a static cast from one shared array pointer type to another.
 template <class T, class U> SharedArrayPtr<T> StaticCast(const SharedArrayPtr<U>& ptr)
 {
     SharedArrayPtr<T> ret;
@@ -202,7 +199,7 @@ template <class T, class U> SharedArrayPtr<T> StaticCast(const SharedArrayPtr<U>
     return ret;
 }
 
-/// Perform a dynamic cast from one shared array pointer type to another
+/// Perform a dynamic cast from one shared array pointer type to another.
 template <class T, class U> SharedArrayPtr<T> DynamicCast(const SharedArrayPtr<U>& ptr)
 {
     SharedArrayPtr<T> ret;
@@ -210,18 +207,18 @@ template <class T, class U> SharedArrayPtr<T> DynamicCast(const SharedArrayPtr<U
     return ret;
 }
 
-/// Weak array pointer template class. Uses non-intrusive reference counting
+/// Weak array pointer template class. Uses non-intrusive reference counting.
 template <class T> class WeakArrayPtr
 {
 public:
-    /// Construct a null weak array pointer
+    /// Construct a null weak array pointer.
     WeakArrayPtr() :
         ptr_(0),
         refCount_(0)
     {
     }
     
-    /// Construct from a shared array pointer
+    /// Construct from a shared array pointer.
     WeakArrayPtr(const SharedArrayPtr<T>& rhs) :
         ptr_(rhs.Get()),
         refCount_(rhs.RefCountPtr())
@@ -230,7 +227,7 @@ public:
             ++(refCount_->weakRefs_);
     }
     
-    /// Copy-construct from another weak array pointer
+    /// Copy-construct from another weak array pointer.
     WeakArrayPtr(const WeakArrayPtr<T>& rhs) :
         ptr_(rhs.ptr_),
         refCount_(rhs.refCount_)
@@ -239,13 +236,13 @@ public:
             ++(refCount_->weakRefs_);
     }
     
-    /// Destruct. Release the weak reference to the array
+    /// Destruct. Release the weak reference to the array.
     ~WeakArrayPtr()
     {
         Release();
     }
     
-    /// Assign from a shared array pointer
+    /// Assign from a shared array pointer.
     WeakArrayPtr<T>& operator = (const SharedArrayPtr<T>& rhs)
     {
         if (ptr_ == rhs.Get() && refCount_ == rhs.RefCountPtr())
@@ -261,7 +258,7 @@ public:
         return *this;
     }
     
-    /// Assign from another weak array pointer
+    /// Assign from another weak array pointer.
     WeakArrayPtr<T>& operator = (const WeakArrayPtr<T>& rhs)
     {
         if (ptr_ == rhs.ptr_ && refCount_ == rhs.refCount_)
@@ -277,7 +274,7 @@ public:
         return *this;
     }
     
-    /// Convert to shared array pointer. If expired, return a null shared array pointer
+    /// Convert to shared array pointer. If expired, return a null shared array pointer.
     SharedArrayPtr<T> Lock() const
     {
         if (Expired())
@@ -286,7 +283,7 @@ public:
             return SharedArrayPtr<T>(ptr_, refCount_);
     }
     
-    /// Return raw pointer. If expired, return null
+    /// Return raw pointer. If expired, return null.
     T* Get() const
     {
         if (Expired())
@@ -295,7 +292,7 @@ public:
             return ptr_;
     }
     
-    /// Point to the array
+    /// Point to the array.
     T* operator -> () const
     {
         T* rawPtr = Get();
@@ -303,7 +300,7 @@ public:
         return rawPtr;
     }
     
-    /// Dereference the array
+    /// Dereference the array.
     T& operator * () const
     {
         T* rawPtr = Get();
@@ -311,7 +308,7 @@ public:
         return *rawPtr;
     }
     
-    /// Subscript the array
+    /// Subscript the array.
     T& operator [] (const int index)
     {
         T* rawPtr = Get();
@@ -319,24 +316,21 @@ public:
         return (*rawPtr)[index];
     }
     
-    /// Test for equality with another weak array pointer
+    /// Test for equality with another weak array pointer.
     bool operator == (const WeakArrayPtr<T>& rhs) const { return ptr_ == rhs.ptr_ && refCount_ == rhs.refCount_; }
-    /// Test for inequality with another weak array pointer
+    /// Test for inequality with another weak array pointer.
     bool operator != (const WeakArrayPtr<T>& rhs) const { return ptr_ != rhs.ptr_ || refCount_ != rhs.refCount_; }
-    /// Test for less than with another weak array pointer
+    /// Test for less than with another weak array pointer.
     bool operator < (const WeakArrayPtr<T>& rhs) const { return ptr_ < rhs.ptr_; }
-    /// Return true if points to an array which is not expired
+    /// Return true if points to an array which is not expired.
     operator bool () const { return !Expired(); }
-    /// Convert to a raw pointer, null if array is expired
+    /// Convert to a raw pointer, null if array is expired.
     operator T* () const { return Get(); }
     
-    /// Reset to null and release the weak reference
-    void Reset()
-    {
-        Release();
-    }
+    /// Reset to null and release the weak reference.
+    void Reset() { Release(); }
     
-    /// Perform a static cast from a weak array pointer of another type
+    /// Perform a static cast from a weak array pointer of another type.
     template <class U> void StaticCast(const WeakArrayPtr<U>& rhs)
     {
         Release();
@@ -347,7 +341,7 @@ public:
             ++(refCount_->weakRefs_);
     }
     
-    /// Perform a dynamic cast from a weak array pointer of another type
+    /// Perform a dynamic cast from a weak array pointer of another type.
     template <class U> void DynamicCast(const WeakArrayPtr<U>& rhs)
     {
         Release();
@@ -363,26 +357,26 @@ public:
             refCount_ = 0;
     }
     
-    /// Check if the pointer is null
+    /// Check if the pointer is null.
     bool Null() const { return refCount_ == 0; }
-    /// Check if the pointer is not null
+    /// Check if the pointer is not null.
     bool NotNull() const { return refCount_ != 0; }
-    /// Return the array's reference count, or 0 if null pointer or if array is expired
+    /// Return the array's reference count, or 0 if null pointer or if array is expired.
     unsigned Refs() const { return refCount_ ? refCount_->refs_ : 0; }
-    /// Return the array's weak reference count
+    /// Return the array's weak reference count.
     unsigned WeakRefs() const { return refCount_ ? refCount_->weakRefs_ : 0; }
-    /// Return whether the array has expired. If null pointer, always return true
+    /// Return whether the array has expired. If null pointer, always return true.
     bool Expired() const { return refCount_ ? refCount_->expired_ : true; }
-    /// Return pointer to RefCount structure
+    /// Return pointer to RefCount structure.
     RefCount* RefCountPtr() const { return refCount_; }
-    /// Return hash value for HashSet & HashMap
+    /// Return hash value for HashSet & HashMap.
     unsigned ToHash() const { return ((unsigned)ptr_) / sizeof(T); }
     
 private:
-    /// Prevent direct assignment from a weak array pointer of different type
+    /// Prevent direct assignment from a weak array pointer of different type.
     template <class U> WeakArrayPtr<T>& operator = (const WeakArrayPtr<U>& rhs);
     
-    /// Release the weak reference. Delete the Refcount structure if the array has expired and this was the last weak reference
+    /// Release the weak reference. Delete the Refcount structure if necessary.
     void Release()
     {
         if (refCount_)
@@ -398,13 +392,13 @@ private:
         refCount_ = 0;
     }
     
-    /// Pointer to the array
+    /// Pointer to the array.
     T* ptr_;
-    /// Pointer to the RefCount structure
+    /// Pointer to the RefCount structure.
     RefCount* refCount_;
 };
 
-/// Perform a static cast from one weak array pointer type to another
+/// Perform a static cast from one weak array pointer type to another.
 template <class T, class U> WeakArrayPtr<T> StaticCast(const WeakArrayPtr<U>& ptr)
 {
     WeakArrayPtr<T> ret;
@@ -412,7 +406,7 @@ template <class T, class U> WeakArrayPtr<T> StaticCast(const WeakArrayPtr<U>& pt
     return ret;
 }
 
-/// Perform a dynamic cast from one weak pointer type to another
+/// Perform a dynamic cast from one weak pointer type to another.
 template <class T, class U> WeakArrayPtr<T> DynamicCast(const WeakArrayPtr<U>& ptr)
 {
     WeakArrayPtr<T> ret;

+ 13 - 13
Engine/Container/Hash.h

@@ -23,79 +23,79 @@
 
 #pragma once
 
-/// Pointer hash function
+/// Pointer hash function.
 template <class T> unsigned MakeHash(T* value)
 {
     return ((unsigned)value) / sizeof(T);
 }
 
-/// Const pointer hash function
+/// Const pointer hash function.
 template <class T> unsigned MakeHash(const T* value)
 {
     return ((unsigned)value) / sizeof(T);
 }
 
-/// Generic hash function
+/// Generic hash function.
 template <class T> unsigned MakeHash(const T& value)
 {
     return value.ToHash();
 }
 
-/// Void pointer hash function
+/// Void pointer hash function.
 template<> inline unsigned MakeHash(void* value)
 {
     return (unsigned)value;
 }
 
-/// Const void pointer hash function
+/// Const void pointer hash function.
 template<> inline unsigned MakeHash(const void* value)
 {
     return (unsigned)value;
 }
 
-/// Long long hash function
+/// Long long hash function.
 template<> inline unsigned MakeHash(const long long& value)
 {
     return (value >> 32) | (value & 0xffffffff);
 }
 
-/// Unsigned long long hash function
+/// Unsigned long long hash function.
 template<> inline unsigned MakeHash(const unsigned long long& value)
 {
     return (value >> 32) | (value & 0xffffffff);
 }
 
-/// Int hash function
+/// Int hash function.
 template<> inline unsigned MakeHash(const int& value)
 {
     return value;
 }
 
-/// Unsigned hash function
+/// Unsigned hash function.
 template<> inline unsigned MakeHash(const unsigned& value)
 {
     return value;
 }
 
-/// Short hash function
+/// Short hash function.
 template<> inline unsigned MakeHash(const short& value)
 {
     return value;
 }
 
-/// Unsigned short hash function
+/// Unsigned short hash function.
 template<> inline unsigned MakeHash(const unsigned short& value)
 {
     return value;
 }
 
-/// Char hash function
+/// Char hash function.
 template<> inline unsigned MakeHash(const char& value)
 {
     return value;
 }
 
-/// Unsigned char hash function
+/// Unsigned char hash function.
 template<> inline unsigned MakeHash(const unsigned char& value)
 {
     return value;

+ 23 - 23
Engine/Container/HashBase.h

@@ -27,10 +27,10 @@
 #include "Hash.h"
 #include "Swap.h"
 
-/// Hash set/map node base
+/// Hash set/map node base.
 struct HashNodeBase
 {
-    /// Construct
+    /// Construct.
     HashNodeBase() :
         prev_(0),
         next_(0),
@@ -38,57 +38,57 @@ struct HashNodeBase
     {
     }
     
-    /// Previous node
+    /// Previous node.
     HashNodeBase* prev_;
-    /// Next node
+    /// Next node.
     HashNodeBase* next_;
-    /// Next node in the bucket
+    /// Next node in the bucket.
     HashNodeBase* down_;
 };
 
-/// Hash set/map iterator base class
+/// Hash set/map iterator base class.
 class HashIteratorBase
 {
 public:
-    /// Construct
+    /// Construct.
     explicit HashIteratorBase(HashNodeBase* ptr) :
         ptr_(ptr)
     {
     }
 
-    /// Test for equality with another iterator
+    /// Test for equality with another iterator.
     bool operator == (const HashIteratorBase& rhs) const { return ptr_ == rhs.ptr_; }
-    /// Test for inequality with another iterator
+    /// Test for inequality with another iterator.
     bool operator != (const HashIteratorBase& rhs) const { return ptr_ != rhs.ptr_; }
 
-    /// Go to the next node
+    /// Go to the next node.
     void GotoNext()
     {
         if (ptr_)
             ptr_ = ptr_->next_;
     }
 
-    /// Go to the previous node
+    /// Go to the previous node.
     void GotoPrev()
     {
         if (ptr_)
             ptr_ = ptr_->prev_;
     }
 
-    /// Node pointer
+    /// Node pointer.
     HashNodeBase* ptr_;
 };
 
-/// Hash set/map base class
+/// Hash set/map base class.
 class HashBase
 {
 public:
-    /// Initial amount of buckets
+    /// Initial amount of buckets.
     static const unsigned MIN_BUCKETS = 8;
-    /// Maximum load factor
+    /// Maximum load factor.
     static const unsigned MAX_LOAD_FACTOR = 4;
     
-    /// Construct
+    /// Construct.
     HashBase() :
         ptrs_(0),
         allocator_(0),
@@ -97,7 +97,7 @@ public:
     {
     }
 
-    /// Swap with another hash set or map
+    /// Swap with another hash set or map.
     void Swap(HashBase& rhs)
     {
         ::Swap(head_, rhs.head_);
@@ -109,16 +109,16 @@ public:
     }
 
 protected:
-    /// List head node pointer
+    /// List head node pointer.
     HashNodeBase* head_;
-    /// List tail node pointer
+    /// List tail node pointer.
     HashNodeBase* tail_;
-    /// Bucket head pointers
+    /// Bucket head pointers.
     HashNodeBase** ptrs_;
-    /// Node allocator
+    /// Node allocator.
     AllocatorBlock* allocator_;
-    /// Number of nodes
+    /// Number of nodes.
     unsigned size_;
-    /// Number of buckets
+    /// Number of buckets.
     unsigned numBuckets_;
 };

+ 74 - 82
Engine/Container/HashMap.h

@@ -26,122 +26,122 @@
 #include "HashBase.h"
 #include "Pair.h"
 
-/// Hash map template class
+/// Hash map template class.
 template <class T, class U> class HashMap : public HashBase
 {
 public:
-    /// Hash map key-value pair with const key
+    /// Hash map key-value pair with const key.
     class KeyValue
     {
     public:
-        /// Construct with default key
+        /// Construct with default key.
         KeyValue() :
             first_(T())
         {
         }
         
-        /// Construct with key and value
+        /// Construct with key and value.
         KeyValue(const T& first, const U& second) :
             first_(first),
             second_(second)
         {
         }
         
-        /// Test for equality with another pair
+        /// Test for equality with another pair.
         bool operator == (const KeyValue& rhs) const { return first_ == rhs.first_ && second_ == rhs.second_; }
-        /// Test for inequality with another pair
+        /// Test for inequality with another pair.
         bool operator != (const KeyValue& rhs) const { return first_ != rhs.first_ || second_ != rhs.second_; }
         
-        /// Key
+        /// Key.
         const T first_;
-        /// Value
+        /// Value.
         U second_;
     };
     
-    /// Hash map node
+    /// Hash map node.
     struct Node : public HashNodeBase
     {
-        /// Construct undefined
+        /// Construct undefined.
         Node()
         {
         }
         
-        /// Construct with key and value
+        /// Construct with key and value.
         Node(const T& key, const U& value) :
             pair_(key, value)
         {
         }
         
-        /// Key-value pair
+        /// Key-value pair.
         KeyValue pair_;
         
-        /// Return next node
+        /// Return next node.
         Node* Next() const { return static_cast<Node*>(next_); }
-        /// Return previous node
+        /// Return previous node.
         Node* Prev() const { return static_cast<Node*>(prev_); }
-        /// Return next node in the bucket
+        /// Return next node in the bucket.
         Node* Down() const { return static_cast<Node*>(down_); }
     };
     
-    /// Hash map node iterator
+    /// Hash map node iterator.
     class Iterator : public HashIteratorBase
     {
     public:
-        /// Construct
+        /// Construct.
         Iterator(Node* ptr) :
             HashIteratorBase(ptr)
         {
         }
         
-        /// Preincrement the pointer
+        /// Preincrement the pointer.
         Iterator& operator ++ () { GotoNext(); return *this; }
-        /// Postincrement the pointer
+        /// Postincrement the pointer.
         Iterator operator ++ (int) { Iterator it = *this; GotoNext(); return it; }
-        /// Predecrement the pointer
+        /// Predecrement the pointer.
         Iterator& operator -- () { GotoPrev(); return *this; }
-        /// Postdecrement the pointer
+        /// Postdecrement the pointer.
         Iterator operator -- (int) { Iterator it = *this; GotoPrev(); return it; }
         
-        /// Point to the pair
+        /// Point to the pair.
         KeyValue* operator -> () const { return &(static_cast<Node*>(ptr_))->pair_; }
-        /// Dereference the pair
+        /// Dereference the pair.
         KeyValue& operator * () const { return (static_cast<Node*>(ptr_))->pair_; }
     };
     
-    /// Hash map node const iterator
+    /// Hash map node const iterator.
     class ConstIterator : public HashIteratorBase
     {
     public:
-        /// Construct
+        /// Construct.
         ConstIterator(Node* ptr) :
             HashIteratorBase(ptr)
         {
         }
         
-        /// Construct from a non-const iterator
+        /// Construct from a non-const iterator.
         ConstIterator(const Iterator& rhs) :
             HashIteratorBase(rhs.ptr_)
         {
         }
         
-        /// Assign from a non-const iterator
+        /// Assign from a non-const iterator.
         ConstIterator& operator = (const Iterator& rhs) { ptr_ = rhs.ptr_; return *this; }
-        /// Preincrement the pointer
+        /// Preincrement the pointer.
         ConstIterator& operator ++ () { GotoNext(); return *this; }
-        /// Postincrement the pointer
+        /// Postincrement the pointer.
         ConstIterator operator ++ (int) { ConstIterator it = *this; GotoNext(); return it; }
-        /// Predecrement the pointer
+        /// Predecrement the pointer.
         ConstIterator& operator -- () { GotoPrev(); return *this; }
-        /// Postdecrement the pointer
+        /// Postdecrement the pointer.
         ConstIterator operator -- (int) { ConstIterator it = *this; GotoPrev(); return it; }
         
-        /// Point to the pair
+        /// Point to the pair.
         const KeyValue* operator -> () const { return &(static_cast<Node*>(ptr_))->pair_; }
-        /// Dereference the pair
+        /// Dereference the pair.
         const KeyValue& operator * () const { return (static_cast<Node*>(ptr_))->pair_; }
     };
     
-    /// Construct empty
+    /// Construct empty.
     HashMap()
     {
         // Reserve the tail node
@@ -149,17 +149,16 @@ public:
         head_ = tail_ = ReserveNode();
     }
     
-    /// Construct from another hash map
+    /// Construct from another hash map.
     HashMap(const HashMap<T, U>& map)
     {
         // Reserve the tail node
         allocator_ = AllocatorInitialize(sizeof(Node));
         head_ = tail_ = ReserveNode();
-        
         *this = map;
     }
     
-    /// Destruct
+    /// Destruct.
     ~HashMap()
     {
         Clear();
@@ -168,30 +167,29 @@ public:
         delete[] ptrs_;
     }
     
-    /// Assign a hash map
+    /// Assign a hash map.
     HashMap& operator = (const HashMap<T, U>& rhs)
     {
         Clear();
         Insert(rhs);
-        
         return *this;
     }
     
-    /// Add-assign a pair
+    /// Add-assign a pair.
     HashMap& operator += (const Pair<T, U>& rhs)
     {
         Insert(rhs);
         return *this;
     }
     
-    /// Add-assign a hash map
+    /// Add-assign a hash map.
     HashMap& operator += (const HashMap<T, U>& rhs)
     {
         Insert(rhs);
         return *this;
     }
     
-    /// Test for equality with another hash map. Warning: this is much slower than checking equality of two maps
+    /// Test for equality with another hash map. Warning: this is much slower than checking equality of two maps.
     bool operator == (const HashMap<T, U>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -209,7 +207,7 @@ public:
         return true;
     }
     
-    /// Test for inequality with another hash map. Warning: this is much slower than checking inequality of two maps
+    /// Test for inequality with another hash map. Warning: this is much slower than checking inequality of two maps.
     bool operator != (const HashMap<T, U>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -227,7 +225,7 @@ public:
         return false;
     }
     
-    /// Index the map. Create a new pair if key not found
+    /// Index the map. Create a new pair if key not found.
     U& operator [] (const T& key)
     {
         if (!numBuckets_)
@@ -242,13 +240,13 @@ public:
             return InsertNode(key, U())->pair_.second_;
     }
     
-    /// Insert a pair. Return an iterator to it
+    /// Insert a pair. Return an iterator to it.
     Iterator Insert(const Pair<T, U>& pair)
     {
         return Iterator(InsertNode(pair.first_, pair.second_));
     }
     
-    /// Insert a map
+    /// Insert a map.
     void Insert(const HashMap<T, U>& map)
     {
         ConstIterator it = map.Begin();
@@ -260,13 +258,10 @@ public:
         }
     }
     
-    /// Insert a pair by iterator. Return iterator to the value
-    Iterator Insert(const ConstIterator& it)
-    {
-        return Iterator(InsertNode(it->first_, it->second_));
-    }
+    /// Insert a pair by iterator. Return iterator to the value.
+    Iterator Insert(const ConstIterator& it) { return Iterator(InsertNode(it->first_, it->second_)); }
     
-    /// Insert a range by iterators
+    /// Insert a range by iterators.
     void Insert(const ConstIterator& start, const ConstIterator& end)
     {
         ConstIterator it = start;
@@ -274,7 +269,7 @@ public:
             InsertNode(*it++);
     }
     
-    /// Erase a pair by key. Return true if was found
+    /// Erase a pair by key. Return true if was found.
     bool Erase(const T& key)
     {
         if (!numBuckets_)
@@ -296,13 +291,10 @@ public:
         return true;
     }
     
-    /// Erase a pair by iterator
-    void Erase(const Iterator& it)
-    {
-        Erase(it->first_);
-    }
+    /// Erase a pair by iterator.
+    void Erase(const Iterator& it) { Erase(it->first_); }
     
-    /// Clear the map
+    /// Clear the map.
     void Clear()
     {
         while (size_)
@@ -313,7 +305,7 @@ public:
             ptrs_[i] = 0;
     }
     
-    /// Return iterator to the pair with key, or end iterator if not found
+    /// Return iterator to the pair with key, or end iterator if not found.
     Iterator Find(const T& key)
     {
         if (!numBuckets_)
@@ -327,7 +319,7 @@ public:
             return End();
     }
     
-    /// Return const iterator to the pair with key, or end iterator if not found
+    /// Return const iterator to the pair with key, or end iterator if not found.
     ConstIterator Find(const T& key) const
     {
         if (!numBuckets_)
@@ -341,7 +333,7 @@ public:
             return End();
     }
     
-    /// Return whether contains a pair with key
+    /// Return whether contains a pair with key.
     bool Contains(const T& key) const
     {
         if (!numBuckets_)
@@ -351,32 +343,32 @@ public:
         return FindNode(key, hashKey) != 0;
     }
     
-    /// Return iterator to the beginning
+    /// Return iterator to the beginning.
     Iterator Begin() { return Iterator(Head()); }
-    /// Return iterator to the beginning
+    /// Return iterator to the beginning.
     ConstIterator Begin() const { return ConstIterator(Head()); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     Iterator End() { return Iterator(Tail()); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     ConstIterator End() const { return ConstIterator(Tail()); }
-    /// Return first key
+    /// Return first key.
     const T& Front() const { return *Begin(); }
-    /// Return last key
+    /// Return last key.
     const T& Back() const { return *(--End()); }
-    /// Return number of key-value pairs
+    /// Return number of key-value pairs.
     unsigned Size() const { return size_; }
-    /// Return whether map is empty
+    /// Return whether map is empty.
     bool Empty() const { return size_ == 0; }
     
 private:
-    /// Return the head pointer with correct type
+    /// Return the head pointer with correct type.
     Node* Head() const { return reinterpret_cast<Node*>(head_); }
-    /// Return the tail pointer with correct type
+    /// Return the tail pointer with correct type.
     Node* Tail() const { return reinterpret_cast<Node*>(tail_); }
-    /// Return the bucket pointers with correct type
+    /// Return the bucket pointers with correct type.
     Node** Ptrs() const { return reinterpret_cast<Node**>(ptrs_); }
     
-    /// Find a node from the buckets
+    /// Find a node from the buckets.
     Node* FindNode(const T& key, unsigned hashKey) const
     {
         Node** ptrs = Ptrs();
@@ -394,7 +386,7 @@ private:
         return 0;
     }
     
-    /// Find a node and the previous node from the buckets
+    /// Find a node and the previous node from the buckets.
     Node* FindNode(const T& key, unsigned hashKey, Node*& previous) const
     {
         previous = 0;
@@ -415,7 +407,7 @@ private:
         return 0;
     }
     
-    /// Insert a key and value and return either the new or existing node
+    /// Insert a key and value and return either the new or existing node.
     Node* InsertNode(const T& key, const U& value)
     {
         // If no pointers yet, allocate with minimum bucket count
@@ -450,7 +442,7 @@ private:
         return newNode;
     }
     
-    /// Insert a node into the list. Return the new node
+    /// Insert a node into the list. Return the new node.
     Node* InsertNode(Node* dest, const T& key, const U& value)
     {
         if (!dest)
@@ -473,7 +465,7 @@ private:
         return newNode;
     }
     
-    /// Erase a node from the list. Return pointer to the next element, or to the end if could not erase
+    /// Erase a node from the list. Return pointer to the next element, or to the end if could not erase.
     Node* EraseNode(Node* toRemove)
     {
         // The tail node can not be removed
@@ -496,7 +488,7 @@ private:
         return next;
     }
     
-    /// Reserve a node
+    /// Reserve a node.
     Node* ReserveNode()
     {
         Node* newNode = static_cast<Node*>(AllocatorReserve(allocator_));
@@ -504,7 +496,7 @@ private:
         return newNode;
     }
     
-    /// Reserve a node with specified key and value
+    /// Reserve a node with specified key and value.
     Node* ReserveNode(const T& key, const U& value)
     {
         if (!allocator_)
@@ -514,14 +506,14 @@ private:
         return newNode;
     }
     
-    /// Free a node
+    /// Free a node.
     void FreeNode(Node* node)
     {
         (node)->~Node();
         AllocatorFree(allocator_, node);
     }
     
-    /// Reallocate and rehash the buckets
+    /// Reallocate and rehash the buckets.
     void Rehash()
     {
         delete[] ptrs_;

+ 63 - 68
Engine/Container/HashSet.h

@@ -25,94 +25,94 @@
 
 #include "HashBase.h"
 
-/// Hash set template class
+/// Hash set template class.
 template <class T> class HashSet : public HashBase
 {
 public:
-    /// Hash set node
+    /// Hash set node.
     struct Node : public HashNodeBase
     {
-        // Construct undefined
+        /// Construct undefined.
         Node()
         {
         }
         
-        /// Construct with key
+        /// Construct with key.
         Node(const T& key) :
             key_(key)
         {
         }
         
-        /// Key
+        /// Key.
         T key_;
         
-        /// Return next node
+        /// Return next node.
         Node* Next() const { return static_cast<Node*>(next_); }
-        /// Return previous node
+        /// Return previous node.
         Node* Prev() const { return static_cast<Node*>(prev_); }
-        /// Return next node in the bucket
+        /// Return next node in the bucket.
         Node* Down() const { return static_cast<Node*>(down_); }
     };
     
-    /// Hash set node iterator
+    /// Hash set node iterator.
     class Iterator : public HashIteratorBase
     {
     public:
-        /// Construct
+        /// Construct.
         Iterator(Node* ptr) :
             HashIteratorBase(ptr)
         {
         }
         
-        /// Preincrement the pointer
+        /// Preincrement the pointer.
         Iterator& operator ++ () { GotoNext(); return *this; }
-        /// Postincrement the pointer
+        /// Postincrement the pointer.
         Iterator operator ++ (int) { Iterator it = *this; GotoNext(); return it; }
-        /// Predecrement the pointer
+        /// Predecrement the pointer.
         Iterator& operator -- () { GotoPrev(); return *this; }
-        /// Postdecrement the pointer
+        /// Postdecrement the pointer.
         Iterator operator -- (int) { Iterator it = *this; GotoPrev(); return it; }
         
-        /// Point to the key
+        /// Point to the key.
         const T* operator -> () const { return &(static_cast<Node*>(ptr_))->key_; }
-        /// Dereference the key
+        /// Dereference the key.
         const T& operator * () const { return (static_cast<Node*>(ptr_))->key_; }
     };
     
-    /// Hash set node const iterator
+    /// Hash set node const iterator.
     class ConstIterator : public HashIteratorBase
     {
     public:
-        /// Construct
+        /// Construct.
         ConstIterator(Node* ptr) :
             HashIteratorBase(ptr)
         {
         }
         
-        /// Construct from a non-const iterator
+        /// Construct from a non-const iterator.
         ConstIterator(const Iterator& rhs) :
             HashIteratorBase(rhs.ptr_)
         {
         }
         
-        /// Assign from a non-const iterator
+        /// Assign from a non-const iterator.
         ConstIterator& operator = (const Iterator& rhs) { ptr_ = rhs.ptr_; return *this; }
-        /// Preincrement the pointer
+        /// Preincrement the pointer.
         ConstIterator& operator ++ () { GotoNext(); return *this; }
-        /// Postincrement the pointer
+        /// Postincrement the pointer.
         ConstIterator operator ++ (int) { ConstIterator it = *this; GotoNext(); return it; }
-        /// Predecrement the pointer
+        /// Predecrement the pointer.
         ConstIterator& operator -- () { GotoPrev(); return *this; }
-        /// Postdecrement the pointer
+        /// Postdecrement the pointer.
         ConstIterator operator -- (int) { ConstIterator it = *this; GotoPrev(); return it; }
         
-        /// Point to the key
+        /// Point to the key.
         const T* operator -> () const { return &(static_cast<Node*>(ptr_))->key_; }
-        /// Dereference the key
+        /// Dereference the key.
         const T& operator * () const { return (static_cast<Node*>(ptr_))->key_; }
     };
     
-    /// Construct empty
+    /// Construct empty.
     HashSet()
     {
         // Reserve the tail node
@@ -120,17 +120,16 @@ public:
         head_ = tail_ = ReserveNode();
     }
     
-    /// Construct from another hash set
+    /// Construct from another hash set.
     HashSet(const HashSet<T>& set)
     {
         // Reserve the tail node
         allocator_ = AllocatorInitialize(sizeof(Node));
         head_ = tail_ = ReserveNode();
-        
         *this = set;
     }
     
-    /// Destruct
+    /// Destruct.
     ~HashSet()
     {
         Clear();
@@ -139,30 +138,29 @@ public:
         delete[] ptrs_;
     }
     
-    /// Assign a hash set
+    /// Assign a hash set.
     HashSet& operator = (const HashSet<T>& rhs)
     {
         Clear();
         Insert(rhs);
-        
         return *this;
     }
     
-    /// Add-assign a value
+    /// Add-assign a value.
     HashSet& operator += (const T& rhs)
     {
         Insert(rhs);
         return *this;
     }
     
-    /// Add-assign a hash set
+    /// Add-assign a hash set.
     HashSet& operator += (const HashSet<T>& rhs)
     {
         Insert(rhs);
         return *this;
     }
     
-    /// Test for equality with another hash set. Warning: this is much slower than checking equality of two sets
+    /// Test for equality with another hash set. Warning: this is much slower than checking equality of two sets.
     bool operator == (const HashSet<T>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -179,7 +177,7 @@ public:
         return true;
     }
     
-    /// Test for inequality with another hash set. Warning: this is much slower than checking inequality of two sets
+    /// Test for inequality with another hash set. Warning: this is much slower than checking inequality of two sets.
     bool operator != (const HashSet<T>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -196,7 +194,7 @@ public:
         return false;
     }
     
-    /// Insert a key. Return an iterator to it
+    /// Insert a key. Return an iterator to it.
     Iterator Insert(const T& key)
     {
         // If no pointers yet, allocate with minimum bucket count
@@ -227,7 +225,7 @@ public:
         return Iterator(newNode);
     }
     
-    /// Insert a set
+    /// Insert a set.
     void Insert(const HashSet<T>& set)
     {
         ConstIterator it = set.Begin();
@@ -236,13 +234,13 @@ public:
             Insert(*it++);
     }
     
-    /// Insert a key by iterator. Return iterator to the value
+    /// Insert a key by iterator. Return iterator to the value.
     Iterator Insert(const ConstIterator& it)
     {
         return Iterator(InsertNode(*it));
     }
     
-    /// Erase a key. Return true if was found
+    /// Erase a key. Return true if was found.
     bool Erase(const T& key)
     {
         if (!numBuckets_)
@@ -264,13 +262,10 @@ public:
         return true;
     }
     
-    /// Erase a key by iterator
-    void Erase(const Iterator& it)
-    {
-        Erase(*it);
-    }
+    /// Erase a key by iterator.
+    void Erase(const Iterator& it) { Erase(*it); }
     
-    /// Clear the set
+    /// Clear the set.
     void Clear()
     {
         while (size_)
@@ -281,7 +276,7 @@ public:
             ptrs_[i] = 0;
     }
     
-    /// Return iterator to the key, or end iterator if not found
+    /// Return iterator to the key, or end iterator if not found.
     Iterator Find(const T& key)
     {
         if (!numBuckets_)
@@ -295,7 +290,7 @@ public:
             return End();
     }
     
-    /// Return const iterator to the key, or end iterator if not found
+    /// Return const iterator to the key, or end iterator if not found.
     ConstIterator Find(const T& key) const
     {
         if (!numBuckets_)
@@ -309,7 +304,7 @@ public:
             return End();
     }
     
-    /// Return whether contains a key
+    /// Return whether contains a key.
     bool Contains(const T& key) const
     {
         if (!numBuckets_)
@@ -319,32 +314,32 @@ public:
         return FindNode(key, hashKey) != 0;
     }
     
-    /// Return iterator to the beginning
+    /// Return iterator to the beginning.
     Iterator Begin() { return Iterator(Head()); }
-    /// Return iterator to the beginning
+    /// Return iterator to the beginning.
     ConstIterator Begin() const { return ConstIterator(Head()); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     Iterator End() { return Iterator(Tail()); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     ConstIterator End() const { return ConstIterator(Tail()); }
-    /// Return first key
+    /// Return first key.
     const T& Front() const { return *Begin(); }
-    /// Return last key
+    /// Return last key.
     const T& Back() const { return *(--End()); }
-    /// Return number of keys
+    /// Return number of keys.
     unsigned Size() const { return size_; }
-    /// Return whether set is empty
+    /// Return whether set is empty.
     bool Empty() const { return size_ == 0; }
     
 private:
-    /// Return the head pointer with correct type
+    /// Return the head pointer with correct type.
     Node* Head() const { return reinterpret_cast<Node*>(head_); }
-    /// Return the tail pointer with correct type
+    /// Return the tail pointer with correct type.
     Node* Tail() const { return reinterpret_cast<Node*>(tail_); }
-    /// Return the bucket pointers with correct type
+    /// Return the bucket pointers with correct type.
     Node** Ptrs() const { return reinterpret_cast<Node**>(ptrs_); }
     
-    /// Find a node from the buckets
+    /// Find a node from the buckets.
     Node* FindNode(const T& key, unsigned hashKey) const
     {
         Node** ptrs = Ptrs();
@@ -362,7 +357,7 @@ private:
         return 0;
     }
     
-    /// Find a node and the previous node from the buckets
+    /// Find a node and the previous node from the buckets.
     Node* FindNode(const T& key, unsigned hashKey, Node*& previous) const
     {
         previous = 0;
@@ -383,7 +378,7 @@ private:
         return 0;
     }
     
-    /// Insert a node into the list. Return the new node
+    /// Insert a node into the list. Return the new node.
     Node* InsertNode(Node* dest, const T& key)
     {
         if (!dest)
@@ -406,7 +401,7 @@ private:
         return newNode;
     }
     
-    /// Erase a node from the list. Return pointer to the next element, or to the end if could not erase
+    /// Erase a node from the list. Return pointer to the next element, or to the end if could not erase.
     Node* EraseNode(Node* toRemove)
     {
         // The tail node can not be removed
@@ -429,7 +424,7 @@ private:
         return next;
     }
     
-    /// Reserve a node
+    /// Reserve a node.
     Node* ReserveNode()
     {
         Node* newNode = static_cast<Node*>(AllocatorReserve(allocator_));
@@ -437,7 +432,7 @@ private:
         return newNode;
     }
     
-    /// Reserve a node with specified key
+    /// Reserve a node with specified key.
     Node* ReserveNode(const T& key)
     {
         if (!allocator_)
@@ -447,14 +442,14 @@ private:
         return newNode;
     }
     
-    /// Free a node
+    /// Free a node.
     void FreeNode(Node* node)
     {
         (node)->~Node();
         AllocatorFree(allocator_, node);
     }
     
-    /// Reallocate and rehash the buckets
+    /// Reallocate and rehash the buckets.
     void Rehash()
     {
         delete[] ptrs_;

+ 68 - 88
Engine/Container/List.h

@@ -25,111 +25,107 @@
 
 #include "ListBase.h"
 
-/// Linked list template class
+/// Linked list template class.
 template <class T> class List : public ListBase
 {
 public:
-    /// List node
+    /// List node.
     struct Node : public ListNodeBase
     {
-        /// Construct undefined
+        /// Construct undefined.
         Node()
         {
         }
         
-        /// Construct with value
+        /// Construct with value.
         Node(const T& value) :
             value_(value)
         {
         }
         
-        /// Node value
+        /// Node value.
         T value_;
         
-        /// Return next node
+        /// Return next node.
         Node* Next() const { return static_cast<Node*>(next_); }
-        /// Return previous node
+        /// Return previous node.
         Node* Prev() { return static_cast<Node*>(prev_); }
     };
     
-    /// List iterator
+    /// List iterator.
     class Iterator : public ListIteratorBase
     {
     public:
-        /// Construct
+        /// Construct.
         explicit Iterator(Node* ptr) :
             ListIteratorBase(ptr)
         {
         }
         
-        /// Preincrement the pointer
+        /// Preincrement the pointer.
         Iterator& operator ++ () { GotoNext(); return *this; }
-        /// Postincrement the pointer
+        /// Postincrement the pointer.
         Iterator operator ++ (int) { Iterator it = *this; GotoNext(); return it; }
-        /// Predecrement the pointer
+        /// Predecrement the pointer.
         Iterator& operator -- () { GotoPrev(); return *this; }
-        /// Postdecrement the pointer
+        /// Postdecrement the pointer.
         Iterator operator -- (int) { Iterator it = *this; GotoPrev(); return it; }
         
-        /// Point to the node value
+        /// Point to the node value.
         T* operator -> () const { return &(static_cast<Node*>(ptr_))->value_; }
-        /// Dereference the node value
+        /// Dereference the node value.
         T& operator * () const { return (static_cast<Node*>(ptr_))->value_; }
     };
     
-    /// List const iterator
+    /// List const iterator.
     class ConstIterator : public ListIteratorBase
     {
     public:
-        /// Construct
+        /// Construct.
         explicit ConstIterator(Node* ptr) :
             ListIteratorBase(ptr)
         {
         }
         
-        /// Construct from a non-const iterator
+        /// Construct from a non-const iterator.
         ConstIterator(const Iterator& rhs) :
             ListIteratorBase(rhs.ptr_)
         {
         }
         
-        /// Assign from a non-const iterator
+        /// Assign from a non-const iterator.
         ConstIterator& operator = (const Iterator& rhs) { ptr_ = rhs.ptr_; return *this; }
-        /// Preincrement the pointer
+        /// Preincrement the pointer.
         ConstIterator& operator ++ () { GotoNext(); return *this; }
-        /// Postincrement the pointer
+        /// Postincrement the pointer.
         ConstIterator operator ++ (int) { ConstIterator it = *this; GotoNext(); return it; }
-        /// Predecrement the pointer
+        /// Predecrement the pointer.
         ConstIterator& operator -- () { GotoPrev(); return *this; }
-        /// Postdecrement the pointer
+        /// Postdecrement the pointer.
         ConstIterator operator -- (int) { ConstIterator it = *this; GotoPrev(); return it; }
         
-        /// Point to the node value
+        /// Point to the node value.
         const T* operator -> () const { return &(static_cast<Node*>(ptr_))->value_; }
-        /// Dereference the node value
+        /// Dereference the node value.
         const T& operator * () const { return (static_cast<Node*>(ptr_))->value_; }
     };
 
-    /// Construct empty
+    /// Construct empty.
     List()
     {
-        // Reserve the tail node
         allocator_ = AllocatorInitialize(sizeof(Node));
         head_ = tail_ = ReserveNode();
     }
     
-    /// Construct from another list
+    /// Construct from another list.
     List(const List<T>& list)
     {
-        // Reserve the tail node
         allocator_ = AllocatorInitialize(sizeof(Node));
         head_ = tail_ = ReserveNode();
-        
-        // Then assign the other list
         *this = list;
     }
     
-    /// Destruct
+    /// Destruct.
     ~List()
     {
         Clear();
@@ -137,31 +133,30 @@ public:
         AllocatorUninitialize(allocator_);
     }
     
-    /// Assign from another list
+    /// Assign from another list.
     List& operator = (const List<T>& rhs)
     {
         // Clear, then insert the nodes of the other list
         Clear();
         Insert(End(), rhs);
-        
         return *this;
     }
     
-    /// Add-assign an element
+    /// Add-assign an element.
     List& operator += (const T& rhs)
     {
         Push(rhs);
         return *this;
     }
     
-    /// Add-assign a list
+    /// Add-assign a list.
     List& operator += (const List<T>& rhs)
     {
         Insert(End(), rhs);
         return *this;
     }
     
-    /// Test for equality with another list
+    /// Test for equality with another list.
     bool operator == (const List<T>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -180,7 +175,7 @@ public:
         return true;
     }
     
-    /// Test for inequality with another list
+    /// Test for inequality with another list.
     bool operator != (const List<T>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -199,25 +194,14 @@ public:
         return false;
     }
     
-    /// Insert an element to the end
-    void Push(const T& value)
-    {
-        InsertNode(Tail(), value);
-    }
-    
-    /// Insert an element to the beginning
-    void PushFront(const T& value)
-    {
-        InsertNode(Head(), value);
-    }
+    /// Insert an element to the end.
+    void Push(const T& value) { InsertNode(Tail(), value); }
+    /// Insert an element to the beginning.
+    void PushFront(const T& value) { InsertNode(Head(), value); }
+    /// Insert an element at position.
+    void Insert(const Iterator& dest, const T& value) { InsertNode(static_cast<Node*>(dest.ptr_), value); }
     
-    /// Insert an element at position
-    void Insert(const Iterator& dest, const T& value)
-    {
-        InsertNode(static_cast<Node*>(dest.ptr_), value);
-    }
-    
-    /// Insert a list at position
+    /// Insert a list at position.
     void Insert(const Iterator& dest, const List<T>& list)
     {
         Node* destNode = static_cast<Node*>(dest.ptr_);
@@ -227,7 +211,7 @@ public:
             InsertNode(destNode, *it++);
     }
     
-    /// Insert elements by iterators
+    /// Insert elements by iterators.
     void Insert(const Iterator& dest, const ConstIterator& start, const ConstIterator& end)
     {
         Node* destNode = static_cast<Node*>(dest.ptr_);
@@ -236,7 +220,7 @@ public:
             InsertNode(destNode, *it++);
     }
     
-    /// Insert values
+    /// Insert elements.
     void Insert(const Iterator& dest, const T* start, const T* end)
     {
         Node* destNode = static_cast<Node*>(dest.ptr_);
@@ -245,27 +229,27 @@ public:
             InsertNode(destNode, *ptr++);
     }
     
-    /// Erase the last element
+    /// Erase the last element.
     void Pop()
     {
         if (size_)
             Erase(--End());
     }
     
-    /// Erase the first element
+    /// Erase the first element.
     void PopFront()
     {
         if (size_)
             Erase(Begin());
     }
     
-    /// Erase an element. Return an iterator to the next element
+    /// Erase an element. Return an iterator to the next element.
     Iterator Erase(Iterator it)
     {
         return Iterator(EraseNode(static_cast<Node*>(it.ptr_)));
     }
     
-    /// Erase a range by iterators. Return an iterator to the next element
+    /// Erase a range by iterators. Return an iterator to the next element.
     Iterator Erase(const Iterator& start, const Iterator& end)
     {
         Iterator it = start;
@@ -275,14 +259,14 @@ public:
         return it;
     }
     
-    /// Clear the list
+    /// Clear the list.
     void Clear()
     {
         while (size_)
             EraseNode(Head());
     }
     
-    /// Return iterator to value, or to the end if not found
+    /// Return iterator to value, or to the end if not found.
     Iterator Find(const T& value)
     {
         Iterator i = Begin();
@@ -291,7 +275,7 @@ public:
         return i;
     }
     
-    /// Return const iterator to value, or to the end if not found
+    /// Return const iterator to value, or to the end if not found.
     ConstIterator Find(const T& value) const
     {
         ConstIterator i = Begin();
@@ -300,40 +284,36 @@ public:
         return i;
     }
     
-    /// Return whether contains a specific value
-    bool Contains(const T& value) const
-    {
-        return Find(value) != End();
-    }
-    
-    /// Return iterator to the first element
+    /// Return whether contains a specific value.
+    bool Contains(const T& value) const { return Find(value) != End(); }
+    /// Return iterator to the first element.
     Iterator Begin() { return Iterator(Head()); }
-    /// Return iterator to the first element
+    /// Return iterator to the first element.
     ConstIterator Begin() const { return ConstIterator(Head()); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     Iterator End() { return Iterator(Tail()); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     ConstIterator End() const { return ConstIterator(Tail()); }
-    /// Return first element
+    /// Return first element.
     T& Front() { return *Begin(); }
-    /// Return const first element
+    /// Return const first element.
     const T& Front() const { return *Begin(); }
-    /// Return last element
+    /// Return last element.
     T& Back() { return *(--End()); }
-    /// Return const last element
+    /// Return const last element.
     const T& Back() const { return *(--End()); }
-    /// Return number of elements
+    /// Return number of elements.
     unsigned Size() const { return size_; }
-    /// Return whether list is empty
+    /// Return whether list is empty.
     bool Empty() const { return size_ == 0; }
     
 private:
-    /// Return the head pointer with correct type
+    /// Return the head pointer with correct type.
     Node* Head() const { return reinterpret_cast<Node*>(head_); }
-    /// Return the tail pointer with correct type
+    /// Return the tail pointer with correct type.
     Node* Tail() const { return reinterpret_cast<Node*>(tail_); }
     
-    /// Allocate and insert a node into the list
+    /// Allocate and insert a node into the list.
     void InsertNode(Node* dest, const T& value)
     {
         if (!dest)
@@ -354,7 +334,7 @@ private:
         ++size_;
     }
     
-    /// Erase and free a node. Return pointer to the next node, or to the end if could not erase
+    /// Erase and free a node. Return pointer to the next node, or to the end if could not erase.
     Node* EraseNode(Node* toRemove)
     {
         // The tail node can not be removed
@@ -377,7 +357,7 @@ private:
         return next;
     }
     
-    /// Reserve a node
+    /// Reserve a node.
     Node* ReserveNode()
     {
         Node* newNode = static_cast<Node*>(AllocatorReserve(allocator_));
@@ -385,7 +365,7 @@ private:
         return newNode;
     }
     
-    /// Reserve a node with initial value
+    /// Reserve a node with initial value.
     Node* ReserveNode(const T& value)
     {
         Node* newNode = static_cast<Node*>(AllocatorReserve(allocator_));
@@ -393,7 +373,7 @@ private:
         return newNode;
     }
     
-    /// Free a node
+    /// Free a node.
     void FreeNode(Node* node)
     {
         (node)->~Node();

+ 18 - 18
Engine/Container/ListBase.h

@@ -26,67 +26,67 @@
 #include "Allocator.h"
 #include "Swap.h"
 
-/// List node base
+/// List node base.
 struct ListNodeBase
 {
-    /// Construct
+    /// Construct.
     ListNodeBase() :
         prev_(0),
         next_(0)
     {
     }
     
-    /// Previous node
+    /// Previous node.
     ListNodeBase* prev_;
-    /// Next node
+    /// Next node.
     ListNodeBase* next_;
 };
 
-/// List iterator base class
+/// List iterator base class.
 class ListIteratorBase
 {
 public:
-    /// Construct
+    /// Construct.
     explicit ListIteratorBase(ListNodeBase* ptr) :
         ptr_(ptr)
     {
     }
     
-    /// Test for equality with another iterator
+    /// Test for equality with another iterator.
     bool operator == (const ListIteratorBase& rhs) const { return ptr_ == rhs.ptr_; }
-    /// Test for inequality with another iterator
+    /// Test for inequality with another iterator.
     bool operator != (const ListIteratorBase& rhs) const { return ptr_ != rhs.ptr_; }
     
-    /// Go to the next node
+    /// Go to the next node.
     void GotoNext()
     {
         if (ptr_)
             ptr_ = ptr_->next_;
     }
     
-    /// Go to the previous node
+    /// Go to the previous node.
     void GotoPrev()
     {
         if (ptr_)
             ptr_ = ptr_->prev_;
     }
     
-    /// Node pointer
+    /// Node pointer.
     ListNodeBase* ptr_;
 };
 
-/// Linked list base class
+/// Linked list base class.
 class ListBase
 {
 public:
-    /// Construct
+    /// Construct.
     ListBase() :
         allocator_(0),
         size_(0)
     {
     }
     
-    /// Swap with another linked list
+    /// Swap with another linked list.
     void Swap(ListBase& rhs)
     {
         ::Swap(head_, rhs.head_);
@@ -96,12 +96,12 @@ public:
     }
     
 protected:
-    /// Head node pointer
+    /// Head node pointer.
     ListNodeBase* head_;
-    /// Tail node pointer
+    /// Tail node pointer.
     ListNodeBase* tail_;
-    /// Node allocator
+    /// Node allocator.
     AllocatorBlock* allocator_;
-    /// Number of nodes
+    /// Number of nodes.
     unsigned size_;
 };

+ 79 - 100
Engine/Container/Map.h

@@ -29,139 +29,139 @@
 // Based on Red Black Trees by Julienne Walker
 // http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx
 
-/// Map template class using a red-black tree
+/// Map template class using a red-black tree.
 template <class T, class U> class Map : public TreeBase
 {
 public:
-    /// Map key-value pair with const key
+    /// Map key-value pair with const key.
     class KeyValue
     {
     public:
-        /// Construct with default key
+        /// Construct with default key.
         KeyValue() :
             first_(T())
         {
         }
         
-        /// Construct with key and value
+        /// Construct with key and value.
         KeyValue(const T& first, const U& second) :
             first_(first),
             second_(second)
         {
         }
         
-        /// Test for equality with another pair
+        /// Test for equality with another pair.
         bool operator == (const KeyValue& rhs) const { return first_ == rhs.first_ && second_ == rhs.second_; }
-        /// Test for inequality with another pair
+        /// Test for inequality with another pair.
         bool operator != (const KeyValue& rhs) const { return first_ != rhs.first_ || second_ != rhs.second_; }
         
-        /// Key
+        /// Key.
         const T first_;
-        /// Value
+        /// Value.
         U second_;
     };
     
-    /// Map node
+    /// Map node.
     struct Node : public TreeNodeBase
     {
-        /// Construct undefined
+        /// Construct undefined.
         Node()
         {
         }
         
-        /// Construct with key and value
+        /// Construct with key and value.
         Node(const T& key, const U& value) :
             pair_(key, value)
         {
         }
         
-        /// Key-value pair
+        /// Key-value pair.
         KeyValue pair_;
         
-        /// Return parent node
+        /// Return parent node.
         Node* Parent() const { return static_cast<Node*>(parent_); }
-        /// Return the left or right child
+        /// Return the left or right child.
         Node* Child(unsigned dir) const { return static_cast<Node*>(link_[dir]); }
     };
     
-    /// Map iterator
+    /// Map iterator.
     class Iterator : public TreeIteratorBase
     {
     public:
-        // Construct
+        /// Construct.
         Iterator(Node* ptr) :
             TreeIteratorBase(ptr)
         {
         }
         
-        /// Preincrement the pointer
+        /// Preincrement the pointer.
         Iterator& operator ++ () { GotoNext(); return *this; }
-        /// Postincrement the pointer
+        /// Postincrement the pointer.
         Iterator operator ++ (int) { Iterator it = *this; GotoNext(); return it; }
-        /// Predecrement the pointer
+        /// Predecrement the pointer.
         Iterator& operator -- () { GotoPrev(); return *this; }
-        /// Postdecrement the pointer
+        /// Postdecrement the pointer.
         Iterator operator -- (int) { Iterator it = *this; GotoPrev(); return it; }
         
-        /// Point to the pair
+        /// Point to the pair.
         KeyValue* operator -> () const { return &(static_cast<Node*>(ptr_))->pair_; }
-        /// Dereference the pair
+        /// Dereference the pair.
         KeyValue& operator * () const { return (static_cast<Node*>(ptr_))->pair_; }
     };
     
-    /// Map const iterator
+    /// Map const iterator.
     class ConstIterator : public TreeIteratorBase
     {
     public:
-        /// Construct
+        /// Construct.
         ConstIterator(Node* ptr) :
             TreeIteratorBase(ptr)
         {
         }
         
-        /// Construct from a non-const iterator
+        /// Construct from a non-const iterator.
         ConstIterator(const Iterator& it) :
             TreeIteratorBase(it.ptr_)
         {
         }
         
-        /// Assign from a non-const iterator
+        /// Assign from a non-const iterator.
         ConstIterator& operator = (const Iterator& rhs) { ptr_ = rhs.ptr_; return *this; }
-        /// Preincrement the pointer
+        /// Preincrement the pointer.
         ConstIterator& operator ++ () { GotoNext(); return *this; }
-        /// Postincrement the pointer
+        /// Postincrement the pointer.
         ConstIterator operator ++ (int) { ConstIterator it = *this; GotoNext(); return it; }
-        /// Predecrement the pointer
+        /// Predecrement the pointer.
         ConstIterator& operator -- () { GotoPrev(); return *this; }
-        /// Postdecrement the pointer
+        /// Postdecrement the pointer.
         ConstIterator operator -- (int) { ConstIterator it = *this; GotoPrev(); return it; }
         
-        /// Point to the pair
+        /// Point to the pair.
         const KeyValue* operator -> () const { return &(static_cast<Node*>(ptr_))->pair_; }
-        /// Dereference the pair
+        /// Dereference the pair.
         const KeyValue& operator * () const { return (static_cast<Node*>(ptr_))->pair_; }
     };
     
-    /// Construct empty map
+    /// Construct empty.
     Map()
     {
     }
     
-    /// Construct from another map
+    /// Construct from another map.
     Map(const Map<T, U>& map)
     {
         allocator_ = AllocatorInitialize(sizeof(Node), map.Size());
         *this = map;
     }
     
-    /// Destruct the map
+    /// Destruct.
     ~Map()
     {
         Clear();
         AllocatorUninitialize(allocator_);
     }
     
-    /// Assign a map
+    /// Assign a map.
     Map<T, U>& operator = (const Map<T, U>& rhs)
     {
         Clear();
@@ -170,21 +170,21 @@ public:
         return *this;
     }
     
-    /// Add-assign a value
+    /// Add-assign a value.
     Map& operator += (const Pair<T, U>& rhs)
     {
         Insert(rhs);
         return *this;
     }
     
-    /// Add-assign a map
+    /// Add-assign a map.
     Map<T, U>& operator += (const Map<T, U>& rhs)
     {
         Insert(rhs);
         return *this;
     }
     
-    /// Test for equality with another map
+    /// Test for equality with another map.
     bool operator == (const Map<T, U>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -203,7 +203,7 @@ public:
         return true;
     }
     
-    /// Test for inequality with another map
+    /// Test for inequality with another map.
     bool operator != (const Map<T, U>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -222,7 +222,7 @@ public:
         return false;
     }
     
-    /// Index the map. Create a new pair if key not found
+    /// Index the map. Create a new pair if key not found.
     U& operator [] (const T& key)
     {
         Node* node = FindNode(key);
@@ -235,35 +235,25 @@ public:
         }
     }
     
-    /// Clear the map
+    /// Clear the map.
     void Clear()
     {
         Node* root = Root();
         if (!root)
             return;
+        
         EraseNodes(root);
         root_ = 0;
     }
     
-    /// Insert a pair and return iterator to it
-    Iterator Insert(const Pair<T, U>& pair)
-    {
-        return Iterator(InsertNode(pair.first_, pair.second_));
-    }
-    
-    /// Insert a map
-    void Insert(const Map<T, U>& map)
-    {
-        Insert(map.Begin(), map.End());
-    }
-    
-    /// Insert a pair by iterator. Return iterator to the value
-    Iterator Insert(const ConstIterator& it)
-    {
-        return Iterator(InsertNode(it->first_, it->second_));
-    }
+    /// Insert a pair and return iterator to it.
+    Iterator Insert(const Pair<T, U>& pair) { return Iterator(InsertNode(pair.first_, pair.second_)); }
+    /// Insert a map.
+    void Insert(const Map<T, U>& map) { Insert(map.Begin(), map.End()); }
+    /// Insert a pair by iterator. Return iterator to the value.
+    Iterator Insert(const ConstIterator& it) { return Iterator(InsertNode(it->first_, it->second_)); }
     
-    /// Insert a range by iterators
+    /// Insert a range by iterators.
     void Insert(const ConstIterator& start, const ConstIterator& end)
     {
         ConstIterator it = start;
@@ -274,19 +264,12 @@ public:
         }
     }
     
-    /// Erase a pair by key. Return true if was found
-    bool Erase(const T& key)
-    {
-        return EraseNode(key);
-    }
-    
-    /// Erase a pair by iterator
-    void Erase(const Iterator& it)
-    {
-        EraseNode(it->first_);
-    }
+    /// Erase a pair by key. Return true if was found.
+    bool Erase(const T& key) { return EraseNode(key); }
+    /// Erase a pair by iterator.
+    void Erase(const Iterator& it) { EraseNode(it->first_); }
     
-    /// Erase a range by iterators
+    /// Erase a range by iterators.
     void Erase(const Iterator& start, const Iterator& end)
     {
         Iterator it = start;
@@ -297,42 +280,38 @@ public:
         }
     }
     
-    /// Return whether contains a pair with key
-    bool Contains(const T& key) const
-    {
-        return FindNode(key) != 0;
-    }
-    
-    /// Return iterator to the pair, or end iterator if not found
+    /// Return whether contains a pair with key.
+    bool Contains(const T& key) const { return FindNode(key) != 0; }
+    /// Return iterator to the pair, or end iterator if not found.
     Iterator Find(const T& key) { Node* node = FindNode(key); return node ? Iterator(node) : End(); }
-    /// Return const iterator to the pair, or null iterator if not found
+    /// Return const iterator to the pair, or null iterator if not found.
     ConstIterator Find(const T& key) const { Node* node = FindNode(key); return node ? ConstIterator(node) : End(); }
-    /// Return iterator to the beginning
+    /// Return iterator to the beginning.
     Iterator Begin() { return Iterator(FindFirst()); }
-    /// Return const iterator to the beginning
+    /// Return const iterator to the beginning.
     ConstIterator Begin() const { return ConstIterator(FindFirst()); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     Iterator End() { return ++Iterator(FindLast()); }
-    /// Return const iterator to the end
+    /// Return const iterator to the end.
     ConstIterator End() const { return ++ConstIterator(FindLast()); }
-    /// Return first key-value pair
+    /// Return first key-value pair.
     KeyValue& Front() { return FindFirst()->pair_; }
-    /// Return const first key-value pair
+    /// Return const first key-value pair.
     const KeyValue& Front() const { return FindFirst()->pair_; }
-    /// Return last key-value pair
+    /// Return last key-value pair.
     KeyValue& Back() { return FindLast()->pair_; }
-    /// Return const last key-value pair
+    /// Return const last key-value pair.
     const KeyValue& Back() const { return FindLast()->pair_; }
-    /// Return number of key-value pairs
+    /// Return number of key-value pairs.
     unsigned Size() const { return size_; }
-    /// Return whether map is empty
+    /// Return whether map is empty.
     bool Empty() const { return size_ == 0; }
     
 private:
-    /// Return the root pointer with correct type
+    /// Return the root pointer with correct type.
     Node* Root() const { return reinterpret_cast<Node*>(root_); }
     
-    /// Find the node with smallest key
+    /// Find the node with smallest key.
     Node* FindFirst() const
     {
         Node* node = Root();
@@ -341,7 +320,7 @@ private:
         return node;
     }
     
-    /// Find the node with largest key
+    /// Find the node with largest key.
     Node* FindLast() const
     {
         Node* node = Root();
@@ -350,7 +329,7 @@ private:
         return node;
     }
     
-    /// Find a node with key. Return null if not found
+    /// Find a node with key. Return null if not found.
     Node* FindNode(const T& key) const
     {
         Node* node = Root();
@@ -364,7 +343,7 @@ private:
         return 0;
     }
     
-    /// Insert a node and return pointer to it
+    /// Insert a node and return pointer to it.
     Node* InsertNode(const T& key, const U& value)
     {
         Node* ret = 0;
@@ -436,7 +415,7 @@ private:
         return ret;
     }
     
-    /// Erase a node. Return true if was erased
+    /// Erase a node. Return true if was erased.
     bool EraseNode(const T& key)
     {
         if (!root_)
@@ -520,7 +499,7 @@ private:
         return removed;
     }
     
-    /// Erase the nodes recursively
+    /// Erase the nodes recursively.
     void EraseNodes(Node* node)
     {
         Node* left = node->Child(0);
@@ -534,7 +513,7 @@ private:
             EraseNodes(right);
     }
     
-    /// Reserve a node
+    /// Reserve a node.
     Node* ReserveNode()
     {
         if (!allocator_)
@@ -544,7 +523,7 @@ private:
         return newNode;
     }
     
-    /// Reserve a node with specified key and value
+    /// Reserve a node with specified key and value.
     Node* ReserveNode(const T& key, const U& value)
     {
         if (!allocator_)
@@ -554,7 +533,7 @@ private:
         return newNode;
     }
     
-    /// Free a node
+    /// Free a node.
     void FreeNode(Node* node)
     {
         (node)->~Node();

+ 11 - 11
Engine/Container/Pair.h

@@ -25,28 +25,28 @@
 
 #include "Hash.h"
 
-/// Pair template class
+/// Pair template class.
 template <class T, class U> class Pair
 {
 public:
-    /// Construct
+    /// Construct undefined.
     Pair()
     {
     }
     
-    /// Construct with values
+    /// Construct with values.
     Pair(const T& first, const U& second) :
         first_(first),
         second_(second)
     {
     }
     
-    /// Test for equality with another pair
+    /// Test for equality with another pair.
     bool operator == (const Pair<T, U>& rhs) const { return first_ == rhs.first_ && second_ == rhs.second_; }
-    /// Test for inequality with another pair
+    /// Test for inequality with another pair.
     bool operator != (const Pair<T, U>& rhs) const { return first_ != rhs.first_ || second_ != rhs.second_; }
     
-    /// Test for less than with another pair
+    /// Test for less than with another pair.
     bool operator < (const Pair<T, U>& rhs) const
     {
         if (first_ < rhs.first_)
@@ -56,7 +56,7 @@ public:
         return second_ < rhs.second_;
     }
     
-    /// Test for less than with another pair
+    /// Test for less than with another pair.
     bool operator > (const Pair<T, U>& rhs) const
     {
         if (first_ > rhs.first_)
@@ -66,16 +66,16 @@ public:
         return second_ > rhs.second_;
     }
     
-    /// Return hash value for HashSet & HashMap
+    /// Return hash value for HashSet & HashMap.
     unsigned ToHash() const { return (MakeHash(first_) & 0xffff) | (MakeHash(second_) << 16); }
     
-    /// First value
+    /// First value.
     T first_;
-    /// Second value
+    /// Second value.
     U second_;
 };
 
-/// Construct a pair
+/// Construct a pair.
 template <class T, class U> Pair<T, U> MakePair(const T& first, const U& second)
 {
     return Pair<T, U>(first, second);

+ 69 - 75
Engine/Container/Ptr.h

@@ -27,17 +27,17 @@
 
 #include <cassert>
 
-/// Shared pointer template class. Can point to an object that derives from RefCounted
+/// Shared pointer template class. Can point to an object that derives from RefCounted.
 template <class T> class SharedPtr
 {
 public:
-    /// Construct a null shared pointer
+    /// Construct a null shared pointer.
     SharedPtr() :
         ptr_(0)
     {
     }
     
-    /// Copy-construct from another shared pointer
+    /// Copy-construct from another shared pointer.
     SharedPtr(const SharedPtr<T>& rhs) :
         ptr_(rhs.ptr_)
     {
@@ -45,7 +45,7 @@ public:
             ptr_->AddRef();
     }
     
-    /// Construct from a raw pointer
+    /// Construct from a raw pointer.
     explicit SharedPtr(T* ptr) :
         ptr_(ptr)
     {
@@ -53,13 +53,13 @@ public:
             ptr_->AddRef();
     }
     
-    /// Destruct. Release the object reference
+    /// Destruct. Release the object reference.
     ~SharedPtr()
     {
         Release();
     }
     
-    /// Assign from another shared pointer
+    /// Assign from another shared pointer.
     SharedPtr<T>& operator = (const SharedPtr<T>& rhs)
     {
         if (ptr_ == rhs.ptr_)
@@ -74,7 +74,7 @@ public:
         return *this;
     }
     
-    /// Assign from a raw pointer
+    /// Assign from a raw pointer.
     SharedPtr<T>& operator = (T* ptr)
     {
         if (ptr_ == ptr)
@@ -89,30 +89,27 @@ public:
         return *this;
     }
     
-    /// Point to the object
+    /// Point to the object.
     T* operator -> () const { assert(ptr_); return ptr_; }
-    /// Dereference the object
+    /// Dereference the object.
     T& operator * () const { assert(ptr_); return *ptr_; }
-    /// Subscript the object if applicable
+    /// Subscript the object if applicable.
     T& operator [] (const int index) { assert(ptr_); return ptr_[index]; }
-    /// Test for less than with another shared pointer
+    /// Test for less than with another shared pointer.
     bool operator < (const SharedPtr<T>& rhs) const { return ptr_ < rhs.ptr_; }
-    /// Test for equality with another shared pointer
+    /// Test for equality with another shared pointer.
     bool operator == (const SharedPtr<T>& rhs) const { return ptr_ == rhs.ptr_; }
-    /// Test for inequality with another shared pointer
+    /// Test for inequality with another shared pointer.
     bool operator != (const SharedPtr<T>& rhs) const { return ptr_ != rhs.ptr_; }
-    /// Return true if the pointer is not null
+    /// Return true if the pointer is not null.
     operator bool () const { return ptr_ != 0; }
-    /// Convert to a raw pointer
+    /// Convert to a raw pointer.
     operator T* () const { return ptr_; }
     
-    /// Reset to null and release the object reference
-    void Reset()
-    {
-        Release();
-    }
+    /// Reset to null and release the object reference.
+    void Reset() { Release(); }
     
-    /// Perform a static cast from a shared pointer of another type
+    /// Perform a static cast from a shared pointer of another type.
     template <class U> void StaticCast(const SharedPtr<U>& rhs)
     {
         Release();
@@ -122,7 +119,7 @@ public:
             ptr_->AddRef();
     }
     
-    /// Perform a dynamic cast from a shared pointer of another type
+    /// Perform a dynamic cast from a shared pointer of another type.
     template <class U> void DynamicCast(const SharedPtr<U>& rhs)
     {
         Release();
@@ -132,26 +129,26 @@ public:
             ptr_->AddRef();
     }
     
-    /// Check if the pointer is null
+    /// Check if the pointer is null.
     bool Null() const { return ptr_ == 0; }
-    /// Check if the pointer is not null
+    /// Check if the pointer is not null.
     bool NotNull() const { return ptr_ != 0; }
-    /// Return the raw pointer
+    /// Return the raw pointer.
     T* Get() const { return ptr_; }
-    /// Return the object's reference count, or 0 if the pointer is null
+    /// Return the object's reference count, or 0 if the pointer is null.
     unsigned Refs() const { return ptr_ ? ptr_->Refs() : 0; }
-    /// Return the object's weak reference count, or 0 if the pointer is null
+    /// Return the object's weak reference count, or 0 if the pointer is null.
     unsigned WeakRefs() const { return ptr_ ? ptr_->WeakRefs() : 0; }
-    /// Return pointer to the RefCount structure
+    /// Return pointer to the RefCount structure.
     RefCount* RefCountPtr() const { return ptr_ ? ptr_->RefCountPtr() : 0; }
-    /// Return hash value for HashSet & HashMap
+    /// Return hash value for HashSet & HashMap.
     unsigned ToHash() const { return ((unsigned)ptr_) / sizeof(T); }
     
 private:
-    /// Prevent direct assignment from a shared pointer of another type
+    /// Prevent direct assignment from a shared pointer of another type.
     template <class U> SharedPtr<T>& operator = (const SharedPtr<U>& rhs);
     
-    /// Release the object reference. This will trigger its deletion if this was the last reference
+    /// Release the object reference and delete it if necessary.
     void Release()
     {
         if (ptr_)
@@ -161,11 +158,11 @@ private:
         }
     }
     
-    /// Pointer to the object
+    /// Pointer to the object.
     T* ptr_;
 };
 
-/// Perform a static cast from one shared pointer type to another
+/// Perform a static cast from one shared pointer type to another.
 template <class T, class U> SharedPtr<T> StaticCast(const SharedPtr<U>& ptr)
 {
     SharedPtr<T> ret;
@@ -173,7 +170,7 @@ template <class T, class U> SharedPtr<T> StaticCast(const SharedPtr<U>& ptr)
     return ret;
 }
 
-/// Perform a dynamic cast from one weak pointer type to another
+/// Perform a dynamic cast from one weak pointer type to another.
 template <class T, class U> SharedPtr<T> DynamicCast(const SharedPtr<U>& ptr)
 {
     SharedPtr<T> ret;
@@ -181,18 +178,18 @@ template <class T, class U> SharedPtr<T> DynamicCast(const SharedPtr<U>& ptr)
     return ret;
 }
 
-/// Weak pointer template class. Can point to an object that derives from RefCounted, but does not keep it alive
+/// Weak pointer template class. Can point to an object that derives from RefCounted, but does not keep it alive.
 template <class T> class WeakPtr
 {
 public:
-    /// Construct a null weak pointer
+    /// Construct a null weak pointer.
     WeakPtr() :
         ptr_(0),
         refCount_(0)
     {
     }
     
-    /// Construct from a shared pointer
+    /// Construct from a shared pointer.
     WeakPtr(const SharedPtr<T>& rhs) :
         ptr_(rhs.Get()),
         refCount_(rhs.RefCountPtr())
@@ -201,7 +198,7 @@ public:
             ++(refCount_->weakRefs_);
     }
     
-    /// Copy-construct from another weak pointer
+    /// Copy-construct from another weak pointer.
     WeakPtr(const WeakPtr<T>& rhs) :
         ptr_(rhs.ptr_),
         refCount_(rhs.refCount_)
@@ -210,7 +207,7 @@ public:
             ++(refCount_->weakRefs_);
     }
     
-    /// Construct from a raw pointer
+    /// Construct from a raw pointer.
     explicit WeakPtr(T* ptr) :
         ptr_(ptr),
         refCount_(ptr ? ptr->RefCountPtr() : 0)
@@ -219,13 +216,13 @@ public:
             ++(refCount_->weakRefs_);
     }
     
-    /// Destruct. Release the weak reference to the object
+    /// Destruct. Release the weak reference to the object.
     ~WeakPtr()
     {
         Release();
     }
     
-    /// Assign from a shared pointer
+    /// Assign from a shared pointer.
     WeakPtr<T>& operator = (const SharedPtr<T>& rhs)
     {
         if (ptr_ == rhs.Get() && refCount_ == rhs.RefCountPtr())
@@ -241,7 +238,7 @@ public:
         return *this;
     }
     
-    /// Assign from a weak pointer
+    /// Assign from a weak pointer.
     WeakPtr<T>& operator = (const WeakPtr<T>& rhs)
     {
         if (ptr_ == rhs.ptr_ && refCount_ == rhs.refCount_)
@@ -257,7 +254,7 @@ public:
         return *this;
     }
     
-    /// Assign from a raw pointer
+    /// Assign from a raw pointer.
     WeakPtr<T>& operator = (T* ptr)
     {
         RefCount* refCount = ptr ? ptr->RefCountPtr() : 0;
@@ -275,7 +272,7 @@ public:
         return *this;
     }
     
-    /// Convert to a shared pointer. If expired, return a null shared pointer
+    /// Convert to a shared pointer. If expired, return a null shared pointer.
     SharedPtr<T> Lock() const
     {
         if (Expired())
@@ -284,7 +281,7 @@ public:
             return SharedPtr<T>(ptr_);
     }
     
-    /// Return raw pointer. If expired, return null
+    /// Return raw pointer. If expired, return null.
     T* Get() const
     {
         if (Expired())
@@ -293,7 +290,7 @@ public:
             return ptr_;
     }
     
-    /// Point to the object
+    /// Point to the object.
     T* operator -> () const
     {
         T* rawPtr = Get();
@@ -301,7 +298,7 @@ public:
         return rawPtr;
     }
     
-    /// Dereference the object
+    /// Dereference the object.
     T& operator * () const
     {
         T* rawPtr = Get();
@@ -309,7 +306,7 @@ public:
         return *rawPtr;
     }
     
-    /// Subscript the object if applicable
+    /// Subscript the object if applicable.
     T& operator [] (const int index)
     {
         T* rawPtr = Get();
@@ -317,24 +314,21 @@ public:
         return (*rawPtr)[index];
     }
     
-    /// Test for equality with another weak pointer
+    /// Test for equality with another weak pointer.
     bool operator == (const WeakPtr<T>& rhs) const { return ptr_ == rhs.ptr_ && refCount_ == rhs.refCount_; }
-    /// Test for inequality with another weak pointer
+    /// Test for inequality with another weak pointer.
     bool operator != (const WeakPtr<T>& rhs) const { return ptr_ != rhs.ptr_ || refCount_ != rhs.refCount_; }
-    /// Test for less than with another weak pointer
+    /// Test for less than with another weak pointer.
     bool operator < (const SharedPtr<T>& rhs) const { return ptr_ < rhs.ptr_; }
-    /// Return true if points to an object which is not expired
+    /// Return true if points to an object which is not expired.
     operator bool () const { return !Expired(); }
-    /// Convert to a raw pointer, null if the object is expired
+    /// Convert to a raw pointer, null if the object is expired.
     operator T* () const { return Get(); }
     
-    /// Reset to null and release the weak reference
-    void Reset()
-    {
-        Release();
-    }
+    /// Reset to null and release the weak reference.
+    void Reset() { Release(); }
     
-    /// Perform a static cast from a weak pointer of another type
+    /// Perform a static cast from a weak pointer of another type.
     template <class U> void StaticCast(const WeakPtr<U>& rhs)
     {
         Release();
@@ -345,7 +339,7 @@ public:
             ++(refCount_->weakRefs_);
     }
     
-    /// Perform a dynamic cast from a weak pointer of another type
+    /// Perform a dynamic cast from a weak pointer of another type.
     template <class U> void DynamicCast(const WeakPtr<U>& rhs)
     {
         Release();
@@ -361,34 +355,34 @@ public:
             refCount_ = 0;
     }
     
-    /// Check if the pointer is null
+    /// Check if the pointer is null.
     bool Null() const { return refCount_ == 0; }
-    /// Check if the pointer is not null. It does not matter whether the object has expired or not
+    /// Check if the pointer is not null. It does not matter whether the object has expired or not.
     bool NotNull() const { return refCount_ != 0; }
-    /// Return the object's reference count, or 0 if null pointer or if object is expired
+    /// Return the object's reference count, or 0 if null pointer or if object is expired.
     unsigned Refs() const { return refCount_ ? refCount_->refs_ : 0; }
     
-    /// Return the object's weak reference count
+    /// Return the object's weak reference count.
     unsigned WeakRefs() const
     {
         if (!Expired())
             return ptr_->WeakRefs();
-        
-        return refCount_ ? refCount_->weakRefs_ : 0;
+        else
+            return refCount_ ? refCount_->weakRefs_ : 0;
     }
     
-    /// Return whether the object has expired. If null pointer, always return true
+    /// Return whether the object has expired. If null pointer, always return true.
     bool Expired() const { return refCount_ ? refCount_->expired_ : true; }
-    /// Return pointer to the RefCount structure
+    /// Return pointer to the RefCount structure.
     RefCount* RefCountPtr() const { return refCount_; }
-    /// Return hash value for HashSet & HashMap
+    /// Return hash value for HashSet & HashMap.
     unsigned ToHash() const { return ((unsigned)ptr_) / sizeof(T); }
     
 private:
-    /// Prevent direct assignment from a weak pointer of different type
+    /// Prevent direct assignment from a weak pointer of different type.
     template <class U> WeakPtr<T>& operator = (const WeakPtr<U>& rhs);
     
-    /// Release the weak reference. Delete the Refcount structure if the object has expired and this was the last weak reference
+    /// Release the weak reference. Delete the Refcount structure if necessary.
     void Release()
     {
         if (refCount_)
@@ -404,13 +398,13 @@ private:
         refCount_ = 0;
     }
     
-    /// Pointer to the object
+    /// Pointer to the object.
     T* ptr_;
-    /// Pointer to the RefCount structure
+    /// Pointer to the RefCount structure.
     RefCount* refCount_;
 };
 
-/// Perform a static cast from one weak pointer type to another
+/// Perform a static cast from one weak pointer type to another.
 template <class T, class U> WeakPtr<T> StaticCast(const WeakPtr<U>& ptr)
 {
     WeakPtr<T> ret;
@@ -418,7 +412,7 @@ template <class T, class U> WeakPtr<T> StaticCast(const WeakPtr<U>& ptr)
     return ret;
 }
 
-/// Perform a dynamic cast from one weak pointer type to another
+/// Perform a dynamic cast from one weak pointer type to another.
 template <class T, class U> WeakPtr<T> DynamicCast(const WeakPtr<U>& ptr)
 {
     WeakPtr<T> ret;

+ 17 - 17
Engine/Container/RefCounted.h

@@ -23,10 +23,10 @@
 
 #pragma once
 
-/// Reference count structure
+/// Reference count structure.
 struct RefCount
 {
-    /// Initialize reference counts to zero and expired status to false
+    /// Construct.
     RefCount() :
         refs_(0),
         weakRefs_(0),
@@ -34,40 +34,40 @@ struct RefCount
     {
     }
     
-    /// Reference count
+    /// Reference count.
     unsigned refs_;
-    /// Weak reference count
+    /// Weak reference count.
     unsigned weakRefs_;
-    /// Expired status for the object
+    /// Expired status for the object.
     bool expired_;
 };
 
-/// Base class for objects that can be pointed to by SharedPtr or WeakPtr. These are noncopyable and non-assignable
+/// Base class for objects that can be pointed to by SharedPtr or WeakPtr. These are noncopyable and non-assignable.
 class RefCounted
 {
 public:
-    /// Construct. Allocate the reference count structure and set an initial self weak reference
+    /// Construct. Allocate the reference count structure and set an initial self weak reference.
     RefCounted();
-    /// Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist
+    /// Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist.
     virtual ~RefCounted();
     
-    /// Increment reference count. Can also be called outside of a SharedPtr for traditional reference counting
+    /// Increment reference count. Can also be called outside of a SharedPtr for traditional reference counting.
     void AddRef();
-    /// Decrement reference count and delete self if no more references. Can also be called outside of a SharedPtr for traditional reference counting
+    /// Decrement reference count and delete self if no more references. Can also be called outside of a SharedPtr for traditional reference counting.
     void ReleaseRef();
-    /// Return reference count
+    /// Return reference count.
     unsigned Refs() const;
-    /// Return weak reference count
+    /// Return weak reference count.
     unsigned WeakRefs() const;
-    /// Return pointer to the reference count structure
+    /// Return pointer to the reference count structure.
     RefCount* RefCountPtr() { return refCount_; }
-
+    
 private:
-    /// Prevent copy construction
+    /// Prevent copy construction.
     RefCounted(const RefCounted& rhs);
-    /// Prevent assignment
+    /// Prevent assignment.
     RefCounted& operator = (const RefCounted& rhs);
     
-    /// Pointer to the reference count structure
+    /// Pointer to the reference count structure.
     RefCount* refCount_;
 };

+ 69 - 90
Engine/Container/Set.h

@@ -28,111 +28,111 @@
 // Based on Red Black Trees by Julienne Walker
 // http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx
 
-/// Set template class using a red-black tree
+/// Set template class using a red-black tree.
 template <class T> class Set : public TreeBase
 {
 public:
-    /// Set node
+    /// Set node.
     struct Node : public TreeNodeBase
     {
-        // Construct undefined
+        // Construct undefined.
         Node()
         {
         }
         
-        // Construct with key
+        // Construct with key.
         Node(const T& key) :
             key_(key)
         {
         }
         
-        /// Key
+        /// Key.
         T key_;
         
-        /// Return parent node
+        /// Return parent node.
         Node* Parent() const { return static_cast<Node*>(parent_); }
-        /// Return the left or right child
+        /// Return the left or right child.
         Node* Child(unsigned dir) const { return static_cast<Node*>(link_[dir]); }
     };
     
-    /// Set iterator
+    /// Set iterator.
     class Iterator : public TreeIteratorBase
     {
     public:
-        // Construct
+        // Construct.
         Iterator(Node* ptr) :
             TreeIteratorBase(ptr)
         {
         }
         
-        /// Preincrement the pointer
+        /// Preincrement the pointer.
         Iterator& operator ++ () { GotoNext(); return *this; }
-        /// Postincrement the pointer
+        /// Postincrement the pointer.
         Iterator operator ++ (int) { Iterator it = *this; GotoNext(); return it; }
-        /// Predecrement the pointer
+        /// Predecrement the pointer.
         Iterator& operator -- () { GotoPrev(); return *this; }
-        /// Postdecrement the pointer
+        /// Postdecrement the pointer.
         Iterator operator -- (int) { Iterator it = *this; GotoPrev(); return it; }
         
-        /// Point to the key
+        /// Point to the key.
         const T* operator -> () const { return &(static_cast<Node*>(ptr_))->key_; }
-        /// Dereference the key
+        /// Dereference the key.
         const T& operator * () const { return (static_cast<Node*>(ptr_))->key_; }
     };
     
-    /// Set const iterator
+    /// Set const iterator.
     class ConstIterator : public TreeIteratorBase
     {
     public:
-        // Construct
+        /// Construct.
         ConstIterator(Node* ptr) :
             TreeIteratorBase(ptr)
         {
         }
         
-        // Construct from a non-const iterator
+        // Construct from a non-const iterator.
         ConstIterator(const Iterator& it) :
             TreeIteratorBase(it.ptr_)
         {
         }
         
-        /// Assign from a non-const iterator
+        /// Assign from a non-const iterator.
         ConstIterator& operator = (const Iterator& rhs) { ptr_ = rhs.ptr_; return *this; }
-        /// Preincrement the pointer
+        /// Preincrement the pointer.
         ConstIterator& operator ++ () { GotoNext(); return *this; }
-        /// Postincrement the pointer
+        /// Postincrement the pointer.
         ConstIterator operator ++ (int) { ConstIterator it = *this; GotoNext(); return it; }
-        /// Predecrement the pointer
+        /// Predecrement the pointer.
         ConstIterator& operator -- () { GotoPrev(); return *this; }
-        /// Postdecrement the pointer
+        /// Postdecrement the pointer.
         ConstIterator operator -- (int) { ConstIterator it = *this; GotoPrev(); return it; }
         
-        /// Point to the key
+        /// Point to the key.
         const T* operator -> () const { return &(static_cast<Node*>(ptr_))->key_; }
-        /// Dereference the key
+        /// Dereference the key.
         const T& operator * () const { return (static_cast<Node*>(ptr_))->key_; }
     };
     
-    /// Construct empty set
+    /// Construct empty.
     Set()
     {
     }
     
-    /// Construct from another set
+    /// Construct from another set.
     Set(const Set<T>& set)
     {
         allocator_ = AllocatorInitialize(sizeof(Node), set.Size());
         *this = set;
     }
     
-    /// Destruct the set
+    /// Destruct.
     ~Set()
     {
         Clear();
         AllocatorUninitialize(allocator_);
     }
     
-    /// Assign a set
+    /// Assign a set.
     Set& operator = (const Set<T>& set)
     {
         Clear();
@@ -141,21 +141,21 @@ public:
         return *this;
     }
     
-    /// Add-assign a value
+    /// Add-assign a value.
     Set& operator += (const T& rhs)
     {
         Insert(rhs);
         return *this;
     }
     
-    /// Add-assign a set
+    /// Add-assign a set.
     Set& operator += (const Set<T>& rhs)
     {
         Insert(rhs);
         return *this;
     }
     
-    /// Test for equality with another set
+    /// Test for equality with another set.
     bool operator == (const Set<T>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -174,7 +174,7 @@ public:
         return true;
     }
     
-    /// Test for inequality with another set
+    /// Test for inequality with another set.
     bool operator != (const Set<T>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -193,35 +193,25 @@ public:
         return false;
     }
     
-    /// Clear the set
+    /// Clear the set.
     void Clear()
     {
         Node* root = Root();
         if (!root)
             return;
+        
         EraseNodes(root);
         root_ = 0;
     }
     
-    /// Insert a key. Return iterator to the value
-    Iterator Insert(const T& key)
-    {
-        return Iterator(InsertNode(key));
-    }
-    
-    /// Insert a set
-    void Insert(const Set<T>& set)
-    {
-        Insert(set.Begin(), set.End());
-    }
-    
-    /// Insert a key by iterator. Return iterator to the value
-    Iterator Insert(const ConstIterator& it)
-    {
-        return Iterator(InsertNode(*it));
-    }
+    /// Insert a key. Return iterator to the value.
+    Iterator Insert(const T& key) { return Iterator(InsertNode(key)); }
+    /// Insert a set.
+    void Insert(const Set<T>& set) { Insert(set.Begin(), set.End()); }
+    /// Insert a key by iterator. Return iterator to the value.
+    Iterator Insert(const ConstIterator& it) { return Iterator(InsertNode(*it)); }
     
-    /// Insert a range by iterators
+    /// Insert a range by iterators.
     void Insert(const ConstIterator& start, const ConstIterator& end)
     {
         ConstIterator it = start;
@@ -229,19 +219,12 @@ public:
             InsertNode(*it++);
     }
     
-    /// Erase a key. Return true if was found
-    bool Erase(const T& key)
-    {
-        return EraseNode(key);
-    }
-    
-    /// Erase a key by iterator
-    void Erase(const Iterator& it)
-    {
-        EraseNode(*it);
-    }
+    /// Erase a key. Return true if was found.
+    bool Erase(const T& key) { return EraseNode(key); }
+    /// Erase a key by iterator.
+    void Erase(const Iterator& it) { EraseNode(*it); }
     
-    /// Erase a range by iterators
+    /// Erase a range by iterators.
     void Erase(const Iterator& start, const Iterator& end)
     {
         Iterator it = start;
@@ -252,38 +235,34 @@ public:
         }
     }
     
-    /// Return whether contains a key
-    bool Contains(const T& key) const
-    {
-        return FindNode(key) != 0;
-    }
-    
-    /// Return iterator to the node with key, or end iterator if not found
+    /// Return whether contains a key.
+    bool Contains(const T& key) const { return FindNode(key) != 0; }
+    /// Return iterator to the node with key, or end iterator if not found.
     Iterator Find(const T& key) { Node* node = FindNode(key); return node ? Iterator(node) : End(); }
-    /// Return const iterator to the node with key, or null iterator if not found
+    /// Return const iterator to the node with key, or null iterator if not found.
     ConstIterator Find(const T& key) const { Node* node = FindNode(key); return node ? ConstIterator(node) : End(); }
-    /// Return iterator to the beginning
+    /// Return iterator to the beginning.
     Iterator Begin() { return Iterator(FindFirst()); }
-    /// Return const iterator to the beginning
+    /// Return const iterator to the beginning.
     ConstIterator Begin() const { return ConstIterator(FindFirst()); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     Iterator End() { return ++Iterator(FindLast()); }
-    /// Return const iterator to the end
+    /// Return const iterator to the end.
     ConstIterator End() const { return ++ConstIterator(FindLast()); }
-    /// Return first key
+    /// Return first key.
     const T& Front() { return FindFirst()->key_; }
-    /// Return last key
+    /// Return last key.
     const T& Back() { return FindLast()->key_; }
-    /// Return number of keys
+    /// Return number of keys.
     unsigned Size() const { return size_; }
-    /// Return whether set is empty
+    /// Return whether set is empty.
     bool Empty() const { return size_ == 0; }
     
 private:
-    /// Return the root pointer with correct type
+    /// Return the root pointer with correct type.
     Node* Root() const { return reinterpret_cast<Node*>(root_); }
     
-    /// Find the node with smallest key
+    /// Find the node with smallest key.
     Node* FindFirst() const
     {
         Node* node = Root();
@@ -292,7 +271,7 @@ private:
         return node;
     }
     
-    /// Find the node with largest key
+    /// Find the node with largest key.
     Node* FindLast() const
     {
         Node* node = Root();
@@ -301,7 +280,7 @@ private:
         return node;
     }
     
-    /// Find a node with key. Return null if not found
+    /// Find a node with key. Return null if not found.
     Node* FindNode(const T& key) const
     {
         Node* node = Root();
@@ -315,7 +294,7 @@ private:
         return 0;
     }
     
-    /// Insert a node and return a pointer to it
+    /// Insert a node and return a pointer to it.
     Node* InsertNode(const T& key)
     {
         Node* ret = 0;
@@ -386,7 +365,7 @@ private:
         return ret;
     }
     
-    /// Erase a node. Return true if was erased
+    /// Erase a node. Return true if was erased.
     bool EraseNode(const T& key)
     {
         if (!root_)
@@ -469,7 +448,7 @@ private:
         return removed;
     }
     
-    /// Erase the nodes recursively
+    /// Erase the nodes recursively.
     void EraseNodes(Node* node)
     {
         Node* left = node->Child(0);
@@ -483,7 +462,7 @@ private:
             EraseNodes(right);
     }
     
-    /// Reserve a node
+    /// Reserve a node.
     Node* ReserveNode()
     {
         if (!allocator_)
@@ -494,7 +473,7 @@ private:
         return newNode;
     }
     
-    /// Reserve a node with specified key
+    /// Reserve a node with specified key.
     Node* ReserveNode(const T& key)
     {
         if (!allocator_)
@@ -504,7 +483,7 @@ private:
         return newNode;
     }
     
-    /// Free a node
+    /// Free a node.
     void FreeNode(Node* node)
     {
         (node)->~Node();

+ 6 - 6
Engine/Container/Sort.h

@@ -31,7 +31,7 @@ static const int QUICKSORT_THRESHOLD = 16;
 // Based on Comparison of several sorting algorithms by Juha Nieminen
 // http://warp.povusers.org/SortComparison/
 
-/// Perform insertion sort on an array
+/// Perform insertion sort on an array.
 template <class T> void InsertionSort(RandomAccessIterator<T> begin, RandomAccessIterator<T> end)
 {
     for (RandomAccessIterator<T> i = begin + 1; i < end; ++i)
@@ -47,7 +47,7 @@ template <class T> void InsertionSort(RandomAccessIterator<T> begin, RandomAcces
     }
 }
 
-/// Perform insertion sort on an array using a compare function
+/// Perform insertion sort on an array using a compare function.
 template <class T, class U> void InsertionSort(RandomAccessIterator<T> begin, RandomAccessIterator<T> end, U compare)
 {
     for (RandomAccessIterator<T> i = begin + 1; i < end; ++i)
@@ -63,7 +63,7 @@ template <class T, class U> void InsertionSort(RandomAccessIterator<T> begin, Ra
     }
 }
 
-/// Perform quick sort initial pass on an array. Does not sort fully
+/// Perform quick sort initial pass on an array. Does not sort fully.
 template <class T> void InitialQuickSort(RandomAccessIterator<T> begin, RandomAccessIterator<T> end)
 {
     while (end - begin > QUICKSORT_THRESHOLD)
@@ -94,7 +94,7 @@ template <class T> void InitialQuickSort(RandomAccessIterator<T> begin, RandomAc
     }
 }
 
-/// Perform quick sort initial pass on an array using a compare function. Does not sort fully
+/// Perform quick sort initial pass on an array using a compare function. Does not sort fully.
 template <class T, class U> void InitialQuickSort(RandomAccessIterator<T> begin, RandomAccessIterator<T> end, U compare)
 {
     while (end - begin > QUICKSORT_THRESHOLD)
@@ -125,14 +125,14 @@ template <class T, class U> void InitialQuickSort(RandomAccessIterator<T> begin,
     }
 }
 
-/// Sort in ascending order using quicksort for initial passes, then an insertion sort to finalize
+/// Sort in ascending order using quicksort for initial passes, then an insertion sort to finalize.
 template <class T> void Sort(RandomAccessIterator<T> begin, RandomAccessIterator<T> end)
 {
     InitialQuickSort(begin, end);
     InsertionSort(begin, end);
 }
 
-/// Sort in ascending order using quicksort for initial passes, then an insertion sort to finalize, using a compare function
+/// Sort in ascending order using quicksort for initial passes, then an insertion sort to finalize, using a compare function.
 template <class T, class U> void Sort(RandomAccessIterator<T> begin, RandomAccessIterator<T> end, U compare)
 {
     InitialQuickSort(begin, end, compare);

+ 14 - 0
Engine/Container/String.cpp

@@ -191,6 +191,20 @@ String::Iterator String::Replace(const String::Iterator& start, const String::It
     return Begin() + pos;
 }
 
+String String::Replaced(char replaceThis, char replaceWith) const
+{
+    String ret(*this);
+    ret.Replace(replaceThis, replaceWith);
+    return ret;
+}
+
+String String::Replaced(const String& replaceThis, const String& replaceWith) const
+{
+    String ret(*this);
+    ret.Replace(replaceThis, replaceWith);
+    return ret;
+}
+
 void String::Append(const String& str)
 {
     *this += str;

+ 111 - 139
Engine/Container/StringBase.h

@@ -32,14 +32,14 @@
 
 static const int CONVERSION_BUFFER_LENGTH = 128;
 
-/// String class
+/// String class.
 class String
 {
 public:
     typedef RandomAccessIterator<char> Iterator;
     typedef RandomAccessConstIterator<char> ConstIterator;
     
-    /// Construct empty
+    /// Construct empty.
     String() :
         length_(0),
         capacity_(0),
@@ -47,7 +47,7 @@ public:
     {
     }
     
-    /// Construct from another string
+    /// Construct from another string.
     String(const String& str) :
         length_(0),
         capacity_(0),
@@ -56,7 +56,7 @@ public:
         *this = str;
     }
     
-    /// Construct from a C string
+    /// Construct from a C string.
     String(const char* str) :
         length_(0),
         capacity_(0),
@@ -65,7 +65,7 @@ public:
         *this = str;
     }
     
-    /// Construct from a C string
+    /// Construct from a C string.
     String(char* str) :
         length_(0),
         capacity_(0),
@@ -74,7 +74,7 @@ public:
         *this = (const char*)str;
     }
     
-    /// Construct from a char array and length
+    /// Construct from a char array and length.
     String(const char* str, unsigned length) :
         length_(0),
         capacity_(0),
@@ -84,26 +84,26 @@ public:
         CopyChars(buffer_, str, length);
     }
     
-    /// Construct from an integer
+    /// Construct from an integer.
     explicit String(int value);
-    /// Construct from a short integer
+    /// Construct from a short integer.
     explicit String(short value);
-    /// Construct from an unsigned integer
+    /// Construct from an unsigned integer.
     explicit String(unsigned value);
-    /// Construct from an unsigned short integer
+    /// Construct from an unsigned short integer.
     explicit String(unsigned short value);
-    /// Construct from a float
+    /// Construct from a float.
     explicit String(float value);
-    /// Construct from a double
+    /// Construct from a double.
     explicit String(double value);
-    /// Construct from a bool
+    /// Construct from a bool.
     explicit String(bool value);
-    /// Construct from a character
+    /// Construct from a character.
     explicit String(char value);
-    /// Construct from a character and fill length
+    /// Construct from a character and fill length.
     explicit String(char value, unsigned length);
     
-    /// Construct from a convertable value
+    /// Construct from a convertable value.
     template <class T> explicit String(const T& value) :
         length_(0),
         capacity_(0),
@@ -112,14 +112,14 @@ public:
         *this = value.ToString();
     }
     
-    /// Destruct
+    /// Destruct.
     ~String()
     {
         if (capacity_)
             delete[] buffer_;
     }
     
-    /// Assign a string
+    /// Assign a string.
     String& operator = (const String& rhs)
     {
         Resize(rhs.length_);
@@ -128,7 +128,7 @@ public:
         return *this;
     }
     
-    /// Assign a C string
+    /// Assign a C string.
     String& operator = (const char* rhs)
     {
         unsigned rhsLength = GetCStringLength(rhs);
@@ -138,7 +138,7 @@ public:
         return *this;
     }
     
-    /// Add-assign a string
+    /// Add-assign a string.
     String& operator += (const String& rhs)
     {
         unsigned oldLength = length_;
@@ -148,7 +148,7 @@ public:
         return *this;
     }
     
-    /// Add-assign a C string
+    /// Add-assign a C string.
     String& operator += (const char* rhs)
     {
         unsigned rhsLength = GetCStringLength(rhs);
@@ -159,7 +159,7 @@ public:
         return *this;
     }
     
-    /// Add-assign a character
+    /// Add-assign a character.
     String& operator += (char rhs)
     {
         unsigned oldLength = length_;
@@ -169,22 +169,22 @@ public:
         return *this;
     }
     
-    /// Add-assign an integer
+    /// Add-assign an integer.
     String& operator += (int rhs);
-    /// Add-assign a short integer
+    /// Add-assign a short integer.
     String& operator += (short rhs);
-    /// Add-assign an unsigned integer
+    /// Add-assign an unsigned integer.
     String& operator += (unsigned rhs);
-    /// Add-assign a short unsigned integer
+    /// Add-assign a short unsigned integer.
     String& operator += (unsigned short rhs);
-    /// Add-assign a float
+    /// Add-assign a float.
     String& operator += (float rhs);
-    /// Add-assign a bool
+    /// Add-assign a bool.
     String& operator += (bool rhs);
-    /// Add-assign an arbitraty type
+    /// Add-assign an arbitraty type.
     template <class T> String operator += (const T& rhs) { return *this += rhs.ToString(); }
     
-    /// Add a string
+    /// Add a string.
     String operator + (const String& rhs) const
     {
         String ret;
@@ -195,7 +195,7 @@ public:
         return ret;
     }
     
-    /// Add a C string
+    /// Add a C string.
     String operator + (const char* rhs) const
     {
         unsigned rhsLength = GetCStringLength(rhs);
@@ -207,7 +207,7 @@ public:
         return ret;
     }
     
-    /// Add a character
+    /// Add a character.
     String operator + (char rhs) const
     {
         String ret(*this);
@@ -216,151 +216,123 @@ public:
         return ret;
     }
     
-    /// Test for equality with another string
-    bool operator == (const String& rhs) const
-    {
-        return strcmp(CString(), rhs.CString()) == 0;
-    }
-    
-    /// Test for inequality with another string
-    bool operator != (const String& rhs) const
-    {
-        return strcmp(CString(), rhs.CString()) != 0;
-    }
-    
-    /// Test if string is less than another string
-    bool operator < (const String& rhs) const
-    {
-        return strcmp(CString(), rhs.CString()) < 0;
-    }
-    
-    /// Test if string is greater than another string
-    bool operator > (const String& rhs) const
-    {
-        return strcmp(CString(), rhs.CString()) > 0;
-    }
-    
-    /// Test for equality with a C string
-    bool operator == (const char* rhs) const
-    {
-        return strcmp(CString(), rhs) == 0;
-    }
-    
-    /// Test for inequality with a C string
-    bool operator != (const char* rhs) const
-    {
-        return strcmp(CString(), rhs) != 0;
-    }
-    
-    /// Test if string is less than a C string
-    bool operator < (const char* rhs) const
-    {
-        return strcmp(CString(), rhs) < 0;
-    }
-    
-    /// Test if string is greater than a C string
-    bool operator > (const char* rhs) const
-    {
-        return strcmp(CString(), rhs) > 0;
-    }
-    
-    /// Return char at index
+    /// Test for equality with another string.
+    bool operator == (const String& rhs) const { return strcmp(CString(), rhs.CString()) == 0; }
+    /// Test for inequality with another string.
+    bool operator != (const String& rhs) const { return strcmp(CString(), rhs.CString()) != 0; }
+    /// Test if string is less than another string.
+    bool operator < (const String& rhs) const { return strcmp(CString(), rhs.CString()) < 0; }
+    /// Test if string is greater than another string.
+    bool operator > (const String& rhs) const { return strcmp(CString(), rhs.CString()) > 0; }
+    /// Test for equality with a C string.
+    bool operator == (const char* rhs) const { return strcmp(CString(), rhs) == 0; }
+    /// Test for inequality with a C string.
+    bool operator != (const char* rhs) const { return strcmp(CString(), rhs) != 0; }
+    /// Test if string is less than a C string.
+    bool operator < (const char* rhs) const { return strcmp(CString(), rhs) < 0; }
+    /// Test if string is greater than a C string.
+    bool operator > (const char* rhs) const { return strcmp(CString(), rhs) > 0; }
+    /// Return char at index.
     char& operator [] (unsigned index) { assert(index < length_); return buffer_[index]; }
-    /// Return const char at index
+    /// Return const char at index.
     const char& operator [] (unsigned index) const { assert(index < length_); return buffer_[index]; }
-    /// Return char at index
+    /// Return char at index.
     char& At(unsigned index) { assert(index < length_); return buffer_[index]; }
-    /// Return const char at index
+    /// Return const char at index.
     const char& At(unsigned index) const { assert(index < length_); return buffer_[index]; }
     
-    /// Replace all occurrences of a character
+    /// Replace all occurrences of a character.
     void Replace(char replaceThis, char replaceWith);
-    /// Replace all occurrences of a string
+    /// Replace all occurrences of a string.
     void Replace(const String& replaceThis, const String& replaceWith);
-    /// Replace a substring
+    /// Replace a substring.
     void Replace(unsigned pos, unsigned length, const String& replaceWith);
-    /// Replace a substring by iterators
+    /// Replace a substring by iterators.
     Iterator Replace(const Iterator& start, const Iterator& end, const String& replaceWith);
-    /// Append a string
+    /// Return a string with all occurrences of a character replaced.
+    String Replaced(char replaceThis, char replaceWith) const;
+    /// Return a string with all occurrences of a string replaced.
+    String Replaced(const String& replaceThis, const String& replaceWith) const;
+    /// Append a string.
     void Append(const String& str);
-    /// Append a C string
+    /// Append a C string.
     void Append(const char* str);
-    /// Append a character
+    /// Append a character.
     void Append(char c);
-    /// Append characters
+    /// Append characters.
     void Append(const char* str, unsigned length);
-    /// Insert a string
+    /// Insert a string.
     void Insert(unsigned pos, const String& str);
-    /// Insert a character
+    /// Insert a character.
     void Insert(unsigned pos, char c);
-    /// Insert a string using an iterator
+    /// Insert a string using an iterator.
     Iterator Insert(const Iterator& dest, const String& str);
-    /// Insert a string partially by iterators
+    /// Insert a string partially by iterators.
     Iterator Insert(const Iterator& dest, const Iterator& start, const Iterator& end);
-    /// Insert a character using an iterator
+    /// Insert a character using an iterator.
     Iterator Insert(const Iterator& dest, char c);
-    /// Erase a substring
+    /// Erase a substring.
     void Erase(unsigned pos, unsigned length = 1);
-    /// Erase a character by iterator
+    /// Erase a character by iterator.
     Iterator Erase(const Iterator& it);
-    /// Erase a substring by iterators
+    /// Erase a substring by iterators.
     Iterator Erase(const Iterator& start, const Iterator& end);
-    /// Resize the string
+    /// Resize the string.
     void Resize(unsigned newLength);
-    /// %Set new capacity
+    /// %Set new capacity.
     void Reserve(unsigned newCapacity);
-    /// Reallocate so that no extra memory is used
+    /// Reallocate so that no extra memory is used.
     void Compact();
-    /// Clear the string
+    /// Clear the string.
     void Clear();
-    /// Swap with another string
+    /// Swap with another string.
     void Swap(String& str);
     
-    /// Return iterator to the beginning
+    /// Return iterator to the beginning.
     Iterator Begin() { return Iterator(buffer_); }
-    /// Return const iterator to the beginning
+    /// Return const iterator to the beginning.
     ConstIterator Begin() const { return ConstIterator(buffer_); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     Iterator End() { return Iterator(buffer_ + length_); }
-    /// Return const iterator to the end
+    /// Return const iterator to the end.
     ConstIterator End() const { return ConstIterator(buffer_ + length_); }
-    /// Return first char, or 0 if empty
+    /// Return first char, or 0 if empty.
     char Front() const { return buffer_[0]; }
-    /// Return last char, or 0 if empty
+    /// Return last char, or 0 if empty.
     char Back() const { return length_ ? buffer_[length_ - 1] : buffer_[0]; }
-    /// Return a substring from position to end
+    /// Return a substring from position to end.
     String Substring(unsigned pos) const;
-    /// Return a substring with length from position
+    /// Return a substring with length from position.
     String Substring(unsigned pos, unsigned length) const;
-    /// Return string with whitespace trimmed from the beginning and the end
+    /// Return string with whitespace trimmed from the beginning and the end.
     String Trimmed() const;
-    /// Return string in uppercase
+    /// Return string in uppercase.
     String ToUpper() const;
-    /// Return string in lowercase
+    /// Return string in lowercase.
     String ToLower() const;
-    /// Split string by a separator char
+    /// Split string by a separator char.
     Vector<String> Split(char separator) const;
-    /// Find the first occurrence of a string, or NPOS if not found
+    /// Find the first occurrence of a string, or NPOS if not found.
     unsigned Find(const String& str, unsigned startPos = 0) const;
-    /// Find the first occurrence of a character, or NPOS if not found
+    /// Find the first occurrence of a character, or NPOS if not found.
     unsigned Find(char c, unsigned startPos = 0) const;
-    /// Find the last occurrence of a string, or NPOS if not found
+    /// Find the last occurrence of a string, or NPOS if not found.
     unsigned FindLast(const String& str, unsigned startPos = NPOS) const;
-    /// Find the last occurrence of a character, or NPOS if not found
+    /// Find the last occurrence of a character, or NPOS if not found.
     unsigned FindLast(char c, unsigned startPos = NPOS) const;
-    /// Return the C string
+    /// Return the C string.
     const char* CString() const { return buffer_; }
-    /// Return length
+    /// Return length.
     unsigned Length() const { return length_; }
-    /// Return buffer capacity
+    /// Return buffer capacity.
     unsigned Capacity() const { return capacity_; }
-    /// Return whether the string is empty
+    /// Return whether the string is empty.
     bool Empty() const { return length_ == 0; }
-    /// Return comparision result with a string
+    /// Return comparision result with a string.
     int Compare(const String& str, bool caseSensitive = true) const;
-    /// Return comparision result with a C string
+    /// Return comparision result with a C string.
     int Compare(const char* str, bool caseSensitive = true) const;
-    /// Return hash value for HashSet & HashMap
+    /// Return hash value for HashSet & HashMap.
     unsigned ToHash() const
     {
         unsigned hash = 0;
@@ -374,20 +346,20 @@ public:
         return hash;
     }
     
-    /// Position for "not found"
+    /// Position for "not found."
     static const unsigned NPOS = 0xffffffff;
-    /// Initial dynamic allocation size
+    /// Initial dynamic allocation size.
     static const unsigned MIN_CAPACITY = 8;
     
 private:
-    /// Move a range of characters within the string
+    /// Move a range of characters within the string.
     void MoveRange(unsigned dest, unsigned src, unsigned count)
     {
         if (count)
             memmove(buffer_ + dest, buffer_ + src, count);
     }
     
-    /// Copy chars from one buffer to another
+    /// Copy chars from one buffer to another.
     static void CopyChars(char* dest, const char* src, unsigned count)
     {
         #ifdef _MSC_VER
@@ -404,7 +376,7 @@ private:
         #endif
     }
     
-    /// Return length of a C string
+    /// Return length of a C string.
     static unsigned GetCStringLength(const char* str)
     {
         if (!str)
@@ -419,21 +391,21 @@ private:
         #endif
     }
     
-    /// Replace a substring with another substring
+    /// Replace a substring with another substring.
     void Replace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength);
     
-    /// String length
+    /// String length.
     unsigned length_;
-    /// Capacity, zero if buffer not allocated
+    /// Capacity, zero if buffer not allocated.
     unsigned capacity_;
-    /// String buffer, null if not allocated
+    /// String buffer, null if not allocated.
     char* buffer_;
     
-    /// End zero for empty strings
+    /// End zero for empty strings.
     static char endZero;
 };
 
-/// Add a string to a C string
+/// Add a string to a C string.
 inline String operator + (const char* lhs, const String& rhs)
 {
     String ret(lhs);

+ 1 - 1
Engine/Container/Swap.h

@@ -29,7 +29,7 @@ class String;
 class TreeBase;
 class VectorBase;
 
-/// Swap two values
+/// Swap two values.
 template<class T> inline void Swap(T& first, T& second)
 {
     T temp = first;

+ 24 - 27
Engine/Container/TreeBase.h

@@ -29,10 +29,10 @@
 // Based on Red Black Trees by Julienne Walker
 // http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx
 
-/// Red-black tree node base
+/// Red-black tree node base.
 struct TreeNodeBase
 {
-    /// Construct
+    /// Construct.
     TreeNodeBase() :
         parent_(0),
         isRed_(true)
@@ -41,7 +41,7 @@ struct TreeNodeBase
         link_[1] = 0;
     }
     
-    /// %Set a child link, adjusting the child's parent as necessary
+    /// %Set a child link, adjusting the child's parent as necessary.
     void SetChild(unsigned dir, TreeNodeBase* newChild)
     {
         link_[dir] = newChild;
@@ -49,45 +49,42 @@ struct TreeNodeBase
             newChild->parent_ = this;
     }
     
-    /// Parent node
+    /// Parent node.
     TreeNodeBase* parent_;
-    /// Child links
+    /// Child links.
     TreeNodeBase* link_[2];
-    /// Color flag
+    /// Color flag.
     bool isRed_;
 };
 
-/// Red-black tree iterator base class
+/// Red-black tree iterator base class.
 class TreeIteratorBase
 {
 public:
-    /// Construct
+    /// Construct.
     TreeIteratorBase() :
         ptr_(0),
         prev_(0)
     {
     }
     
-    /// Construct with a node pointer
+    /// Construct with a node pointer.
     TreeIteratorBase(TreeNodeBase* ptr) :
         ptr_(ptr),
         prev_(0)
     {
     }
     
-    /// Test for equality with another iterator
+    /// Test for equality with another iterator.
     bool operator == (const TreeIteratorBase& rhs) const { return ptr_ == rhs.ptr_; }
-    /// Test for inequality with another iterator
+    /// Test for inequality with another iterator.
     bool operator != (const TreeIteratorBase& rhs) const { return ptr_ != rhs.ptr_; }
     
-    /// Go to the next node
+    /// Go to the next node.
     void GotoNext()
     {
         if (!ptr_)
-        {
-            prev_ = 0;
             return;
-        }
         
         prev_ = ptr_;
         
@@ -105,7 +102,7 @@ public:
             ptr_ = ptr_->link_[0];
     }
     
-    /// Go to the previous node
+    /// Go to the previous node.
     void GotoPrev()
     {
         if (!ptr_)
@@ -131,17 +128,17 @@ public:
             ptr_ = ptr_->link_[1];
     }
     
-    /// Current node pointer
+    /// Current node pointer.
     TreeNodeBase* ptr_;
-    /// Previous node pointer, needed to back from the end
+    /// Previous node pointer, needed to go back from the end.
     TreeNodeBase* prev_;
 };
 
-/// Red-black tree base class
+/// Red-black tree base class.
 class TreeBase
 {
 public:
-    /// Construct
+    /// Construct.
     TreeBase() :
         root_(0),
         allocator_(0),
@@ -149,7 +146,7 @@ public:
     {
     }
     
-    /// Swap with another tree
+    /// Swap with another tree.
     void Swap(TreeBase& rhs)
     {
         ::Swap(root_, rhs.root_);
@@ -158,10 +155,10 @@ public:
     }
     
 protected:
-    /// Check whether a node is red
+    /// Check whether a node is red.
     bool IsRed(TreeNodeBase* node) const { return node && node->isRed_; }
     
-    /// Single rotation
+    /// Single rotation.
     TreeNodeBase* RotateSingle(TreeNodeBase* node, unsigned dir)
     {
         TreeNodeBase* save = node->link_[!dir];
@@ -175,17 +172,17 @@ protected:
         return save;
     }
     
-    /// Double rotation
+    /// Double rotation.
     TreeNodeBase* RotateDouble(TreeNodeBase* node, unsigned dir)
     {
         node->SetChild(!dir, RotateSingle(node->link_[!dir], !dir));
         return RotateSingle(node, dir);
     }
     
-    /// Root node
+    /// Root node.
     TreeNodeBase* root_;
-    /// Node allocator
+    /// Node allocator.
     AllocatorBlock* allocator_;
-    /// Number of nodes
+    /// Number of nodes.
     unsigned size_;
 };

+ 112 - 148
Engine/Container/Vector.h

@@ -29,85 +29,82 @@
 #include <cstring>
 #include <new>
 
-/// Vector template class
+/// Vector template class.
 template <class T> class Vector : public VectorBase
 {
 public:
     typedef RandomAccessIterator<T> Iterator;
     typedef RandomAccessConstIterator<T> ConstIterator;
     
-    /// Construct empty
+    /// Construct empty.
     Vector()
     {
     }
     
-    /// Construct with initial size
+    /// Construct with initial size.
     explicit Vector(unsigned size)
     {
         Resize(size, 0);
     }
     
-    /// Construct with initial data
+    /// Construct with initial data.
     Vector(const T* data, unsigned size)
     {
         Resize(size, data);
     }
     
-    /// Construct from another vector
+    /// Construct from another vector.
     Vector(const Vector<T>& vector)
     {
         *this = vector;
     }
     
-    /// Destruct
+    /// Destruct.
     ~Vector()
     {
         Clear();
         delete[] buffer_;
     }
     
-    /// Assign from another vector
+    /// Assign from another vector.
     Vector<T>& operator = (const Vector<T>& rhs)
     {
         Clear();
         Resize(rhs.size_, rhs.Buffer());
-        
         return *this;
     }
     
-    /// Add-assign an element
+    /// Add-assign an element.
     Vector<T>& operator += (const T& rhs)
     {
         Push(rhs);
         return *this;
     }
     
-    /// Add-assign another vector
+    /// Add-assign another vector.
     Vector<T>& operator += (const Vector<T>& rhs)
     {
         Push(rhs);
         return *this;
     }
     
-    /// Add an element
+    /// Add an element.
     Vector<T> operator + (const T& rhs) const
     {
         Vector<T> ret(*this);
         ret.Push(rhs);
-        
         return ret;
     }
     
-    /// Add another vector
+    /// Add another vector.
     Vector<T> operator + (const Vector<T>& rhs) const
     {
         Vector<T> ret(*this);
         ret.Push(rhs);
-        
         return ret;
     }
     
-    /// Test for equality with another vector
+    /// Test for equality with another vector.
     bool operator == (const Vector<T>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -124,7 +121,7 @@ public:
         return true;
     }
     
-    /// Test for inequality with another vector
+    /// Test for inequality with another vector.
     bool operator != (const Vector<T>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -141,35 +138,28 @@ public:
         return false;
     }
     
-    /// Return element at index
+    /// Return element at index.
     T& operator [] (unsigned index) { assert(index < size_); return Buffer()[index]; }
-    /// Return const element at index
+    /// Return const element at index.
     const T& operator [] (unsigned index) const { assert(index < size_); return Buffer()[index]; }
-    /// Return element at index
+    /// Return element at index.
     T& At(unsigned index) { assert(index < size_); return Buffer()[index]; }
-    /// Return const element at index
+    /// Return const element at index.
     const T& At(unsigned index) const { assert(index < size_); return Buffer()[index]; }
 
-    /// Add an element at the end
-    void Push(const T& value)
-    {
-        Resize(size_ + 1, &value);
-    }
+    /// Add an element at the end.
+    void Push(const T& value) { Resize(size_ + 1, &value); }
+    /// Add another vector at the end.
+    void Push(const Vector<T>& vector) { Resize(size_ + vector.size_, vector.Buffer()); }
     
-    /// Add another vector at the end
-    void Push(const Vector<T>& vector)
-    {
-        Resize(size_ + vector.size_, vector.Buffer());
-    }
-    
-    /// Remove the last element
+    /// Remove the last element.
     void Pop()
     {
         if (size_)
             Resize(size_ - 1, 0);
     }
     
-    /// Insert an element at position
+    /// Insert an element at position.
     void Insert(unsigned pos, const T& value)
     {
         if (pos > size_)
@@ -181,7 +171,7 @@ public:
         Buffer()[pos] = value;
     }
     
-    /// Insert another vector at position
+    /// Insert another vector at position.
     void Insert(unsigned pos, const Vector<T>& vector)
     {
         if (pos > size_)
@@ -193,7 +183,7 @@ public:
         CopyElements(Buffer() + pos, vector.Buffer(), vector.size_);
     }
     
-    /// Insert an element using an iterator
+    /// Insert an element using an iterator.
     Iterator Insert(const Iterator& dest, const T& value)
     {
         unsigned pos = dest - Begin();
@@ -204,7 +194,7 @@ public:
         return Begin() + pos;
     }
     
-    /// Insert a vector using an iterator
+    /// Insert a vector using an iterator.
     Iterator Insert(const Iterator& dest, const Vector<T>& vector)
     {
         unsigned pos = dest - Begin();
@@ -215,7 +205,7 @@ public:
         return Begin() + pos;
     }
     
-    /// Insert a vector partially by iterators
+    /// Insert a vector partially by iterators.
     Iterator Insert(const Iterator& dest, const ConstIterator& start, const ConstIterator& end)
     {
         unsigned pos = dest - Begin();
@@ -232,7 +222,7 @@ public:
         return Begin() + pos;
     }
     
-    /// Insert values
+    /// Insert elements.
     Iterator Insert(const Iterator& dest, const T* start, const T* end)
     {
         unsigned pos = dest - Begin();
@@ -249,7 +239,7 @@ public:
         return Begin() + pos;
     }
     
-    /// Erase a range of elements
+    /// Erase a range of elements.
     void Erase(unsigned pos, unsigned length = 1)
     {
         // Return if the range is illegal
@@ -260,7 +250,7 @@ public:
         Resize(size_ - length, 0);
     }
     
-    /// Erase an element by iterator
+    /// Erase an element by iterator.
     Iterator Erase(const Iterator& it)
     {
         unsigned pos = it - Begin();
@@ -271,7 +261,7 @@ public:
         return Begin() + pos;
     }
     
-    /// Erase a range by iterators
+    /// Erase a range by iterators.
     Iterator Erase(const Iterator& start, const Iterator& end)
     {
         unsigned pos = start - Begin();
@@ -283,19 +273,12 @@ public:
         return Begin() + pos;
     }
     
-    /// Clear the vector
-    void Clear()
-    {
-        Resize(0);
-    }
-    
-    /// Resize the vector
-    void Resize(unsigned newSize)
-    {
-        Resize(newSize, 0);
-    }
+    /// Clear the vector.
+    void Clear() { Resize(0); }
+    /// Resize the vector.
+    void Resize(unsigned newSize) { Resize(newSize, 0); }
     
-    /// %Set new capacity
+    /// %Set new capacity.
     void Reserve(unsigned newCapacity)
     {
         if (newCapacity < size_)
@@ -320,13 +303,10 @@ public:
         }
     }
     
-    /// Reallocate so that no extra memory is used
-    void Compact()
-    {
-        Reserve(size_);
-    }
+    /// Reallocate so that no extra memory is used.
+    void Compact() { Reserve(size_); }
     
-    /// Return iterator to value, or to the end if not found
+    /// Return iterator to value, or to the end if not found.
     Iterator Find(const T& value)
     {
         Iterator i = Begin();
@@ -335,7 +315,7 @@ public:
         return i;
     }
     
-    /// Return const iterator to value, or to the end if not found
+    /// Return const iterator to value, or to the end if not found.
     ConstIterator Find(const T& value) const
     {
         ConstIterator i = Begin();
@@ -344,40 +324,37 @@ public:
         return i;
     }
     
-    /// Return whether contains a specific value
-    bool Contains(const T& value) const
-    {
-        return Find(value) != End();
-    }
+    /// Return whether contains a specific value.
+    bool Contains(const T& value) const { return Find(value) != End(); }
     
-    /// Return iterator to the beginning
+    /// Return iterator to the beginning.
     Iterator Begin() { return Iterator(Buffer()); }
-    /// Return const iterator to the beginning
+    /// Return const iterator to the beginning.
     ConstIterator Begin() const { return ConstIterator(Buffer()); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     Iterator End() { return Iterator(Buffer() + size_); }
-    /// Return const iterator to the end
+    /// Return const iterator to the end.
     ConstIterator End() const { return ConstIterator(Buffer() + size_); }
-    /// Return first element
+    /// Return first element.
     T& Front() { return Buffer()[0]; }
-    /// Return const first element
+    /// Return const first element.
     const T& Front() const { return Buffer()[0]; }
-    /// Return last element
+    /// Return last element.
     T& Back() { return Buffer()[size_ - 1]; }
-    /// Return const last element
+    /// Return const last element.
     const T& Back() const { return Buffer()[size_ - 1]; }
-    /// Return size of vector
+    /// Return size of vector.
     unsigned Size() const { return size_; }
-    /// Return capacity of vector
+    /// Return capacity of vector.
     unsigned Capacity() const { return capacity_; }
-    /// Return whether vector is empty
+    /// Return whether vector is empty.
     bool Empty() const { return size_ == 0; }
     
 private:
-    /// Return the buffer with right type
+    /// Return the buffer with right type.
     T* Buffer() const { return reinterpret_cast<T*>(buffer_); }
     
-   /// Resize the vector and create/remove new elements as necessary
+   /// Resize the vector and create/remove new elements as necessary.
     void Resize(unsigned newSize, const T* src)
     {
         // If size shrinks, destruct the removed elements
@@ -413,7 +390,7 @@ private:
         size_ = newSize;
     }
     
-    /// Move a range of elements within the vector
+    /// Move a range of elements within the vector.
     void MoveRange(unsigned dest, unsigned src, unsigned count)
     {
         T* buffer = Buffer();
@@ -429,7 +406,7 @@ private:
         }
     }
     
-    /// Construct elements, optionally with source data
+    /// Construct elements, optionally with source data.
     static void ConstructElements(T* dest, const T* src, unsigned count)
     {
         if (!src)
@@ -444,14 +421,14 @@ private:
         }
     }
     
-    /// Copy elements from one buffer to another
+    /// Copy elements from one buffer to another.
     static void CopyElements(T* dest, const T* src, unsigned count)
     {
         for (unsigned i = 0; i < count; ++i)
             dest[i] = src[i];
     }
     
-    // Call the elements' destructors
+    // Call the elements' destructors.
     static void DestructElements(T* dest, unsigned count)
     {
         for (unsigned i = 0; i < count; ++i)
@@ -459,85 +436,82 @@ private:
     }
 };
 
-/// Vector template class for POD types. Does not call constructors or destructors and uses block move
+/// Vector template class for POD types. Does not call constructors or destructors and uses block move.
 template <class T> class PODVector : public VectorBase
 {
 public:
     typedef RandomAccessIterator<T> Iterator;
     typedef RandomAccessConstIterator<T> ConstIterator;
     
-    /// Construct empty
+    /// Construct empty.
     PODVector()
     {
     }
     
-    /// Construct with initial size
+    /// Construct with initial size.
     explicit PODVector(unsigned size)
     {
         Resize(size);
     }
     
-    /// Construct with initial data
+    /// Construct with initial data.
     PODVector(const T* data, unsigned size)
     {
         Resize(size);
         CopyElements(Buffer(), data, size);
     }
     
-    /// Construct from another vector
+    /// Construct from another vector.
     PODVector(const PODVector<T>& vector)
     {
         *this = vector;
     }
     
-    /// Destruct
+    /// Destruct.
     ~PODVector()
     {
         delete[] buffer_;
     }
     
-    /// Assign from another vector
+    /// Assign from another vector.
     PODVector<T>& operator = (const PODVector<T>& rhs)
     {
         Resize(rhs.size_);
         CopyElements(Buffer(), rhs.Buffer(), rhs.size_);
-        
         return *this;
     }
     
-    /// Add-assign an element
+    /// Add-assign an element.
     PODVector<T>& operator += (const T& rhs)
     {
         Push(rhs);
         return *this;
     }
     
-    /// Add-assign another vector
+    /// Add-assign another vector.
     PODVector<T>& operator += (const PODVector<T>& rhs)
     {
         Push(rhs);
         return *this;
     }
     
-    /// Add an element
+    /// Add an element.
     PODVector<T> operator + (const T& rhs) const
     {
         PODVector<T> ret(*this);
         ret.Push(rhs);
-        
         return ret;
     }
     
-    /// Add another vector
+    /// Add another vector.
     PODVector<T> operator + (const PODVector<T>& rhs) const
     {
         PODVector<T> ret(*this);
         ret.Push(rhs);
-        
         return ret;
     }
     
-    /// Test for equality with another vector
+    /// Test for equality with another vector.
     bool operator == (const PODVector<T>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -554,7 +528,7 @@ public:
         return true;
     }
     
-    /// Test for inequality with another vector
+    /// Test for inequality with another vector.
     bool operator != (const PODVector<T>& rhs) const
     {
         if (rhs.size_ != size_)
@@ -571,16 +545,16 @@ public:
         return false;
     }
     
-    /// Return element at index
+    /// Return element at index.
     T& operator [] (unsigned index) { assert(index < size_); return Buffer()[index]; }
-    /// Return const element at index
+    /// Return const element at index.
     const T& operator [] (unsigned index) const { assert(index < size_); return Buffer()[index]; }
-    /// Return element at index
+    /// Return element at index.
     T& At(unsigned index) { assert(index < size_); return Buffer()[index]; }
-    /// Return const element at index
+    /// Return const element at index.
     const T& At(unsigned index) const { assert(index < size_); return Buffer()[index]; }
     
-    /// Add an element at the end
+    /// Add an element at the end.
     void Push(const T& value)
     {
         if (size_ < capacity_)
@@ -590,7 +564,7 @@ public:
         Back() = value;
     }
     
-    /// Add another vector at the end
+    /// Add another vector at the end.
     void Push(const PODVector<T>& vector)
     {
         unsigned oldSize = size_;
@@ -598,14 +572,14 @@ public:
         CopyElements(Buffer() + oldSize, vector.Buffer(), vector.size_);
     }
     
-    /// Remove the last element
+    /// Remove the last element.
     void Pop()
     {
         if (size_)
             Resize(size_ - 1);
     }
     
-    /// Insert an element at position
+    /// Insert an element at position.
     void Insert(unsigned pos, const T& value)
     {
         if (pos > size_)
@@ -617,7 +591,7 @@ public:
         Buffer()[pos] = value;
     }
     
-    /// Insert another vector at position
+    /// Insert another vector at position.
     void Insert(unsigned pos, const PODVector<T>& vector)
     {
         if (pos > size_)
@@ -629,7 +603,7 @@ public:
         CopyElements(Buffer() + pos, vector.Buffer(), vector.size_);
     }
     
-    /// Insert an element using an iterator
+    /// Insert an element using an iterator.
     Iterator Insert(const Iterator& dest, const T& value)
     {
         unsigned pos = dest - Begin();
@@ -640,7 +614,7 @@ public:
         return Begin() + pos;
     }
     
-    /// Insert a vector using an iterator
+    /// Insert a vector using an iterator.
     Iterator Insert(const Iterator& dest, const PODVector<T>& vector)
     {
         unsigned pos = dest - Begin();
@@ -651,7 +625,7 @@ public:
         return Begin() + pos;
     }
     
-    /// Insert a vector partially by iterators
+    /// Insert a vector partially by iterators.
     Iterator Insert(const Iterator& dest, const ConstIterator& start, const ConstIterator& end)
     {
         unsigned pos = dest - Begin();
@@ -665,7 +639,7 @@ public:
         return Begin() + pos;
     }
     
-    /// Insert values
+    /// Insert elements.
     Iterator Insert(const Iterator& dest, const T* start, const T* end)
     {
         unsigned pos = dest - Begin();
@@ -682,7 +656,7 @@ public:
         return Begin() + pos;
     }
     
-    /// Erase a range of elements
+    /// Erase a range of elements.
     void Erase(unsigned pos, unsigned length = 1)
     {
         // Return if the range is illegal
@@ -693,7 +667,7 @@ public:
         Resize(size_ - length);
     }
     
-    /// Erase an element using an iterator
+    /// Erase an element using an iterator.
     Iterator Erase(const Iterator& it)
     {
         unsigned pos = it - Begin();
@@ -704,7 +678,7 @@ public:
         return Begin() + pos;
     }
     
-    /// Erase a range by iterators
+    /// Erase a range by iterators.
     Iterator Erase(const Iterator& start, const Iterator& end)
     {
         unsigned pos = start - Begin();
@@ -716,13 +690,10 @@ public:
         return Begin() + pos;
     }
     
-    /// Clear the vector
-    void Clear()
-    {
-        Resize(0);
-    }
+    /// Clear the vector.
+    void Clear() { Resize(0); }
     
-    /// Resize the vector
+    /// Resize the vector.
     void Resize(unsigned newSize)
     {
         if (newSize > capacity_)
@@ -748,7 +719,7 @@ public:
         size_ = newSize;
     }
     
-    /// %Set new capacity
+    /// %Set new capacity.
     void Reserve(unsigned newCapacity)
     {
         if (newCapacity < size_)
@@ -772,13 +743,10 @@ public:
         }
     }
     
-    /// Reallocate so that no extra memory is used
-    void Compact()
-    {
-        Reserve(size_);
-    }
+    /// Reallocate so that no extra memory is used.
+    void Compact() { Reserve(size_); }
     
-    /// Return iterator to value, or to the end if not found
+    /// Return iterator to value, or to the end if not found.
     Iterator Find(const T& value)
     {
         Iterator i = Begin();
@@ -787,7 +755,7 @@ public:
         return i;
     }
     
-    /// Return const iterator to value, or to the end if not found
+    /// Return const iterator to value, or to the end if not found.
     ConstIterator Find(const T& value) const
     {
         ConstIterator i = Begin();
@@ -796,47 +764,43 @@ public:
         return i;
     }
     
-    /// Return whether contains a specific value
-    bool Contains(const T& value) const
-    {
-        return Find(value) != End();
-    }
-    
-    /// Return iterator to the beginning
+    /// Return whether contains a specific value.
+    bool Contains(const T& value) const { return Find(value) != End(); }
+    /// Return iterator to the beginning.
     Iterator Begin() { return Iterator(Buffer()); }
-    /// Return const iterator to the beginning
+    /// Return const iterator to the beginning.
     ConstIterator Begin() const { return ConstIterator(Buffer()); }
-    /// Return iterator to the end
+    /// Return iterator to the end.
     Iterator End() { return Iterator(Buffer() + size_); }
-    /// Return const iterator to the end
+    /// Return const iterator to the end.
     ConstIterator End() const { return ConstIterator(Buffer() + size_); }
-    /// Return first element
+    /// Return first element.
     T& Front() { return Buffer()[0]; }
-    /// Return const first element
+    /// Return const first element.
     const T& Front() const { return Buffer()[0]; }
-    /// Return last element
+    /// Return last element.
     T& Back() { return Buffer()[size_ - 1]; }
-    /// Return const last element
+    /// Return const last element.
     const T& Back() const { return Buffer()[size_ - 1]; }
-    /// Return number of elements
+    /// Return number of elements.
     unsigned Size() const { return size_; }
-    /// Return capacity of vector
+    /// Return capacity of vector.
     unsigned Capacity() const { return capacity_; }
-    /// Return whether vector is empty
+    /// Return whether vector is empty.
     bool Empty() const { return size_ == 0; }
     
 private:
-    /// Return the buffer with right type
+    /// Return the buffer with right type.
     T* Buffer() const { return reinterpret_cast<T*>(buffer_); }
     
-    /// Move a range of elements within the vector
+    /// Move a range of elements within the vector.
     void MoveRange(unsigned dest, unsigned src, unsigned count)
     {
         if (count)
             memmove(Buffer() + dest, Buffer() + src, count * sizeof(T));
     }
     
-    /// Copy elements from one buffer to another
+    /// Copy elements from one buffer to another.
     static void CopyElements(T* dest, const T* src, unsigned count)
     {
         if (count)

+ 44 - 44
Engine/Container/VectorBase.h

@@ -25,109 +25,109 @@
 
 #include "Swap.h"
 
-/// Random access iterator
+/// Random access iterator.
 template <class T> class RandomAccessIterator
 {
 public:
-    /// Construct
+    /// Construct.
     explicit RandomAccessIterator(T* ptr) :
         ptr_(ptr)
     {
     }
     
-    /// Point to the object
+    /// Point to the object.
     T* operator -> () const { return ptr_; }
-    /// Dereference the object
+    /// Dereference the object.
     T& operator * () const { return *ptr_; }
-    /// Preincrement the pointer
+    /// Preincrement the pointer.
     RandomAccessIterator<T>& operator ++ () { ++ptr_; return *this; }
-    /// Postincrement the pointer
+    /// Postincrement the pointer.
     RandomAccessIterator<T> operator ++ (int) { RandomAccessIterator<T> it = *this; ++ptr_; return it; }
-    /// Predecrement the pointer
+    /// Predecrement the pointer.
     RandomAccessIterator<T>& operator -- () { --ptr_; return *this; }
-    /// Postdecrement the pointer
+    /// Postdecrement the pointer.
     RandomAccessIterator<T> operator -- (int) { RandomAccessIterator<T> it = *this; --ptr_; return it; }
-    /// Add an offset to the pointer
+    /// Add an offset to the pointer.
     RandomAccessIterator<T>& operator += (int value) { ptr_ += value; return *this; }
-    /// Subtract an offset from the pointer
+    /// Subtract an offset from the pointer.
     RandomAccessIterator<T>& operator -= (int value) { ptr_ -= value; return *this; }
-    /// Add an offset to the pointer
+    /// Add an offset to the pointer.
     RandomAccessIterator<T> operator + (int value) const { return RandomAccessIterator<T>(ptr_ + value); }
-    /// Subtract an offset from the pointer
+    /// Subtract an offset from the pointer.
     RandomAccessIterator<T> operator - (int value) const { return RandomAccessIterator<T>(ptr_ - value); }
-    /// Calculate offset to another iterator
+    /// Calculate offset to another iterator.
     int operator - (const RandomAccessIterator& rhs) const { return ptr_ - rhs.ptr_; }
-    /// Test for equality with another iterator
+    /// Test for equality with another iterator.
     bool operator == (const RandomAccessIterator& rhs) const { return ptr_ == rhs.ptr_; }
-    /// Test for inequality with another iterator
+    /// Test for inequality with another iterator.
     bool operator != (const RandomAccessIterator& rhs) const { return ptr_ != rhs.ptr_; }
-    /// Test for less than with another iterator
+    /// Test for less than with another iterator.
     bool operator < (const RandomAccessIterator& rhs) const { return ptr_ < rhs.ptr_; }
-    /// Test for greater than with another iterator
+    /// Test for greater than with another iterator.
     bool operator > (const RandomAccessIterator& rhs) const { return ptr_ > rhs.ptr_; }
     
-    /// Pointer
+    /// Pointer.
     T* ptr_;
 };
 
-/// Random access const iterator
+/// Random access const iterator.
 template <class T> class RandomAccessConstIterator
 {
 public:
-    /// Construct
+    /// Construct.
     explicit RandomAccessConstIterator(T* ptr) :
         ptr_(ptr)
     {
     }
     
-    /// Construct from a non-const iterator
+    /// Construct from a non-const iterator.
     RandomAccessConstIterator(const RandomAccessIterator<T>& rhs) :
         ptr_(rhs.ptr_)
     {
     }
     
-    /// Assign from a non-const iterator
+    /// Assign from a non-const iterator.
     RandomAccessConstIterator<T>& operator = (const RandomAccessIterator<T>& rhs) { ptr_ = rhs.ptr_; return *this; }
-    /// Point to the object
+    /// Point to the object.
     const T* operator -> () const { return ptr_; }
-    /// Dereference the object
+    /// Dereference the object.
     const T& operator * () const { return *ptr_; }
-    /// Preincrement the pointer
+    /// Preincrement the pointer.
     RandomAccessConstIterator<T>& operator ++ () { ++ptr_; return *this; }
-    /// Postincrement the pointer
+    /// Postincrement the pointer.
     RandomAccessConstIterator<T> operator ++ (int) { RandomAccessConstIterator<T> it = *this; ++ptr_; return it; }
-    /// Predecrement the pointer
+    /// Predecrement the pointer.
     RandomAccessConstIterator<T>& operator -- () { --ptr_; return *this; }
-    /// Postdecrement the pointer
+    /// Postdecrement the pointer.
     RandomAccessConstIterator<T> operator -- (int) { RandomAccessConstIterator<T> it = *this; --ptr_; return it; }
-    /// Add an offset to the pointer
+    /// Add an offset to the pointer.
     RandomAccessConstIterator<T>& operator += (int value) { ptr_ += value; return *this; }
-    /// Subtract an offset from the pointer
+    /// Subtract an offset from the pointer.
     RandomAccessConstIterator<T>& operator -= (int value) { ptr_ -= value; return *this; }
-    /// Add an offset to the pointer
+    /// Add an offset to the pointer.
     RandomAccessConstIterator<T> operator + (int value) const { return RandomAccessConstIterator<T>(ptr_ + value); }
-    /// Subtract an offset from the pointer
+    /// Subtract an offset from the pointer.
     RandomAccessConstIterator<T> operator - (int value) const { return RandomAccessConstIterator<T>(ptr_ - value); }
-    /// Calculate offset to another iterator
+    /// Calculate offset to another iterator.
     int operator - (const RandomAccessConstIterator& rhs) const { return ptr_ - rhs.ptr_; }
-    /// Test for equality with another iterator
+    /// Test for equality with another iterator.
     bool operator == (const RandomAccessConstIterator& rhs) const { return ptr_ == rhs.ptr_; }
-    /// Test for inequality with another iterator
+    /// Test for inequality with another iterator.
     bool operator != (const RandomAccessConstIterator& rhs) const { return ptr_ != rhs.ptr_; }
-    /// Test for less than with another iterator
+    /// Test for less than with another iterator.
     bool operator < (const RandomAccessConstIterator& rhs) const { return ptr_ < rhs.ptr_; }
-    /// Test for greater than with another iterator
+    /// Test for greater than with another iterator.
     bool operator > (const RandomAccessConstIterator& rhs) const { return ptr_ > rhs.ptr_; }
     
-    /// Pointer
+    /// Pointer.
     T* ptr_;
 };
 
-/// Vector base class
+/// Vector base class.
 class VectorBase
 {
 public:
-    /// Construct
+    /// Construct.
     VectorBase() :
         size_(0),
         capacity_(0),
@@ -135,7 +135,7 @@ public:
     {
     }
     
-    /// Swap with another vector
+    /// Swap with another vector.
     void Swap(VectorBase& rhs)
     {
         ::Swap(size_, rhs.size_);
@@ -144,10 +144,10 @@ public:
     }
     
 protected:
-    /// Size of vector
+    /// Size of vector.
     unsigned size_;
-    /// Buffer capacity
+    /// Buffer capacity.
     unsigned capacity_;
-    /// Buffer
+    /// Buffer.
     unsigned char* buffer_;
 };

+ 7 - 7
Engine/Core/AreaAllocator.h

@@ -26,24 +26,24 @@
 #include "Rect.h"
 #include "Vector.h"
 
-/// Rectangular area allocator
+/// Rectangular area allocator.
 class AreaAllocator
 {
 public:
-    /// Construct with given width and height
+    /// Construct with given width and height.
     AreaAllocator(int width, int height);
     
-    /// Reset to given width and height and remove all previous allocations
+    /// Reset to given width and height and remove all previous allocations.
     void Reset(int width, int height);
-    /// Try to allocate an area. Return true if successful, with x & y coordinates filled
+    /// Try to allocate an area. Return true if successful, with x & y coordinates filled.
     bool Allocate(int width, int height, int& x, int& y);
 
 private:
-    /// Cut the reserved area from a rectangle. Return true if the rectangle should be removed from the vector
+    /// Cut the reserved area from a rectangle. Return true if the rectangle should be removed from the vector.
     bool SplitRect(IntRect original, const IntRect& reserved);
-    /// Remove overlapping free rectangles
+    /// Remove overlapping free rectangles.
     void Cleanup();
     
-    /// Free rectangles
+    /// Free rectangles.
     PODVector<IntRect> freeAreas_;
 };

+ 20 - 20
Engine/Core/Attribute.h

@@ -26,33 +26,33 @@
 #include "Ptr.h"
 #include "Variant.h"
 
-/// Attribute used for file serialization
+/// Attribute used for file serialization.
 static const unsigned AM_FILE = 0x1;
-/// Attribute used for network replication
+/// Attribute used for network replication.
 static const unsigned AM_NET = 0x2;
-/// Attribute used for both file serialization and network replication (default)
+/// Attribute used for both file serialization and network replication (default.)
 static const unsigned AM_DEFAULT = 0x3;
-/// Attribute should use latest data grouping instead of delta update in network replication
+/// Attribute should use latest data grouping instead of delta update in network replication.
 static const unsigned AM_LATESTDATA = 0x4;
-/// Attribute should not be shown in the editor
+/// Attribute should not be shown in the editor.
 static const unsigned AM_NOEDIT = 0x8;
 
 class Serializable;
 
-/// Internal helper class for invoking attribute accessors
+/// Internal helper class for invoking attribute accessors.
 class AttributeAccessor : public RefCounted
 {
 public:
-    /// Get the attribute
+    /// Get the attribute.
     virtual void Get(Serializable* ptr, Variant& dest) {}
-    /// %Set the attribute
+    /// %Set the attribute.
     virtual void Set(Serializable* ptr, const Variant& src) {}
 };
 
-/// Description of an automatically serializable variable
+/// Description of an automatically serializable variable.
 struct AttributeInfo
 {
-    /// Construct empty
+    /// Construct empty.
     AttributeInfo() :
         type_(VAR_NONE),
         offset_(0),
@@ -61,7 +61,7 @@ struct AttributeInfo
     {
     }
     
-    /// Construct offset attribute
+    /// Construct offset attribute.
     AttributeInfo(VariantType type, const char* name, unsigned offset, const Variant& defaultValue, unsigned mode) :
         type_(type),
         name_(name),
@@ -72,7 +72,7 @@ struct AttributeInfo
     {
     }
     
-   /// Construct offset enum attribute
+    /// Construct offset enum attribute.
     AttributeInfo(VariantType type, const char* name, unsigned offset, const String* enumNames, const Variant& defaultValue, unsigned mode) :
         type_(type),
         name_(name),
@@ -83,7 +83,7 @@ struct AttributeInfo
     {
     }
     
-    /// Construct accessor attribute
+    /// Construct accessor attribute.
     AttributeInfo(VariantType type, const char* name, AttributeAccessor* accessor, const Variant& defaultValue, unsigned mode) :
         type_(type),
         name_(name),
@@ -95,18 +95,18 @@ struct AttributeInfo
     {
     }
     
-    /// Attribute type
+    /// Attribute type.
     VariantType type_;
-    /// Name
+    /// Name.
     String name_;
-    /// Byte offset from start of object
+    /// Byte offset from start of object.
     unsigned offset_;
-    /// Enum string names
+    /// Enum string names.
     const String* enumNames_;
-    /// Helper object for accessor mode
+    /// Helper object for accessor mode.
     SharedPtr<AttributeAccessor> accessor_;
-    /// Default value for network replication
+    /// Default value for network replication.
     Variant defaultValue_;
-    /// Attribute mode: whether to use for serialization, network replication, or both
+    /// Attribute mode: whether to use for serialization, network replication, or both.
     unsigned mode_;
 };

+ 51 - 77
Engine/Core/Context.h

@@ -27,51 +27,44 @@
 #include "HashSet.h"
 #include "Object.h"
 
-/// Execution context within a process. Provides access to the subsystems, object factories and attributes, and event receivers
+/// Execution context within a process. Provides access to the subsystems, object factories and attributes, and event receivers.
 class Context : public RefCounted
 {
 public:
-    /// Construct and create the Time & Profiler subsystems
+    /// Construct.
     Context();
-    /// Destruct
+    /// Destruct.
     ~Context();
     
-    /// Create an object by type. Return pointer to it or null if no factory found
+    /// Create an object by type. Return pointer to it or null if no factory found.
     SharedPtr<Object> CreateObject(ShortStringHash objectType);
-    /// Register a factory for an object type. If exists already, will not be replaced
+    /// Register a factory for an object type. If exists already, will not be replaced.
     void RegisterFactory(ObjectFactory* factory);
-    /// Register a subsystem. If exists already, will not be replaced
+    /// Register a subsystem. If exists already, will not be replaced.
     void RegisterSubsystem(Object* subsystem);
-    /// Register object attribute
+    /// Register object attribute.
     void RegisterAttribute(ShortStringHash objectType, const AttributeInfo& attr);
-    /// Remove object attribute
+    /// Remove object attribute.
     void RemoveAttribute(ShortStringHash objectType, const String& name);
-    /// Copy base class attributes to derived class
+    /// Copy base class attributes to derived class.
     void CopyBaseAttributes(ShortStringHash baseType, ShortStringHash derivedType);
-    /// Add event receiver
+    /// Add event receiver.
     void AddEventReceiver(Object* receiver, StringHash eventType);
-    /// Add event receiver for specific event
+    /// Add event receiver for specific event.
     void AddEventReceiver(Object* receiver, Object* sender, StringHash eventType);
-    /// Remove an event sender from all receivers. Called on its destruction
+    /// Remove an event sender from all receivers. Called on its destruction.
     void RemoveEventSender(Object* sender);
-    /// Remove event receiver from specific events
+    /// Remove event receiver from specific events.
     void RemoveEventReceiver(Object* receiver, Object* sender, StringHash eventType);
-    /// Remove event receiver from non-specific events
+    /// Remove event receiver from non-specific events.
     void RemoveEventReceiver(Object* receiver, StringHash eventType);
     
-    /// %Set current event handler. Called by Object
-    void SetEventHandler(EventHandler* handler)
-    {
-        eventHandler_ = handler;
-    }
+    /// %Set current event handler. Called by Object.
+    void SetEventHandler(EventHandler* handler) { eventHandler_ = handler; }
+    /// Begin event send.
+    void BeginSendEvent(Object* sender) { eventSenders_.Push(sender); }
     
-    /// Begin event send
-    void BeginSendEvent(Object* sender)
-    {
-        eventSenders_.Push(sender);
-    }
-    
-    /// End event send. Clean up event receivers removed in the meanwhile
+    /// End event send. Clean up event receivers removed in the meanwhile.
     void EndSendEvent()
     {
         eventSenders_.Pop();
@@ -114,49 +107,49 @@ public:
         }
     }
     
-    /// Template version of registering an object factory
+    /// Template version of registering an object factory.
     template <class T> void RegisterFactory();
-    /// Template version of registering an object attribute
+    /// Template version of registering an object attribute.
     template <class T> void RegisterAttribute(const AttributeInfo& attr);
-    /// Template version of removing an object attribue
+    /// Template version of removing an object attribute.
     template <class T> void RemoveAttribute(const char* name);
-    /// Template version of copying base class attributes to derived class
+    /// Template version of copying base class attributes to derived class.
     template <class T, class U> void CopyBaseAttributes();
     
-    /// Return subsystem by type
+    /// Return subsystem by type.
     Object* GetSubsystem(ShortStringHash type) const;
-    /// Return all subsystems
+    /// Return all subsystems.
     const Map<ShortStringHash, SharedPtr<Object> >& GetSubsystems() const { return subsystems_; }
-    /// Return all object factories
+    /// Return all object factories.
     const Map<ShortStringHash, SharedPtr<ObjectFactory> >& GetObjectFactories() const { return factories_; }
-    /// Return attributes for all object types
+    /// Return attributes for all object types.
     const Map<ShortStringHash, Vector<AttributeInfo> >& GetAllAttributes() const { return attributes_; }
-    /// Return network replication attributes for all object types
+    /// Return network replication attributes for all object types.
     const Map<ShortStringHash, Vector<AttributeInfo> >& GetAllNetworkAttributes() const { return networkAttributes_; }
-    /// Return active event sender. Null outside event handling
+    /// Return active event sender. Null outside event handling.
     Object* GetEventSender() const;
-    /// Return active event handler. Set by Object. Null outside event handling
+    /// Return active event handler. Set by Object. Null outside event handling.
     EventHandler* GetEventHandler() const { return eventHandler_; }
-    /// Return object type name from hash, or empty if unknown
+    /// Return object type name from hash, or empty if unknown.
     const String& GetTypeName(ShortStringHash type) const;
-    /// Template version of returning a subsystem
+    /// Template version of returning a subsystem.
     template <class T> T* GetSubsystem() const;
     
-    /// Return attribute descriptions for an object type, or null if none defined
+    /// Return attribute descriptions for an object type, or null if none defined.
     const Vector<AttributeInfo>* GetAttributes(ShortStringHash type) const
     {
         Map<ShortStringHash, Vector<AttributeInfo> >::ConstIterator i = attributes_.Find(type);
         return i != attributes_.End() ? &i->second_ : 0;
     }
     
-    /// Return network replication attribute descriptions for an object type, or null if none defined
+    /// Return network replication attribute descriptions for an object type, or null if none defined.
     const Vector<AttributeInfo>* GetNetworkAttributes(ShortStringHash type) const
     {
         Map<ShortStringHash, Vector<AttributeInfo> >::ConstIterator i = networkAttributes_.Find(type);
         return i != networkAttributes_.End() ? &i->second_ : 0;
     }
     
-    /// Return event receivers for a sender and event type, or null if they do not exist
+    /// Return event receivers for a sender and event type, or null if they do not exist.
     PODVector<Object*>* GetReceivers(Object* sender, StringHash eventType)
     {
         Map<Pair<Object*, StringHash>, PODVector<Object*> >::Iterator i = 
@@ -164,7 +157,7 @@ public:
         return i != specificEventReceivers_.End() ? &i->second_ : 0;
     }
     
-    /// Return event receivers for an event type, or null if they do not exist
+    /// Return event receivers for an event type, or null if they do not exist.
     PODVector<Object*>* GetReceivers(StringHash eventType)
     {
         Map<StringHash, PODVector<Object*> >::Iterator i = eventReceivers_.Find(eventType);
@@ -172,49 +165,30 @@ public:
     }
     
 private:
-    /// Object factories
+    /// Object factories.
     Map<ShortStringHash, SharedPtr<ObjectFactory> > factories_;
-    /// Subsystems
+    /// Subsystems.
     Map<ShortStringHash, SharedPtr<Object> > subsystems_;
-    /// Attribute descriptions per object type
+    /// Attribute descriptions per object type.
     Map<ShortStringHash, Vector<AttributeInfo> > attributes_;
-    /// Network replication attribute descriptions per object type
+    /// Network replication attribute descriptions per object type.
     Map<ShortStringHash, Vector<AttributeInfo> > networkAttributes_;
-    /// Event receivers for non-specific events
+    /// Event receivers for non-specific events.
     Map<StringHash, PODVector<Object*> > eventReceivers_;
-    /// Event receivers for specific senders' events
+    /// Event receivers for specific senders' events.
     Map<Pair<Object*, StringHash>, PODVector<Object*> > specificEventReceivers_;
-    /// Event sender stack
+    /// Event sender stack.
     PODVector<Object*> eventSenders_;
-    /// Event types that have had receivers removed during event handling
+    /// Event types that have had receivers removed during event handling.
     HashSet<StringHash> dirtyReceivers_;
-    /// Event types for specific senders that have had receivers removed during event handling
+    /// Event types for specific senders that have had receivers removed during event handling.
     HashSet<Pair<Object*, StringHash> > dirtySpecificReceivers_;
-    /// Active event handler. Not stored in a stack for performance reasons; is needed only in esoteric cases
+    /// Active event handler. Not stored in a stack for performance reasons; is needed only in esoteric cases.
     WeakPtr<EventHandler> eventHandler_;
 };
 
-template <class T> void Context::RegisterFactory()
-{
-    RegisterFactory(new ObjectFactoryImpl<T>(this));
-}
-
-template <class T> void Context::RegisterAttribute(const AttributeInfo& attr)
-{
-    RegisterAttribute(T::GetTypeStatic(), attr);
-}
-
-template <class T> void Context::RemoveAttribute(const char* name)
-{
-    RemoveAttribute(T::GetTypeStatic(), name);
-}
-
-template <class T, class U> void Context::CopyBaseAttributes()
-{
-    CopyBaseAttributes(T::GetTypeStatic(), U::GetTypeStatic());
-}
-
-template <class T> T* Context::GetSubsystem() const
-{
-    return static_cast<T*>(GetSubsystem(T::GetTypeStatic()));
-}
+template <class T> void Context::RegisterFactory() { RegisterFactory(new ObjectFactoryImpl<T>(this)); }
+template <class T> void Context::RegisterAttribute(const AttributeInfo& attr) { RegisterAttribute(T::GetTypeStatic(), attr); }
+template <class T> void Context::RemoveAttribute(const char* name) { RemoveAttribute(T::GetTypeStatic(), name); }
+template <class T, class U> void Context::CopyBaseAttributes() { CopyBaseAttributes(T::GetTypeStatic(), U::GetTypeStatic()); }
+template <class T> T* Context::GetSubsystem() const { return static_cast<T*>(GetSubsystem(T::GetTypeStatic())); }

+ 6 - 6
Engine/Core/CoreEvents.h

@@ -25,38 +25,38 @@
 
 #include "Object.h"
 
-/// Frame begin event
+/// Frame begin event.
 EVENT(E_BEGINFRAME, BeginFrame)
 {
     PARAM(P_FRAMENUMBER, FrameNumber);  // unsigned
     PARAM(P_TIMESTEP, TimeStep);        // float
 }
 
-/// Application-wide logic update event
+/// Application-wide logic update event.
 EVENT(E_UPDATE, Update)
 {
     PARAM(P_TIMESTEP, TimeStep);          // float
 }
 
-/// Application-wide logic post-update event
+/// Application-wide logic post-update event.
 EVENT(E_POSTUPDATE, PostUpdate)
 {
     PARAM(P_TIMESTEP, TimeStep);          // float
 }
 
-/// Render update event
+/// Render update event.
 EVENT(E_RENDERUPDATE, RenderUpdate)
 {
     PARAM(P_TIMESTEP, TimeStep);          // float
 }
 
-/// Post-render update event
+/// Post-render update event.
 EVENT(E_POSTRENDERUPDATE, PostRenderUpdate)
 {
     PARAM(P_TIMESTEP, TimeStep);          // float
 }
 
-/// Frame end event
+/// Frame end event.
 EVENT(E_ENDFRAME, EndFrame)
 {
 }

+ 1 - 1
Engine/Core/MiniDump.h

@@ -24,6 +24,6 @@
 #pragma once
 
 #ifdef ENABLE_MINIDUMPS
-/// Write a minidump. Needs to be called from within a structured exception handler
+/// Write a minidump. Needs to be called from within a structured exception handler.
 int WriteMiniDump(const char* applicationName, void* exceptionPointers);
 #endif

+ 10 - 10
Engine/Core/Mutex.h

@@ -23,35 +23,35 @@
 
 #pragma once
 
-/// Operating system mutual exclusion primitive
+/// Operating system mutual exclusion primitive.
 class Mutex
 {
 public:
-    /// Construct
+    /// Construct.
     Mutex();
-    /// Destruct
+    /// Destruct.
     ~Mutex();
     
-    /// Acquire the mutex. Block if already acquired
+    /// Acquire the mutex. Block if already acquired.
     void Acquire();
-    /// Release the mutex
+    /// Release the mutex.
     void Release();
     
 private:
-    /// Critical section
+    /// Critical section.
     void* criticalSection_;
 };
 
-/// Lock that automatically acquires and releases a mutex
+/// Lock that automatically acquires and releases a mutex.
 class MutexLock
 {
 public:
-    /// Construct and acquire the mutex
+    /// Construct and acquire the mutex.
     MutexLock(Mutex& mutex);
-    /// Destruct. Release the mutex
+    /// Destruct. Release the mutex.
     ~MutexLock();
     
 private:
-    /// Mutex reference
+    /// Mutex reference.
     Mutex& mutex_;
 };

+ 56 - 66
Engine/Core/Object.h

@@ -30,117 +30,110 @@
 class Context;
 class EventHandler;
 
-/// Base class for objects with type identification, subsystem access and event sending/receiving capability
+/// Base class for objects with type identification, subsystem access and event sending/receiving capability.
 class Object : public RefCounted
 {
 public:
-    /// Construct
+    /// Construct.
     Object(Context* context);
-    /// Destruct. Clean up self from event sender & receiver structures
+    /// Destruct. Clean up self from event sender & receiver structures.
     virtual ~Object();
     
-    /// Return type
+    /// Return type.
     virtual ShortStringHash GetType() const = 0;
-    /// Return type name
+    /// Return type name.
     virtual const String& GetTypeName() const = 0;
-    /// Handle event
+    /// Handle event.
     virtual void OnEvent(Object* sender, bool broadcast, StringHash eventType, VariantMap& eventData);
     
-    /// Subscribe to an event that can be sent by any sender
+    /// Subscribe to an event that can be sent by any sender.
     void SubscribeToEvent(StringHash eventType, EventHandler* handler);
-    /// Subscribe to a specific sender's event
+    /// Subscribe to a specific sender's event.
     void SubscribeToEvent(Object* sender, StringHash eventType, EventHandler* handler);
-    /// Unsubscribe from an event
+    /// Unsubscribe from an event.
     void UnsubscribeFromEvent(StringHash eventType);
-    /// Unsubscribe from a specific sender's event
+    /// Unsubscribe from a specific sender's event.
     void UnsubscribeFromEvent(Object* sender, StringHash eventType);
-    /// Unsubscribe from a specific sender's events
+    /// Unsubscribe from a specific sender's events.
     void UnsubscribeFromEvents(Object* sender);
-    /// Unsubscribe from all events
+    /// Unsubscribe from all events.
     void UnsubscribeFromAllEvents();
-    /// Unsubscribe from all events with userdata defined in the handler
+    /// Unsubscribe from all events with userdata defined in the handler.
     void UnsubscribeFromAllEventsWithUserData();
-    /// Send event to all subscribers
+    /// Send event to all subscribers.
     void SendEvent(StringHash eventType);
-    /// Send event with parameters to all subscribers
+    /// Send event with parameters to all subscribers.
     void SendEvent(StringHash eventType, VariantMap& eventData);
-    /// Send event to a specific receiver
+    /// Send event to a specific receiver.
     void SendEvent(Object* receiver, StringHash eventType);
-    /// Send event with parameters to a specific receiver
+    /// Send event with parameters to a specific receiver.
     void SendEvent(Object* receiver, StringHash eventType, VariantMap& eventData);
-    /// Template version of creating an object
+    /// Template version of creating an object.
     template <class T> SharedPtr<T> CreateObject();
     
-    /// Return execution context
+    /// Return execution context.
     Context* GetContext() const { return context_; }
-    /// Return subsystem by type
+    /// Return subsystem by type.
     Object* GetSubsystem(ShortStringHash type) const;
-    /// Return whether has subscribed to an event without specific sender
+    /// Return whether has subscribed to an event without specific sender.
     bool HasSubscribedToEvent(StringHash eventType) const;
-    /// Return whether has subscribed to a specific sender's event
+    /// Return whether has subscribed to a specific sender's event.
     bool HasSubscribedToEvent(Object* sender, StringHash eventType) const;
-    /// Return active event sender
+    /// Return active event sender.
     Object* GetEventSender() const;
-    /// Template version of returning a subsystem
+    /// Template version of returning a subsystem.
     template <class T> T* GetSubsystem() const;
     
-    /// Remove event handlers related to a specific sender
+    /// Remove event handlers related to a specific sender.
     void RemoveEventSender(Object* sender);
     
 protected:
-    /// Execution context
+    /// Execution context.
     Context* context_;
     
 private:
-    /// Event handlers. Sender is null for non-specific handlers
+    /// Event handlers. Sender is null for non-specific handlers.
     Map<Pair<Object*, StringHash>, SharedPtr<EventHandler> > eventHandlers_;
 };
 
-template <class T> SharedPtr<T> Object::CreateObject()
-{
-    return StaticCast<T>(CreateObject(T::GetTypeStatic()));
-}
-
-template <class T> T* Object::GetSubsystem() const
-{
-    return static_cast<T*>(GetSubsystem(T::GetTypeStatic()));
-}
+template <class T> SharedPtr<T> Object::CreateObject() { return StaticCast<T>(CreateObject(T::GetTypeStatic())); }
+template <class T> T* Object::GetSubsystem() const { return static_cast<T*>(GetSubsystem(T::GetTypeStatic())); }
 
-/// Object factory
+/// Base class for object factories.
 class ObjectFactory : public RefCounted
 {
 public:
-    /// Construct
+    /// Construct.
     ObjectFactory(Context* context) :
         context_(context)
     {
         assert(context_);
     }
     
-    /// Create an object. Implemented in templated subclasses
+    /// Create an object. Implemented in templated subclasses.
     virtual SharedPtr<Object> CreateObject() = 0;
     
-    /// Return execution context
+    /// Return execution context.
     Context* GetContext() const { return context_; }
-    /// Return type
+    /// Return type.
     ShortStringHash GetType() const { return type_; }
-    /// Return typename
+    /// Return typename.
     const String& GetTypeName() const { return typeName_; }
     
 protected:
-    /// Execution context
+    /// Execution context.
     Context* context_;
-    /// Object type
+    /// Object type.
     ShortStringHash type_;
-    /// Object typename
+    /// Object typename.
     String typeName_;
 };
 
-/// Template implementation of the object factory
+/// Template implementation of the object factory.
 template <class T> class ObjectFactoryImpl : public ObjectFactory
 {
 public:
-    /// Construct
+    /// Construct.
     ObjectFactoryImpl(Context* context) :
         ObjectFactory(context)
     {
@@ -148,18 +141,15 @@ public:
         typeName_ = T::GetTypeNameStatic();
     }
     
-    /// Create an object of the specific type
-    virtual SharedPtr<Object>(CreateObject())
-    {
-        return SharedPtr<Object>(new T(context_));
-    }
+    /// Create an object of the specific type.
+    virtual SharedPtr<Object>(CreateObject()) { return SharedPtr<Object>(new T(context_)); }
 };
 
-/// Internal helper class for invoking event handler functions
+/// Internal helper class for invoking event handler functions.
 class EventHandler : public RefCounted
 {
 public:
-    /// Construct with specified receiver
+    /// Construct with specified receiver.
     EventHandler(Object* receiver) :
         receiver_(receiver),
         userData_(0)
@@ -167,7 +157,7 @@ public:
         assert(receiver_);
     }
     
-    /// Construct with specified receiver and userdata
+    /// Construct with specified receiver and userdata.
     EventHandler(Object* receiver, void* userData) :
         receiver_(receiver),
         userData_(userData)
@@ -175,31 +165,31 @@ public:
         assert(receiver_);
     }
     
-    /// Destruct
+    /// Destruct.
     virtual ~EventHandler() {}
     
-    /// Invoke event handler function
+    /// Invoke event handler function.
     virtual void Invoke(StringHash eventType, VariantMap& eventData) = 0;
     
-    /// Return event receiver
+    /// Return event receiver.
     Object* GetReceiver() const { return receiver_; }
-    /// Return userdata
+    /// Return userdata.
     void* GetUserData() const { return userData_; }
     
 protected:
-    /// Event receiver
+    /// Event receiver.
     Object* receiver_;
-    /// Userdata
+    /// Userdata.
     void* userData_;
 };
 
-/// Template implementation of the event handler invoke helper (stores a function pointer of specific class)
+/// Template implementation of the event handler invoke helper (stores a function pointer of specific class.)
 template <class T> class EventHandlerImpl : public EventHandler
 {
 public:
     typedef void (T::*HandlerFunctionPtr)(StringHash, VariantMap&);
     
-    /// Construct with receiver and function pointers
+    /// Construct with receiver and function pointers.
     EventHandlerImpl(T* receiver, HandlerFunctionPtr function) :
         EventHandler(receiver),
         function_(function)
@@ -207,7 +197,7 @@ public:
         assert(function_);
     }
     
-    /// Construct with receiver and function pointers and userdata
+    /// Construct with receiver and function pointers and userdata.
     EventHandlerImpl(T* receiver, HandlerFunctionPtr function, void* userData) :
         EventHandler(receiver, userData),
         function_(function)
@@ -215,7 +205,7 @@ public:
         assert(function_);
     }
     
-    /// Invoke event handler function
+    /// Invoke event handler function.
     virtual void Invoke(StringHash eventType, VariantMap& eventData)
     {
         T* receiver = static_cast<T*>(receiver_);
@@ -223,7 +213,7 @@ public:
     }
     
 private:
-    /// Class-specific pointer to handler function
+    /// Class-specific pointer to handler function.
     HandlerFunctionPtr function_;
 };
 

+ 10 - 10
Engine/Core/ProcessUtils.h

@@ -27,23 +27,23 @@
 
 class Mutex;
 
-/// Display an error dialog with the specified title and message
+/// Display an error dialog with the specified title and message.
 void ErrorDialog(const char* title, const char* message);
-/// Exit the application with an error message to the console
+/// Exit the application with an error message to the console.
 void ErrorExit(const String& message, int exitCode = 1);
-/// Open a console window
+/// Open a console window.
 void OpenConsoleWindow();
-/// Print to the console. A newline will be added automatically
+/// Print to the console. A newline will be added automatically.
 void PrintLine(const String& str);
-/// Print to the console. A newline will be added automatically
+/// Print to the console. A newline will be added automatically.
 void PrintLine(const char* str);
-/// Return the static library init/shutdown mutex
+/// Return the static library init/shutdown mutex.
 Mutex& GetStaticMutex();
-/// Parse arguments from the command line
+/// Parse arguments from the command line.
 const Vector<String>& ParseArguments(const char* cmdLine);
-/// Return previously parsed arguments
+/// Return previously parsed arguments.
 const Vector<String>& GetArguments();
-/// Read input from the console window. Return empty if no input
+/// Read input from the console window. Return empty if no input.
 String GetConsoleInput();
-/// Return the number of (logical) CPU cores
+/// Return the number of (logical) CPU cores.
 unsigned GetNumCPUCores();

+ 52 - 52
Engine/Core/Profiler.h

@@ -25,11 +25,11 @@
 
 #include "Timer.h"
 
-/// Profiling data for one block in the profiling tree
+/// Profiling data for one block in the profiling tree.
 class ProfilerBlock
 {
 public:
-    /// Construct with the specified parent block and name
+    /// Construct with the specified parent block and name.
     ProfilerBlock(ProfilerBlock* parent, const char* name) :
         name_(name),
         time_(0),
@@ -46,7 +46,7 @@ public:
     {
     }
     
-    /// Destruct. Free the child blocks
+    /// Destruct. Free the child blocks.
     ~ProfilerBlock()
     {
         for (PODVector<ProfilerBlock*>::Iterator i = children_.Begin(); i != children_.End(); ++i)
@@ -56,20 +56,20 @@ public:
         }
     }
     
-    /// Begin timing. Call count can also be specified if known to reduce overhead
+    /// Begin timing. Call count can also be specified if known to reduce overhead.
     void Begin(unsigned count = 1)
     {
         timer_.Reset();
         count_ += count;
     }
     
-    /// End timing
+    /// End timing.
     void End()
     {
         time_ += timer_.GetUSec(false);
     }
     
-    /// End profiling frame and update accumulation period and total values
+    /// End profiling frame and update accumulation period and total values.
     void EndFrame()
     {
         frameTime_ = time_;
@@ -85,7 +85,7 @@ public:
             (*i)->EndFrame();
     }
     
-    /// Clear accumulation period data
+    /// Clear accumulation period data.
     void ClearAccumulated()
     {
         accumulatedTime_ = 0;
@@ -95,7 +95,7 @@ public:
             (*i)->ClearAccumulated();
     }
     
-    /// Return child block with the specified name
+    /// Return child block with the specified name.
     ProfilerBlock* GetChild(const char* name)
     {
         if (name == lastSearchName_)
@@ -119,78 +119,78 @@ public:
         return newBlock;
     }
     
-    /// Return name of block
+    /// Return name of block.
     const char* GetName() const { return name_; }
     
-    /// Return accumulated time during last frame
+    /// Return accumulated time during last frame.
     long long GetFrameTime() const { return frameTime_; }
-    /// Return number of calls during last frame
+    /// Return number of calls during last frame.
     unsigned GetFrameCount() const { return frameCount_; }
-    /// Return accumulated time during the current accumulation period
+    /// Return accumulated time during the current accumulation period.
     long long GetAccumulatedTime() const { return accumulatedTime_; }
-    /// Return number of calls during the current accumulation period
+    /// Return number of calls during the current accumulation period.
     unsigned GetAccumulatedCount() const { return accumulatedCount_; }
-    /// Return total accumulated time
+    /// Return total accumulated time.
     long long GetTotalTime() const { return totalTime_; }
-    /// Return total number of calls
+    /// Return total number of calls.
     unsigned GetTotalCount() const { return totalCount_; }
-    /// Return parent block
+    /// Return parent block.
     ProfilerBlock* GetParent() const { return parent_; }
-    /// Return child blocks
+    /// Return child blocks.
     const PODVector<ProfilerBlock*>& GetChildren() const { return children_; }
     
 private:
-    /// Block name
+    /// Block name.
     const char* name_;
-    /// High-resolution timer for measuring the block duration
+    /// High-resolution timer for measuring the block duration.
     HiresTimer timer_;
-    /// Time on current frame
+    /// Time on current frame.
     long long time_;
-    /// Calls on current frame
+    /// Calls on current frame.
     unsigned count_;
 
-    /// Parent block
-    ProfilerBlock* parent_;    
-    /// Last queried child block name (optimization)
+    /// Parent block.
+    ProfilerBlock* parent_;
+    /// Last queried child block name (optimization.)
     const char* lastSearchName_;
-    /// Last queried child block (optimization)
+    /// Last queried child block (optimization.)
     ProfilerBlock* lastSearchBlock_;
-    /// Child blocks
+    /// Child blocks.
     PODVector<ProfilerBlock*> children_;
     
-    /// Time on the previous frame
+    /// Time on the previous frame.
     long long frameTime_;
-    /// Calls on the previous frame
+    /// Calls on the previous frame.
     unsigned frameCount_;
-    /// Time on the accumulation period
+    /// Time on the accumulation period.
     long long accumulatedTime_;
-    /// Calls on the accumulation period
+    /// Calls on the accumulation period.
     unsigned accumulatedCount_;
-    /// Total time
+    /// Total time.
     long long totalTime_;
-    /// Total calls
+    /// Total calls.
     unsigned totalCount_;
 };
 
-/// Hierarchical performance profiler subsystem
+/// Hierarchical performance profiler subsystem.
 class Profiler : public Object
 {
     OBJECT(Profiler);
     
 public:
-    /// Construct
+    /// Construct.
     Profiler(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~Profiler();
     
-    /// Begin timing a profiling block. Call count can also be specified if known to reduce overhead
+    /// Begin timing a profiling block. Call count can also be specified if known to reduce overhead.
     void BeginBlock(const char* name, unsigned count = 1)
     {
         current_ = current_->GetChild(name);
         current_->Begin(count);
     }
     
-    /// End timing the current profiling block
+    /// End timing the current profiling block.
     void EndBlock()
     {
         if (current_ != root_)
@@ -200,33 +200,33 @@ public:
         }
     }
     
-    /// Begin the profiling frame. Called by HandleBeginFrame()
+    /// Begin the profiling frame. Called by HandleBeginFrame().
     void BeginFrame();
-    /// End the profiling frame. Called by HandleEndFrame()
+    /// End the profiling frame. Called by HandleEndFrame().
     void EndFrame();
-    /// Begin a new accumulation period
+    /// Begin a new accumulation period.
     void ClearAccumulated();
     
-    /// Return profiling data as text output
+    /// Return profiling data as text output.
     String GetData(bool showUnused = false, bool showAccumulated = false, bool showTotal = false) const;
-    /// Return the current profiling block
+    /// Return the current profiling block.
     const ProfilerBlock* GetCurrentBlock() { return current_; }
     
 private:
-    /// Return profiling data as text output for a specified profiling block
+    /// Return profiling data as text output for a specified profiling block.
     void GetData(ProfilerBlock* block, String& output, unsigned indent, bool showUnused, bool showAccumulated, bool showTotal) const;
-    /// Handle begin frame event
+    /// Handle begin frame event.
     void HandleBeginFrame(StringHash eventType, VariantMap& eventData);
-    /// Handle end frame event
+    /// Handle end frame event.
     void HandleEndFrame(StringHash eventType, VariantMap& eventData);
     
-    /// Current profiling block
+    /// Current profiling block.
     ProfilerBlock* current_;
-    /// Root profiling block
+    /// Root profiling block.
     ProfilerBlock* root_;
-    /// Frames in the current accumulation period
+    /// Frames in the current accumulation period.
     unsigned accumulatedFrames_;
-    /// Total frames
+    /// Total frames.
     unsigned totalFrames_;
 };
 
@@ -234,7 +234,7 @@ private:
 class AutoProfileBlock
 {
 public:
-    /// Construct. Begin a profiling block with the specified name and optional call count
+    /// Construct. Begin a profiling block with the specified name and optional call count.
     AutoProfileBlock(Profiler* profiler, const char* name, unsigned count = 1) :
         profiler_(profiler)
     {
@@ -242,7 +242,7 @@ public:
             profiler_->BeginBlock(name, count);
     }
     
-    /// Destruct. End the profiling block
+    /// Destruct. End the profiling block.
     ~AutoProfileBlock()
     {
         if (profiler_)
@@ -250,7 +250,7 @@ public:
     }
     
 private:
-    /// Profiler
+    /// Profiler.
     Profiler* profiler_;
 };
 

+ 43 - 43
Engine/Core/StringHash.h

@@ -25,42 +25,42 @@
 
 #include "StringBase.h"
 
-/// 32-bit hash value for a string
+/// 32-bit hash value for a string.
 class StringHash
 {
 public:
-    /// Construct with zero value
+    /// Construct with zero value.
     StringHash() :
         value_(0)
     {
     }
     
-    /// Copy-construct from another hash
+    /// Copy-construct from another hash.
     StringHash(const StringHash& rhs) :
         value_(rhs.value_)
     {
     }
     
-    /// Construct with an initial value
+    /// Construct with an initial value.
     explicit StringHash(unsigned value) :
         value_(value)
     {
     }
     
-    /// Construct from a C string case-insensitively
+    /// Construct from a C string case-insensitively.
     explicit StringHash(const char* str);
     
-    /// Construct from a string case-insensitively
+    /// Construct from a string case-insensitively.
     explicit StringHash(const String& str);
     
-    /// Assign from another hash
+    /// Assign from another hash.
     StringHash& operator = (const StringHash& rhs)
     {
         value_ = rhs.value_;
         return *this;
     }
     
-    /// Add a hash
+    /// Add a hash.
     StringHash operator + (const StringHash& rhs) const
     {
         StringHash ret;
@@ -68,84 +68,84 @@ public:
         return ret;
     }
     
-    /// Add-assign a hash
+    /// Add-assign a hash.
     StringHash& operator += (const StringHash& rhs)
     {
         value_ += rhs.value_;
         return *this;
     }
     
-    // Test for equality with another hash
+    // Test for equality with another hash.
     bool operator == (const StringHash& rhs) const { return value_ == rhs.value_; }
-    /// Test for inequality with another hash
+    /// Test for inequality with another hash.
     bool operator != (const StringHash& rhs) const { return value_ != rhs.value_; }
-    /// Test if less than another hash
+    /// Test if less than another hash.
     bool operator < (const StringHash& rhs) const { return value_ < rhs.value_; }
-    /// Test if greater than another hash
+    /// Test if greater than another hash.
     bool operator > (const StringHash& rhs) const { return value_ > rhs.value_; }
-    /// Return true if nonzero hash value
+    /// Return true if nonzero hash value.
     operator bool () const { return value_ != 0; }
-    /// Return hash value
+    /// Return hash value.
     unsigned GetValue() const { return value_; }
-    /// Return unsigned data
+    /// Return unsigned data.
     const unsigned* GetData() const { return &value_; }
-    /// Return as string
+    /// Return as string.
     String ToString() const;
-    /// Return hash value for HashSet & HashMap
+    /// Return hash value for HashSet & HashMap.
     unsigned ToHash() const { return value_; }
     
-    /// Calculate hash value case-insensitively from a C string
+    /// Calculate hash value case-insensitively from a C string.
     static unsigned Calculate(const char* str);
     
-    /// Zero hash
+    /// Zero hash.
     static const StringHash ZERO;
     
 private:
-    /// Hash value
+    /// Hash value.
     unsigned value_;
 };
 
-/// 16-bit hash value for a string
+/// 16-bit hash value for a string.
 class ShortStringHash
 {
 public:
-    /// Construct with zero hash value
+    /// Construct with zero hash value.
     ShortStringHash() :
         value_(0)
     {
     }
     
-    /// Copy-construct from another hash value
+    /// Copy-construct from another hash value.
     ShortStringHash(const ShortStringHash& rhs) :
         value_(rhs.value_)
     {
     }
     
-    /// Copy-construct from another 32-bit hash value (ignore the high bits)
+    /// Copy-construct from another 32-bit hash value (ignore the high bits.)
     explicit ShortStringHash(const StringHash& rhs) :
         value_(rhs.GetValue())
     {
     }
     
-    /// Construct with an initial value
+    /// Construct with an initial value.
     explicit ShortStringHash(unsigned short value) :
         value_(value)
     {
     }
 
-    /// Construct from a C string case-insensitively
+    /// Construct from a C string case-insensitively.
     explicit ShortStringHash(const char* str);
-    /// Construct from a string case-insensitively
+    /// Construct from a string case-insensitively.
     explicit ShortStringHash(const String& str);
     
-    /// Assign from another hash
+    /// Assign from another hash.
     ShortStringHash& operator = (const ShortStringHash& rhs)
     {
         value_ = rhs.value_;
         return *this;
     }
     
-    /// Add a hash
+    /// Add a hash.
     ShortStringHash operator + (const ShortStringHash& rhs) const
     {
         ShortStringHash ret;
@@ -153,40 +153,40 @@ public:
         return ret;
     }
     
-    // Add-assign a hash
+    // Add-assign a hash.
     ShortStringHash& operator += (const ShortStringHash& rhs)
     {
         value_ += rhs.value_;
         return *this;
     }
     
-    /// Test for equality with another hash
+    /// Test for equality with another hash.
     bool operator == (const ShortStringHash& rhs) const { return value_ == rhs.value_; }
-    /// Test for inequality with another hash
+    /// Test for inequality with another hash.
     bool operator != (const ShortStringHash& rhs) const { return value_ != rhs.value_; }
-    /// Test if less than another hash
+    /// Test if less than another hash.
     bool operator < (const ShortStringHash& rhs) const { return value_ < rhs.value_; }
-    /// Test if greater than another hash
+    /// Test if greater than another hash.
     bool operator > (const ShortStringHash& rhs) const { return value_ > rhs.value_; }
-    /// Return true if nonzero hash value
+    /// Return true if nonzero hash value.
     operator bool () const { return value_ != 0; }
-    /// Return hash value
+    /// Return hash value.
     unsigned short GetValue() const { return value_; }
-    /// Return unsigned short data
+    /// Return unsigned short data.
     const unsigned short* GetData() const { return &value_; }
-    /// Return as string
+    /// Return as string.
     String ToString() const;
-    /// Return hash value for HashSet & HashMap
+    /// Return hash value for HashSet & HashMap.
     unsigned ToHash() const { return value_; }
     
-    /// Calculate hash value case-insensitively from a C string
+    /// Calculate hash value case-insensitively from a C string.
     static unsigned short Calculate(const char* str);
     
-    /// Zero hash
+    /// Zero hash.
     static const ShortStringHash ZERO;
     
 private:
-    /// Hash value
+    /// Hash value.
     unsigned short value_;
 };
 

+ 10 - 7
Engine/Core/StringUtils.cpp

@@ -31,13 +31,16 @@
 
 bool ToBool(const String& source)
 {
-    if (source.Empty())
-        return false;
-    char first = tolower(source[0]);
-    if (first == 't' || first == 'y' || first == '1')
-        return true;
-    else
-        return false;
+    for (unsigned i = 0; i < source.Length(); ++i)
+    {
+        char c = tolower(source[0]);
+        if (c == 't' || c == 'y' || c == '1')
+            return true;
+        else if (c != ' ' && c != '\t')
+            break;
+    }
+    
+    return false;
 }
 
 int ToInt(const String& source)

+ 15 - 15
Engine/Core/StringUtils.h

@@ -29,34 +29,34 @@
 #include "StringHash.h"
 #include "Vector4.h"
 
-/// Parse a bool from a string. Check for the substring "true" case-insensitively
+/// Parse a bool from a string. Check for the first non-empty character (converted to lowercase) being either 't', 'y' or '1'.
 bool ToBool(const String& source);
-/// Parse a float from a string
+/// Parse a float from a string.
 float ToFloat(const String& source);
-/// Parse an integer from a string
+/// Parse an integer from a string.
 int ToInt(const String& source);
-/// Parse an unsigned integer from a string
+/// Parse an unsigned integer from a string.
 unsigned ToUInt(const String& source);
-/// Parse a Color from a string
+/// Parse a Color from a string.
 Color ToColor(const String& source);
-/// Parse an IntRect from a string
+/// Parse an IntRect from a string.
 IntRect ToIntRect(const String& source);
-/// Parse an IntVector2 from a string
+/// Parse an IntVector2 from a string.
 IntVector2 ToIntVector2(const String& source);
-/// Parse a Quaternion from a string. If only 3 components specified, convert Euler angles (degrees) to quaternion
+/// Parse a Quaternion from a string. If only 3 components specified, convert Euler angles (degrees) to quaternion.
 Quaternion ToQuaternion(const String& source);
-/// Parse a Rect from a string
+/// Parse a Rect from a string.
 Rect ToRect(const String& source);
-/// Parse a Vector2 from a string
+/// Parse a Vector2 from a string.
 Vector2 ToVector2(const String& source);
-/// Parse a Vector3 from a string
+/// Parse a Vector3 from a string.
 Vector3 ToVector3(const String& source);
-/// Parse a Vector4 from a string
+/// Parse a Vector4 from a string.
 Vector4 ToVector4(const String& source, bool allowMissingCoords = false);
-/// Convert a pointer to string (returns hexadecimal)
+/// Convert a pointer to string (returns hexadecimal.)
 String ToString(void* value);
-/// Convert an unsigned integer to string as hexadecimal
+/// Convert an unsigned integer to string as hexadecimal.
 String ToStringHex(unsigned value);
 
-/// Return an index to a string list corresponding to the given string, or a default value if not found. The string list must be empty-terminated
+/// Return an index to a string list corresponding to the given string, or a default value if not found. The string list must be empty-terminated.
 unsigned GetStringListIndex(const String& value, const String* strings, unsigned defaultIndex, bool caseSensitive = false);

+ 1 - 1
Engine/Core/Thread.cpp

@@ -64,7 +64,7 @@ bool Thread::Start()
 {
     // Check if already running
     if (handle_)
-        return true;
+        return false;
     
     shouldRun_ = true;
     #ifdef WIN32

+ 9 - 9
Engine/Core/Thread.h

@@ -23,31 +23,31 @@
 
 #pragma once
 
-/// Operating system thread
+/// Operating system thread.
 class Thread
 {
 public:
-    /// Construct. Does not start the thread yet
+    /// Construct. Does not start the thread yet.
     Thread();
-    /// Destruct. If running, stop and wait for thread to finish
+    /// Destruct. If running, stop and wait for thread to finish.
     ~Thread();
     
-    /// The function to run in the thread
+    /// The function to run in the thread.
     virtual void ThreadFunction() = 0;
     
-    /// Start running the thread. Return true if successful, or false if already running or if can not create the thread
+    /// Start running the thread. Return true if successful, or false if already running or if can not create the thread.
     bool Start();
-    /// %Set the running flag to false and wait for the thread to finish
+    /// %Set the running flag to false and wait for the thread to finish.
     void Stop();
-    /// %Set thread priority. The thread must have been started first
+    /// %Set thread priority. The thread must have been started first.
     void SetPriority(int priority);
     
     /// Return whether thread exists
     bool IsStarted() const { return handle_ != 0; }
     
 protected:
-    /// Thread handle
+    /// Thread handle.
     void* handle_;
-    /// Running flag
+    /// Running flag.
     volatile bool shouldRun_;
 };

+ 31 - 31
Engine/Core/Timer.h

@@ -25,94 +25,94 @@
 
 #include "Object.h"
 
-/// Time and frame counter subsystem
+/// Time and frame counter subsystem.
 class Time : public Object
 {
     OBJECT(Time);
     
 public:
-    /// Construct
+    /// Construct.
     Time(Context* context);
-    /// Destruct. Reset the low-resolution timer period if set
+    /// Destruct. Reset the low-resolution timer period if set.
     virtual ~Time();
     
-    /// Begin new frame, with (last) frame duration in milliseconds. Send frame start event, then the update events
+    /// Begin new frame, with (last) frame duration in milliseconds. Send frame start event, then the update events.
     void BeginFrame(unsigned mSec);
-    /// End frame. Increment total time and send frame end event
+    /// End frame. Increment total time and send frame end event.
     void EndFrame();
-    /// %Set the low-resolution timer period in milliseconds. 0 resets to the default period
+    /// %Set the low-resolution timer period in milliseconds. 0 resets to the default period.
     void SetTimerPeriod(unsigned mSec);
     
-    /// Return frame number, starting from 1 once BeginFrame() is called for the first time
+    /// Return frame number, starting from 1 once BeginFrame() is called for the first time.
     unsigned GetFrameNumber() const { return frameNumber_; }
-    /// Return current frame timestep as seconds
+    /// Return current frame timestep as seconds.
     float GetTimeStep() const { return timeStep_; }
-    /// Return current frame timestep as milliseconds
+    /// Return current frame timestep as milliseconds.
     unsigned GetTimeStepMSec() const { return timeStepMSec_; }
-    /// Return total elapsed time of frames in milliseconds
+    /// Return total elapsed time of frames in milliseconds.
     unsigned GetTotalMSec() const { return totalMSec_; }
-    /// Return current low-resolution timer period in milliseconds
+    /// Return current low-resolution timer period in milliseconds.
     unsigned GetTimerPeriod() const { return timerPeriod_; }
     
-    /// Sleep for a number of milliseconds
+    /// Sleep for a number of milliseconds.
     static void Sleep(unsigned mSec);
     
 private:
-    /// Frame number
+    /// Frame number.
     unsigned frameNumber_;
-    /// Timestep in seconds
+    /// Timestep in seconds.
     float timeStep_;
-    /// Timestep in milliseconds
+    /// Timestep in milliseconds.
     unsigned timeStepMSec_;
-    /// Total elapsed time in milliseconds
+    /// Total elapsed time in milliseconds.
     unsigned totalMSec_;
-    /// Low-resolution timer period
+    /// Low-resolution timer period.
     unsigned timerPeriod_;
 };
 
 
-/// Low-resolution operating system timer
+/// Low-resolution operating system timer.
 class Timer
 {
 public:
-    /// Construct. Get the starting clock value
+    /// Construct. Get the starting clock value.
     Timer();
     
-    /// Return elapsed milliseconds and optionally reset
+    /// Return elapsed milliseconds and optionally reset.
     unsigned GetMSec(bool reset);
-    /// Reset the timer
+    /// Reset the timer.
     void Reset();
     
 private:
-    /// Starting clock value in milliseconds
+    /// Starting clock value in milliseconds.
     unsigned startTime_;
 };
 
-/// High-resolution operating system timer used in profiling
+/// High-resolution operating system timer used in profiling.
 class HiresTimer
 {
     friend class Time;
     
 public:
-    /// Construct. Get the starting high-resolution clock value
+    /// Construct. Get the starting high-resolution clock value.
     HiresTimer();
     
-    /// Return elapsed microseconds and optionally reset
+    /// Return elapsed microseconds and optionally reset.
     long long GetUSec(bool reset);
-    /// Reset the timer
+    /// Reset the timer.
     void Reset();
     
-    /// Return if high-resolution timer is supported
+    /// Return if high-resolution timer is supported.
     static bool IsSupported() { return supported; }
-    /// Return high-resolution timer frequency if supported
+    /// Return high-resolution timer frequency if supported.
     static long long GetFrequency() { return frequency; }
     
 private:
-    /// Starting clock value in CPU ticks
+    /// Starting clock value in CPU ticks.
     long long startTime_;
     
-     /// High-resolution timer support flag
+     /// High-resolution timer support flag.
     static bool supported;
-    /// High-resolution timer frequency
+    /// High-resolution timer frequency.
     static long long frequency;
 };

+ 137 - 140
Engine/Core/Variant.h

@@ -29,7 +29,7 @@
 #include "StringHash.h"
 #include "Vector4.h"
 
-/// Supported variable types for Variant
+/// Supported variable types for Variant.
 enum VariantType
 {
     VAR_NONE = 0,
@@ -50,7 +50,7 @@ enum VariantType
     VAR_VARIANTMAP
 };
 
-/// Union for holding all the possible Variant values
+/// Union for holding all the possible Variant values.
 struct VariantValue
 {
     union
@@ -66,258 +66,256 @@ struct VariantValue
     float w_;
 };
 
-/// Typed resource reference
+/// Typed resource reference.
 struct ResourceRef
 {
-    /// Construct
+    /// Construct.
     ResourceRef()
     {
     }
     
-    /// Construct with type only and empty id
+    /// Construct with type only and empty id.
     ResourceRef(ShortStringHash type) :
         type_(type)
     {
     }
     
-    /// Construct with type and id
+    /// Construct with type and id.
     ResourceRef(ShortStringHash type, StringHash id) :
         type_(type),
         id_(id)
     {
     }
     
-    // Construct from another ResourceRef
+    // Construct from another ResourceRef.
     ResourceRef(const ResourceRef& rhs) :
         type_(rhs.type_),
         id_(rhs.id_)
     {
     }
     
-    /// Object type
+    /// Object type.
     ShortStringHash type_;
-    /// Object identifier, for example name hash
+    /// Object identifier, for example name hash.
     StringHash id_;
     
-    /// Test for equality with another reference
+    /// Test for equality with another reference.
     bool operator == (const ResourceRef& rhs) const { return type_ == rhs.type_ && id_ == rhs.id_; }
-    
-    /// Test for inequality with another reference
+    /// Test for inequality with another reference.
     bool operator != (const ResourceRef& rhs) const { return type_ != rhs.type_ || id_ != rhs.id_; }
 };
 
-/// List of resource references of a specific type
+/// List of resource references of a specific type.
 struct ResourceRefList
 {
-    /// Construct
+    /// Construct.
     ResourceRefList()
     {
     }
     
-    /// Construct with type only
+    /// Construct with type only.
     ResourceRefList(ShortStringHash type) :
         type_(type)
     {
     }
-    /// Construct with type and id list
+    /// Construct with type and id list.
     ResourceRefList(ShortStringHash type, const Vector<StringHash>& ids) :
         type_(type),
         ids_(ids)
     {
     }
     
-    /// Object type
+    /// Object type.
     ShortStringHash type_;
-    /// List of object identifiers, for example name hashes
+    /// List of object identifiers, for example name hashes.
     Vector<StringHash> ids_;
     
-    /// Test for equality with another reference list
+    /// Test for equality with another reference list.
     bool operator == (const ResourceRefList& rhs) const { return type_ == rhs.type_ && ids_ == rhs.ids_; }
-    
-    /// Test for inequality with another reference list
+    /// Test for inequality with another reference list.
     bool operator != (const ResourceRefList& rhs) const { return type_ != rhs.type_ || ids_ != rhs.ids_; }
 };
 
 class Variant;
 
-/// Vector of variants
+/// Vector of variants.
 typedef Vector<Variant> VariantVector;
-/// Map of variants
+/// Map of variants.
 typedef HashMap<ShortStringHash, Variant> VariantMap;
 
-/// Variable that supports a fixed set of types
+/// Variable that supports a fixed set of types.
 class Variant
 {
 public:
-    /// Construct with none value
+    /// Construct empty.
     Variant() :
         type_(VAR_NONE)
     {
     }
     
-    /// Construct from integer
+    /// Construct from integer.
     Variant(int value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from unsigned integer
+    /// Construct from unsigned integer.
     Variant(unsigned value) :
         type_(VAR_NONE)
     {
         *this = (int)value;
     }
     
-    /// Construct from a string hash (convert to integer)
+    /// Construct from a string hash (convert to integer.)
     Variant(const StringHash& value) :
         type_(VAR_NONE)
     {
         *this = (int)value.GetValue();
     }
     
-    /// Construct from a short string hash (convert to integer)
+    /// Construct from a short string hash (convert to integer.)
     Variant(const ShortStringHash& value) :
         type_(VAR_NONE)
     {
         *this = (int)value.GetValue();
     }
     
-    /// Construct from a bool
+    /// Construct from a bool.
     Variant(bool value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a float
+    /// Construct from a float.
     Variant(float value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a Vector2
+    /// Construct from a Vector2.
     Variant(const Vector2& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a Vector3
+    /// Construct from a Vector3.
     Variant(const Vector3& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a Vector4
+    /// Construct from a Vector4.
     Variant(const Vector4& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a Quaternion
+    /// Construct from a quaternion.
     Variant(const Quaternion& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a Color
+    /// Construct from a color.
     Variant(const Color& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a string
+    /// Construct from a string.
     Variant(const String& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a C string
+    /// Construct from a C string.
     Variant(const char* value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a buffer
+    /// Construct from a buffer.
     Variant(const PODVector<unsigned char>& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a pointer
+    /// Construct from a pointer.
     Variant(void* value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from an object reference
+    /// Construct from a resource reference.
     Variant(const ResourceRef& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from an object reference list
+    /// Construct from a resource reference list.
     Variant(const ResourceRefList& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a variant vector
+    /// Construct from a variant vector.
     Variant(const VariantVector& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from a variant map
+    /// Construct from a variant map.
     Variant(const VariantMap& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Construct from type and value
+    /// Construct from type and value.
     Variant(const String& type, const String& value) :
         type_(VAR_NONE)
     {
         FromString(type, value);
     }
     
-    /// Copy-construct from another variant
+    /// Copy-construct from another variant.
     Variant(const Variant& value) :
         type_(VAR_NONE)
     {
         *this = value;
     }
     
-    /// Destruct
+    /// Destruct.
     ~Variant()
     {
         SetType(VAR_NONE);
     }
     
-    /// Reset to none type
+    /// Reset to empty.
     void Clear()
     {
         SetType(VAR_NONE);
     }
     
-    /// Assign from another variant
+    /// Assign from another variant.
     Variant& operator = (const Variant& rhs);
     
-    /// Assign from an integer
+    /// Assign from an integer.
     Variant& operator = (int rhs)
     {
         SetType(VAR_INT);
@@ -325,7 +323,7 @@ public:
         return *this;
     }
     
-    /// Assign from an unsigned integer
+    /// Assign from an unsigned integer.
     Variant& operator = (unsigned rhs)
     {
         SetType(VAR_INT);
@@ -333,7 +331,7 @@ public:
         return *this;
     }
     
-    /// Assign from a StringHash (convert to integer)
+    /// Assign from a StringHash (convert to integer.)
     Variant& operator = (const StringHash& rhs)
     {
         SetType(VAR_INT);
@@ -349,7 +347,7 @@ public:
         return *this;
     }
     
-    /// Assign from a bool
+    /// Assign from a bool.
     Variant& operator = (bool rhs)
     {
         SetType(VAR_BOOL);
@@ -357,7 +355,7 @@ public:
         return *this;
     }
     
-    /// Assign from a float
+    /// Assign from a float.
     Variant& operator = (float rhs)
     {
         SetType(VAR_FLOAT);
@@ -365,7 +363,7 @@ public:
         return *this;
     }
     
-    /// Assign from a Vector2
+    /// Assign from a Vector2.
     Variant& operator = (const Vector2& rhs)
     {
         SetType(VAR_VECTOR2);
@@ -373,7 +371,7 @@ public:
         return *this;
     }
     
-    /// Assign from a Vector3
+    /// Assign from a Vector3.
     Variant& operator = (const Vector3& rhs)
     {
         SetType(VAR_VECTOR3);
@@ -381,7 +379,7 @@ public:
         return *this;
     }
     
-    /// Assign from a Vector4
+    /// Assign from a Vector4.
     Variant& operator = (const Vector4& rhs)
     {
         SetType(VAR_VECTOR4);
@@ -389,7 +387,7 @@ public:
         return *this;
     }
     
-    /// Assign from a Quaternion
+    /// Assign from a quaternion.
     Variant& operator = (const Quaternion& rhs)
     {
         SetType(VAR_QUATERNION);
@@ -397,7 +395,7 @@ public:
         return *this;
     }
     
-    /// Assign from a Color
+    /// Assign from a color.
     Variant& operator = (const Color& rhs)
     {
         SetType(VAR_COLOR);
@@ -405,7 +403,7 @@ public:
         return *this;
     }
     
-    /// Assign from a string
+    /// Assign from a string.
     Variant& operator = (const String& rhs)
     {
         SetType(VAR_STRING);
@@ -413,7 +411,7 @@ public:
         return *this;
     }
     
-    /// Assign from a C string
+    /// Assign from a C string.
     Variant& operator = (const char* rhs)
     {
         SetType(VAR_STRING);
@@ -421,7 +419,7 @@ public:
         return *this;
     }
 
-    /// Assign from a buffer
+    /// Assign from a buffer.
     Variant& operator = (const PODVector<unsigned char>& rhs)
     {
         SetType(VAR_BUFFER);
@@ -429,7 +427,7 @@ public:
         return *this;
     }
     
-    /// Assign from a pointer
+    /// Assign from a pointer.
     Variant& operator = (void* rhs)
     {
         SetType(VAR_PTR);
@@ -437,7 +435,7 @@ public:
         return *this;
     }
     
-    /// Assign from an object reference
+    /// Assign from a resource reference.
     Variant& operator = (const ResourceRef& rhs)
     {
         SetType(VAR_RESOURCEREF);
@@ -445,7 +443,7 @@ public:
         return *this;
     }
     
-    /// Assign from an object reference list
+    /// Assign from a resource reference list.
     Variant& operator = (const ResourceRefList& rhs)
     {
         SetType(VAR_RESOURCEREFLIST);
@@ -453,7 +451,7 @@ public:
         return *this;
     }
     
-    /// Assign from a variant vector
+    /// Assign from a variant vector.
     Variant& operator = (const VariantVector& rhs)
     {
         SetType(VAR_VARIANTVECTOR);
@@ -461,7 +459,7 @@ public:
         return *this;
     }
     
-    /// Assign from a variant map
+    /// Assign from a variant map.
     Variant& operator = (const VariantMap& rhs)
     {
         SetType(VAR_VARIANTMAP);
@@ -469,13 +467,12 @@ public:
         return *this;
     }
     
-    /// Test for equality with another variant
+    /// Test for equality with another variant.
     bool operator == (const Variant& rhs) const;
-    
-    /// Test for inequality with another variant
+    /// Test for inequality with another variant.
     bool operator != (const Variant& rhs) const { return !(*this == rhs); }
     
-    /// Test for equality with an integer. To return true, both the type and value must match
+    /// Test for equality with an integer. To return true, both the type and value must match.
     bool operator == (int rhs) const
     {
         if (type_ == VAR_INT)
@@ -484,7 +481,7 @@ public:
             return false;
     }
     
-    /// Test for equality with an unsigned integer. To return true, both the type and value must match
+    /// Test for equality with an unsigned integer. To return true, both the type and value must match.
     bool operator == (unsigned rhs) const
     {
         if (type_ == VAR_INT)
@@ -493,7 +490,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a bool. To return true, both the type and value must match
+    /// Test for equality with a bool. To return true, both the type and value must match.
     bool operator == (bool rhs) const
     {
         if (type_ == VAR_BOOL)
@@ -502,7 +499,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a float. To return true, both the type and value must match
+    /// Test for equality with a float. To return true, both the type and value must match.
     bool operator == (float rhs) const
     {
         if (type_ == VAR_FLOAT)
@@ -511,7 +508,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a Vector2. To return true, both the type and value must match
+    /// Test for equality with a Vector2. To return true, both the type and value must match.
     bool operator == (const Vector2& rhs) const
     {
         if (type_ == VAR_VECTOR2)
@@ -520,7 +517,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a Vector3. To return true, both the type and value must match
+    /// Test for equality with a Vector3. To return true, both the type and value must match.
     bool operator == (const Vector3& rhs) const
     {
         if (type_ == VAR_VECTOR3)
@@ -529,7 +526,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a Vector4. To return true, both the type and value must match
+    /// Test for equality with a Vector4. To return true, both the type and value must match.
     bool operator == (const Vector4& rhs) const
     {
         if (type_ == VAR_VECTOR4)
@@ -538,7 +535,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a Quaternion. To return true, both the type and value must match
+    /// Test for equality with a quaternion. To return true, both the type and value must match.
     bool operator == (const Quaternion& rhs) const
     {
         if (type_ == VAR_QUATERNION)
@@ -547,7 +544,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a Color. To return true, both the type and value must match
+    /// Test for equality with a color. To return true, both the type and value must match.
     bool operator == (const Color& rhs) const
     {
         if (type_ == VAR_COLOR)
@@ -556,7 +553,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a string. To return true, both the type and value must match
+    /// Test for equality with a string. To return true, both the type and value must match.
     bool operator == (const String& rhs) const
     {
         if (type_ == VAR_STRING)
@@ -565,7 +562,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a buffer. To return true, both the type and value must match
+    /// Test for equality with a buffer. To return true, both the type and value must match.
     bool operator == (const PODVector<unsigned char>& rhs) const
     {
         if (type_ == VAR_BUFFER)
@@ -574,7 +571,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a pointer. To return true, both the type and value must match
+    /// Test for equality with a pointer. To return true, both the type and value must match.
     bool operator == (void* rhs) const
     {
         if (type_ == VAR_PTR)
@@ -583,7 +580,7 @@ public:
             return false;
     }
     
-    /// Test for equality with an object reference. To return true, both the type and value must match
+    /// Test for equality with a resource reference. To return true, both the type and value must match.
     bool operator == (const ResourceRef& rhs) const
     {
         if (type_ == VAR_RESOURCEREF)
@@ -592,7 +589,7 @@ public:
             return false;
     }
     
-    /// Test for equality with an object reference list. To return true, both the type and value must match
+    /// Test for equality with a resource reference list. To return true, both the type and value must match.
     bool operator == (const ResourceRefList& rhs) const
     {
         if (type_ == VAR_RESOURCEREFLIST)
@@ -601,7 +598,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a variant vector. To return true, both the type and value must match
+    /// Test for equality with a variant vector. To return true, both the type and value must match.
     bool operator == (const VariantVector& rhs) const
     {
         if (type_ == VAR_VARIANTVECTOR)
@@ -610,7 +607,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a variant map. To return true, both the type and value must match
+    /// Test for equality with a variant map. To return true, both the type and value must match.
     bool operator == (const VariantMap& rhs) const
     {
         if (type_ == VAR_VARIANTMAP)
@@ -619,7 +616,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a StringHash. To return true, both the type and value must match
+    /// Test for equality with a StringHash. To return true, both the type and value must match.
     bool operator == (const StringHash& rhs) const
     {
         if (type_ == VAR_INT)
@@ -628,7 +625,7 @@ public:
             return false;
     }
     
-    /// Test for equality with a ShortStringHash. To return true, both the type and value must match
+    /// Test for equality with a ShortStringHash. To return true, both the type and value must match.
     bool operator == (const ShortStringHash& rhs) const
     {
         if (type_ == VAR_INT)
@@ -637,47 +634,47 @@ public:
             return false;
     }
     
-    /// Test for inequality with an integer
+    /// Test for inequality with an integer.
     bool operator != (int rhs) const { return !(*this == rhs); }
-    /// Test for inequality with an unsigned integer
+    /// Test for inequality with an unsigned integer.
     bool operator != (unsigned rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a bool
+    /// Test for inequality with a bool.
     bool operator != (bool rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a float
+    /// Test for inequality with a float.
     bool operator != (float rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a Vector2
+    /// Test for inequality with a Vector2.
     bool operator != (const Vector2& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a Vector3
+    /// Test for inequality with a Vector3.
     bool operator != (const Vector3& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with an Vector4
+    /// Test for inequality with an Vector4.
     bool operator != (const Vector4& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a Quaternion
+    /// Test for inequality with a Quaternion.
     bool operator != (const Quaternion& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a string
+    /// Test for inequality with a string.
     bool operator != (const String& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a buffer
+    /// Test for inequality with a buffer.
     bool operator != (const PODVector<unsigned char>& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a pointer
+    /// Test for inequality with a pointer.
     bool operator != (void* rhs) const { return !(*this == rhs); }
-    /// Test for inequality with an object reference
+    /// Test for inequality with a resource reference.
     bool operator != (const ResourceRef& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with an object reference list
+    /// Test for inequality with a resource reference list.
     bool operator != (const ResourceRefList& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a variant vector
+    /// Test for inequality with a variant vector.
     bool operator != (const VariantVector& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a variant map
+    /// Test for inequality with a variant map.
     bool operator != (const VariantMap& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a StringHash
+    /// Test for inequality with a StringHash.
     bool operator != (const StringHash& rhs) const { return !(*this == rhs); }
-    /// Test for inequality with a ShortStringHash
+    /// Test for inequality with a ShortStringHash.
     bool operator != (const ShortStringHash& rhs) const { return !(*this == rhs); }
     
-    /// %Set from type and value strings. Pointers will be set to null, and VariantBuffer or VariantMap types are not supported
+    /// %Set from type and value strings. Pointers will be set to null, and VariantBuffer or VariantMap types are not supported.
     void FromString(const String& type, const String& value);
-    /// %Set buffer type from a memory area
+    /// %Set buffer type from a memory area.
     void SetBuffer(const void* data, unsigned size);
     
-    /// Return int or zero on type mismatch
+    /// Return int or zero on type mismatch.
     int GetInt() const
     {
         if (type_ != VAR_INT)
@@ -685,7 +682,7 @@ public:
         return value_.int_;
     }
     
-    /// Return unsigned int or zero on type mismatch
+    /// Return unsigned int or zero on type mismatch.
     int GetUInt() const
     {
         if (type_ != VAR_INT)
@@ -693,7 +690,7 @@ public:
         return (unsigned)value_.int_;
     }
     
-    /// Return StringHash or zero on type mismatch
+    /// Return StringHash or zero on type mismatch.
     StringHash GetStringHash() const
     {
         if (type_ != VAR_INT)
@@ -701,7 +698,7 @@ public:
         return StringHash(value_.int_);
     }
     
-    /// Return ShortStringHash or zero on type mismatch
+    /// Return ShortStringHash or zero on type mismatch.
     ShortStringHash GetShortStringHash() const
     {
         if (type_ != VAR_INT)
@@ -709,7 +706,7 @@ public:
         return ShortStringHash(value_.int_);
     }
     
-    /// Return bool or false on type mismatch
+    /// Return bool or false on type mismatch.
     bool GetBool() const
     {
         if (type_ != VAR_BOOL)
@@ -717,7 +714,7 @@ public:
         return value_.bool_;
     }
     
-    /// Return float or zero on type mismatch
+    /// Return float or zero on type mismatch.
     float GetFloat() const
     {
         if (type_ != VAR_FLOAT)
@@ -725,7 +722,7 @@ public:
         return value_.float_;
     }
     
-    /// Return Vector2 or zero on type mismatch
+    /// Return Vector2 or zero on type mismatch.
     const Vector2& GetVector2() const
     {
         if (type_ != VAR_VECTOR2)
@@ -733,7 +730,7 @@ public:
         return *reinterpret_cast<const Vector2*>(&value_);
     }
     
-    /// Return Vector3 or zero on type mismatch
+    /// Return Vector3 or zero on type mismatch.
     const Vector3& GetVector3() const
     {
         if (type_ != VAR_VECTOR3)
@@ -741,7 +738,7 @@ public:
         return *reinterpret_cast<const Vector3*>(&value_);
     }
     
-    /// Return Vector4 or zero on type mismatch
+    /// Return Vector4 or zero on type mismatch.
     const Vector4& GetVector4() const
     {
         if (type_ != VAR_VECTOR4)
@@ -749,7 +746,7 @@ public:
         return *reinterpret_cast<const Vector4*>(&value_);
     }
     
-    /// Return Quaternion or identity on type mismatch
+    /// Return quaternion or identity on type mismatch.
     const Quaternion& GetQuaternion() const
     {
         if (type_ != VAR_QUATERNION)
@@ -757,7 +754,7 @@ public:
         return *reinterpret_cast<const Quaternion*>(&value_);
     }
     
-    /// Return Color or default on type mismatch
+    /// Return color or default on type mismatch.
     const Color& GetColor() const
     {
         if (type_ != VAR_COLOR)
@@ -765,7 +762,7 @@ public:
         return *reinterpret_cast<const Color*>(&value_);
     }
     
-    /// Return string or empty on type mismatch
+    /// Return string or empty on type mismatch.
     const String& GetString() const
     {
         if (type_ != VAR_STRING)
@@ -773,7 +770,7 @@ public:
         return *reinterpret_cast<const String*>(value_.ptr_);
     }
     
-    /// Return buffer or empty on type mismatch
+    /// Return buffer or empty on type mismatch.
     const PODVector<unsigned char>& GetBuffer() const
     {
         if (type_ != VAR_BUFFER)
@@ -781,7 +778,7 @@ public:
         return *reinterpret_cast<const PODVector<unsigned char>*>(value_.ptr_);
     }
     
-    /// Return pointer or null on type mismatch
+    /// Return pointer or null on type mismatch.
     void* GetPtr() const
     {
         if (type_ != VAR_PTR)
@@ -789,7 +786,7 @@ public:
         return value_.ptr_;
     }
     
-    /// Return ResourceRef or empty on type mismatch
+    /// Return a resource reference or empty on type mismatch.
     const ResourceRef& GetResourceRef() const
     {
         if (type_ != VAR_RESOURCEREF)
@@ -797,7 +794,7 @@ public:
         return *reinterpret_cast<ResourceRef*>(value_.ptr_);
     }
     
-    /// Return ResourceRefList or empty on type mismatch
+    /// Return a resource reference list or empty on type mismatch.
     const ResourceRefList& GetResourceRefList() const
     {
         if (type_ != VAR_RESOURCEREFLIST)
@@ -805,7 +802,7 @@ public:
         return *reinterpret_cast<ResourceRefList*>(value_.ptr_);
     }
     
-    /// Return VariantVector or empty on type mismatch
+    /// Return a variant vector or empty on type mismatch.
     const VariantVector& GetVariantVector() const
     {
         if (type_ != VAR_VARIANTVECTOR)
@@ -813,7 +810,7 @@ public:
         return *reinterpret_cast<VariantVector*>(value_.ptr_);
     }
     
-    /// Return VariantMap or empty on type mismatch
+    /// Return a variant map or empty on type mismatch
     const VariantMap& GetVariantMap() const
     {
         if (type_ != VAR_VARIANTMAP)
@@ -821,40 +818,40 @@ public:
         return *reinterpret_cast<VariantMap*>(value_.ptr_);
     }
 
-    /// Return the value, template version
+    /// Return the value, template version.
     template <class T> T Get() const;
-    /// Return type
+    /// Return type.
     VariantType GetType() const { return type_; }
-    /// Return type name
+    /// Return type name.
     const String& GetTypeName() const;
-    /// Convert value to string. Pointers are returned as null, and VariantBuffer or VariantMap are not supported and return empty
+    /// Convert value to string. Pointers are returned as null, and VariantBuffer or VariantMap are not supported and return empty.
     String ToString() const;
     
-    /// Return type name for enum value
+    /// Return type name for enum value.
     static const String& GetTypeName(VariantType type);
     
-    /// Empty variant
+    /// Empty variant.
     static const Variant EMPTY;
     
 private:
-    /// %Set new type and allocate/deallocate memory as necessary
+    /// %Set new type and allocate/deallocate memory as necessary.
     void SetType(VariantType newType);
     
-    /// Variant type
+    /// Variant type.
     VariantType type_;
-    /// Variant value
+    /// Variant value.
     VariantValue value_;
     
-    /// Empty string
+    /// Empty string.
     static const String emptyString;
-    /// Empty buffer
+    /// Empty buffer.
     static const PODVector<unsigned char> emptyBuffer;
-    /// Empty object reference
+    /// Empty resource reference.
     static const ResourceRef emptyResourceRef;
-    /// Empty object reference list
+    /// Empty resource reference list.
     static const ResourceRefList emptyResourceRefList;
-    /// Empty variant map
+    /// Empty variant map.
     static const VariantMap emptyVariantMap;
-    /// Empty variant vector
+    /// Empty variant vector.
     static const VariantVector emptyVariantVector;
 };

+ 25 - 25
Engine/Engine/APITemplates.h

@@ -39,7 +39,7 @@
 #include <angelscript.h>
 #include <cstring>
 
-/// Template function for dynamic cast between two script classes
+/// Template function for dynamic cast between two script classes.
 template <class T, class U> U* RefCast(T* t)
 {
     if (!t)
@@ -48,7 +48,7 @@ template <class T, class U> U* RefCast(T* t)
     return dynamic_cast<U*>(t);
 }
 
-/// Template function for returning a Variant pointer type cast to specific class
+/// Template function for returning a Variant pointer type cast to specific class.
 template <class T> T* GetVariantPtr(Variant* ptr)
 {
     // An attempt at type safety. Probably can not guarantee that this could not be made to invoke UDB
@@ -60,7 +60,7 @@ template <class T> T* GetVariantPtr(Variant* ptr)
         return 0;
 }
 
-/// Template function for Vector to array conversion
+/// Template function for Vector to array conversion.
 template <class T> CScriptArray* VectorToArray(const Vector<T>& vector, const char* arrayName)
 {
     asIScriptContext *context = asGetActiveContext();
@@ -78,7 +78,7 @@ template <class T> CScriptArray* VectorToArray(const Vector<T>& vector, const ch
         return 0;
 }
 
-/// Template function for PODVector to array conversion
+/// Template function for PODVector to array conversion.
 template <class T> CScriptArray* VectorToArray(const PODVector<T>& vector, const char* arrayName)
 {
     asIScriptContext *context = asGetActiveContext();
@@ -96,7 +96,7 @@ template <class T> CScriptArray* VectorToArray(const PODVector<T>& vector, const
         return 0;
 }
 
-/// Template function for Vector to handle array conversion
+/// Template function for Vector to handle array conversion.
 template <class T> CScriptArray* VectorToHandleArray(const Vector<T*>& vector, const char* arrayName)
 {
     asIScriptContext *context = asGetActiveContext();
@@ -120,7 +120,7 @@ template <class T> CScriptArray* VectorToHandleArray(const Vector<T*>& vector, c
         return 0;
 }
 
-/// Template function for PODVector to handle array conversion
+/// Template function for PODVector to handle array conversion.
 template <class T> CScriptArray* VectorToHandleArray(const PODVector<T*>& vector, const char* arrayName)
 {
     asIScriptContext *context = asGetActiveContext();
@@ -144,7 +144,7 @@ template <class T> CScriptArray* VectorToHandleArray(const PODVector<T*>& vector
         return 0;
 }
 
-/// Template function for shared pointer Vector to handle array conversion
+/// Template function for shared pointer Vector to handle array conversion.
 template <class T> CScriptArray* SharedPtrVectorToHandleArray(const Vector<SharedPtr<T> >& vector, const char* arrayName)
 {
     asIScriptContext *context = asGetActiveContext();
@@ -168,7 +168,7 @@ template <class T> CScriptArray* SharedPtrVectorToHandleArray(const Vector<Share
         return 0;
 }
 
-/// Template function for Set to array conversion
+/// Template function for Set to array conversion.
 template <class T> CScriptArray* SetToArray(const Set<T>& set, const char* arrayName)
 {
     asIScriptContext *context = asGetActiveContext();
@@ -190,7 +190,7 @@ template <class T> CScriptArray* SetToArray(const Set<T>& set, const char* array
         return 0;
 }
 
-/// Template function for registering implicit casts between base and subclass
+/// Template function for registering implicit casts between base and subclass.
 template <class T, class U> void RegisterSubclass(asIScriptEngine* engine, const char* classNameT, const char* classNameU)
 {
     if (!strcmp(classNameT, classNameU))
@@ -203,7 +203,7 @@ template <class T, class U> void RegisterSubclass(asIScriptEngine* engine, const
     engine->RegisterObjectBehaviour(classNameU, asBEHAVE_IMPLICIT_REF_CAST, declReturnT.CString(), asFUNCTION((RefCast<U, T>)), asCALL_CDECL_OBJLAST);
 }
 
-/// Template function for registering a class derived from Serializer
+/// Template function for registering a class derived from Serializer.
 template <class T> void RegisterSerializer(asIScriptEngine* engine, const char* className)
 {
     engine->RegisterObjectMethod(className, "bool WriteInt(int)", asMETHODPR(T, WriteInt, (int), bool), asCALL_THISCALL);
@@ -235,7 +235,7 @@ template <class T> void RegisterSerializer(asIScriptEngine* engine, const char*
     engine->RegisterObjectMethod(className, "bool WriteLine(const String&in)", asMETHODPR(T, WriteLine, (const String&), bool), asCALL_THISCALL);
 }
 
-/// Template function for registering a class derived from Deserializer
+/// Template function for registering a class derived from Deserializer.
 template <class T> void RegisterDeserializer(asIScriptEngine* engine, const char* className)
 {
     engine->RegisterObjectMethod(className, "int ReadInt()", asMETHODPR(T, ReadInt, (), int), asCALL_THISCALL);
@@ -273,7 +273,7 @@ template <class T> void RegisterDeserializer(asIScriptEngine* engine, const char
     engine->RegisterObjectMethod(className, "bool get_eof() const", asMETHODPR(T, IsEof, () const, bool), asCALL_THISCALL);
 }
 
-/// Template function for registering a class derived from RefCounted
+/// Template function for registering a class derived from RefCounted.
 template <class T> void RegisterRefCounted(asIScriptEngine* engine, const char* className)
 {
     engine->RegisterObjectType(className, 0, asOBJ_REF);
@@ -281,7 +281,7 @@ template <class T> void RegisterRefCounted(asIScriptEngine* engine, const char*
     engine->RegisterObjectBehaviour(className, asBEHAVE_RELEASE, "void f()", asMETHODPR(T, ReleaseRef, (), void), asCALL_THISCALL);
 }
 
-/// Template function for registering a class derived from Object
+/// Template function for registering a class derived from Object.
 template <class T> void RegisterObject(asIScriptEngine* engine, const char* className)
 {
     engine->RegisterObjectType(className, 0, asOBJ_REF);
@@ -304,14 +304,14 @@ template <class T> T* ConstructNamedObject(const String& name)
     return object;
 }
 
-/// Template function for registering a default constructor for a class derived from Object
+/// Template function for registering a default constructor for a class derived from Object.
 template <class T> void RegisterObjectConstructor(asIScriptEngine* engine, const char* className)
 {
     String declFactory(String(className) + "@+ f()");
     engine->RegisterObjectBehaviour(className, asBEHAVE_FACTORY, declFactory.CString(), asFUNCTION(ConstructObject<T>), asCALL_CDECL);
 }
 
-/// Template function for registering a named constructor for a class derived from Object
+/// Template function for registering a named constructor for a class derived from Object.
 template <class T> void RegisterNamedObjectConstructor(asIScriptEngine* engine, const char* className)
 {
     String declFactoryWithName(String(className) + "@+ f(const String&in)");
@@ -348,7 +348,7 @@ static bool SerializableSave(File* file, Serializable* ptr)
         return false;
 }
 
-/// Template function for registering a class derived from Serializable
+/// Template function for registering a class derived from Serializable.
 template <class T> void RegisterSerializable(asIScriptEngine* engine, const char* className)
 {
     RegisterObject<T>(engine, className);
@@ -365,7 +365,7 @@ template <class T> void RegisterSerializable(asIScriptEngine* engine, const char
     RegisterSubclass<Object, T>(engine, "Serializable", className);
 }
 
-/// Template function for registering a class derived from Component
+/// Template function for registering a class derived from Component.
 template <class T> void RegisterComponent(asIScriptEngine* engine, const char* className, bool nodeRegistered = true)
 {
     RegisterSerializable<T>(engine, className);
@@ -482,7 +482,7 @@ static CScriptArray* NodeGetChildrenWithClassName(const String& className, bool
     return VectorToHandleArray<Node>(ret, "Array<Node@>");
 }
 
-/// Template function for registering a class derived from Node
+/// Template function for registering a class derived from Node.
 template <class T> void RegisterNode(asIScriptEngine* engine, const char* className)
 {
     RegisterSerializable<T>(engine, className);
@@ -563,7 +563,7 @@ static bool ResourceSave(File* file, XMLFile* ptr)
         return false;
 }
 
-/// Template function for registering a class derived from Resource
+/// Template function for registering a class derived from Resource.
 template <class T> void RegisterResource(asIScriptEngine* engine, const char* className)
 {
     RegisterObject<T>(engine, className);
@@ -592,7 +592,7 @@ static bool DrawableIsInView(Drawable* ptr)
     return ptr->IsInView(frame.frameNumber_);
 }
 
-/// Template function for registering a class derived from Drawable
+/// Template function for registering a class derived from Drawable.
 template <class T> void RegisterDrawable(asIScriptEngine* engine, const char* className)
 {
     RegisterComponent<T>(engine, className);
@@ -617,7 +617,7 @@ template <class T> void RegisterDrawable(asIScriptEngine* engine, const char* cl
     engine->RegisterObjectMethod(className, "const BoundingBox& get_worldBoundingBox()", asMETHOD(T, GetWorldBoundingBox), asCALL_THISCALL);
 }
 
-/// Template function for registering a class derived from SoundSource
+/// Template function for registering a class derived from SoundSource.
 template <class T> void RegisterSoundSource(asIScriptEngine* engine, const char* className)
 {
     RegisterComponent<T>(engine, className);
@@ -643,7 +643,7 @@ template <class T> void RegisterSoundSource(asIScriptEngine* engine, const char*
     engine->RegisterObjectMethod(className, "bool get_playing() const", asMETHOD(T, IsPlaying), asCALL_THISCALL);
 }
 
-/// Template function for registering a class derived from Texture
+/// Template function for registering a class derived from Texture.
 template <class T> void RegisterTexture(asIScriptEngine* engine, const char* className)
 {
     RegisterResource<T>(engine, className);
@@ -668,7 +668,7 @@ template <class T> void RegisterTexture(asIScriptEngine* engine, const char* cla
     engine->RegisterObjectMethod(className, "bool get_dataLost() const", asMETHOD(T, IsDataLost), asCALL_THISCALL);
 }
 
-/// Template function for registering a class derived from UIElement
+/// Template function for registering a class derived from UIElement.
 template <class T> void RegisterUIElement(asIScriptEngine* engine, const char* className)
 {
     RegisterObject<T>(engine, className);
@@ -774,7 +774,7 @@ template <class T> void RegisterUIElement(asIScriptEngine* engine, const char* c
     engine->RegisterObjectProperty(className, "VariantMap vars", offsetof(T, vars_));
 }
 
-/// Template function for registering a class derived from BorderImage
+/// Template function for registering a class derived from BorderImage.
 template <class T> void RegisterBorderImage(asIScriptEngine* engine, const char* className)
 {
     RegisterUIElement<T>(engine, className);
@@ -790,7 +790,7 @@ template <class T> void RegisterBorderImage(asIScriptEngine* engine, const char*
     engine->RegisterObjectMethod(className, "const IntVector2& get_hoverOffset() const", asMETHOD(T, GetHoverOffset), asCALL_THISCALL);
 }
 
-/// Template function for registering a class derived from Button
+/// Template function for registering a class derived from Button.
 template <class T> void RegisterButton(asIScriptEngine* engine, const char* className)
 {
     RegisterBorderImage<T>(engine, className);

+ 31 - 31
Engine/Engine/Console.h

@@ -33,75 +33,75 @@ class Text;
 class UIElement;
 class XMLFile;
 
-/// Console window with log history and AngelScript prompt
+/// Console window with log history and AngelScript prompt.
 class Console : public Object
 {
     OBJECT(Console);
     
 public:
-    /// Construct
+    /// Construct.
     Console(Context* context);
-    /// Destruct
+    /// Destruct.
     ~Console();
     
-    /// %Set UI elements' style from an XML file
+    /// %Set UI elements' style from an XML file.
     void SetStyle(XMLFile* style);
-    /// Show or hide. Showing automatically focuses the line edit
+    /// Show or hide. Showing automatically focuses the line edit.
     void SetVisible(bool enable);
-    /// Toggle visibility
+    /// Toggle visibility.
     void Toggle();
-    /// %Set number of displayed rows
+    /// %Set number of displayed rows.
     void SetNumRows(unsigned rows);
-    /// %Set command history maximum size, 0 disables history
+    /// %Set command history maximum size, 0 disables history.
     void SetNumHistoryRows(unsigned rows);
-    /// Update elements to layout properly. Call this after manually adjusting the sub-elements
+    /// Update elements to layout properly. Call this after manually adjusting the sub-elements.
     void UpdateElements();
     
-    /// Return the UI style file
+    /// Return the UI style file.
     XMLFile* GetStyle() const { return style_; }
-    /// Return the background element
+    /// Return the background element.
     BorderImage* GetBackground() const { return background_; }
-    /// Return the line edit element
+    /// Return the line edit element.
     LineEdit* GetLineEdit() const { return lineEdit_; }
-    /// Return whether is visible
+    /// Return whether is visible.
     bool IsVisible() const;
-    /// Return number of displayed rows
+    /// Return number of displayed rows.
     unsigned GetNumRows() const { return rows_.Size(); }
-    /// Return history maximum size
+    /// Return history maximum size.
     unsigned GetNumHistoryRows() const { return historyRows_; }
-    /// Return current history position
+    /// Return current history position.
     unsigned GetHistoryPosition() const { return historyPosition_; }
-    /// Return history row at index
+    /// Return history row at index.
     const String& GetHistoryRow(unsigned index) const;
     
 private:
-    /// Handle enter pressed on the line edit
+    /// Handle enter pressed on the line edit.
     void HandleTextFinished(StringHash eventType, VariantMap& eventData);
-    /// Handle unhandled key on the line edit for scrolling the history
+    /// Handle unhandled key on the line edit for scrolling the history.
     void HandleLineEditKey(StringHash eventType, VariantMap& eventData);
-    /// Handle rendering window resize
+    /// Handle rendering window resize.
     void HandleScreenMode(StringHash eventType, VariantMap& eventData);
-    /// Handle a log message
+    /// Handle a log message.
     void HandleLogMessage(StringHash eventType, VariantMap& eventData);
     
-    /// UI style file
+    /// UI style file.
     SharedPtr<XMLFile> style_;
-    /// Background
+    /// Background.
     SharedPtr<BorderImage> background_;
-    /// Container for text rows
+    /// Container for text rows.
     SharedPtr<UIElement> rowContainer_;
-    /// Text rows
+    /// Text rows.
     Vector<SharedPtr<Text> > rows_;
-    /// Line edit
+    /// Line edit.
     SharedPtr<LineEdit> lineEdit_;
-    /// Command history
+    /// Command history.
     Vector<String> history_;
-    /// Current row being edited
+    /// Current row being edited.
     String current_Row;
-    /// Command history maximum rows
+    /// Command history maximum rows.
     unsigned historyRows_;
-    /// Command history current position
+    /// Command history current position.
     unsigned historyPosition_;
-    /// Currently printing a log message -flag
+    /// Currently printing a log message flag.
     bool inLogMessage_;
 };

+ 18 - 0
Engine/Engine/CoreAPI.cpp

@@ -240,6 +240,16 @@ static void ConstructVariantString(const String& value, Variant* ptr)
     new(ptr) Variant(value);
 }
 
+static void ConstructVariantResourceRef(const ResourceRef& value, Variant* ptr)
+{
+    new(ptr) Variant(value);
+}
+
+static void ConstructVariantResourceRefList(const ResourceRefList& value, Variant* ptr)
+{
+    new(ptr) Variant(value);
+}
+
 void ArrayToVariantVector(CScriptArray* arr, VariantVector& dest)
 {
     unsigned numVariants = arr->GetSize();
@@ -371,6 +381,8 @@ static void RegisterVariant(asIScriptEngine* engine)
     engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(const Quaternion&in)", asFUNCTION(ConstructVariantQuaternion), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(const Color&in)", asFUNCTION(ConstructVariantColor), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(const String&in)", asFUNCTION(ConstructVariantString), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(const ResourceRef&in)", asFUNCTION(ConstructVariantResourceRef), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(const ResourceRefList&in)", asFUNCTION(ConstructVariantResourceRefList), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(const Array<Variant>@+)", asFUNCTION(ConstructVariantVariantVector), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Variant", asBEHAVE_CONSTRUCT, "void f(const VariantMap&in)", asFUNCTION(ConstructVariantVariantMap), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Variant", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructVariant), asCALL_CDECL_OBJLAST);
@@ -387,6 +399,8 @@ static void RegisterVariant(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Variant", "Variant& opAssign(const Quaternion&in)", asMETHODPR(Variant, operator =, (const Quaternion&), Variant&), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "Variant& opAssign(const Color&in)", asMETHODPR(Variant, operator =, (const Color&), Variant&), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "Variant& opAssign(const String&in)", asMETHODPR(Variant, operator =, (const String&), Variant&), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Variant", "Variant& opAssign(const ResourceRef&in)", asMETHODPR(Variant, operator =, (const ResourceRef&), Variant&), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Variant", "Variant& opAssign(const ResourceRefList&in)", asMETHODPR(Variant, operator =, (const ResourceRefList&), Variant&), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "Variant& opAssign(const Array<Variant>@+)", asFUNCTION(VariantAssignVariantVector), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Variant", "Variant& opAssign(const VariantMap&in)", asMETHODPR(Variant, operator =, (const VariantMap&), Variant&), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "bool opEquals(const Variant&in) const", asMETHODPR(Variant, operator ==, (const Variant&) const, bool), asCALL_THISCALL);
@@ -401,6 +415,8 @@ static void RegisterVariant(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Variant", "bool opEquals(const Quaternion&in) const", asMETHODPR(Variant, operator ==, (const Quaternion&) const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "bool opEquals(const Color&in) const", asMETHODPR(Variant, operator ==, (const Color&) const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "bool opEquals(const String&in) const", asMETHODPR(Variant, operator ==, (const String&) const, bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Variant", "bool opEquals(const ResourceRef&in) const", asMETHODPR(Variant, operator ==, (const ResourceRef&) const, bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Variant", "bool opEquals(const ResourceRefList&in) const", asMETHODPR(Variant, operator ==, (const ResourceRefList&) const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "bool opEquals(const Array<Variant>@+)", asFUNCTION(VariantEqualsVariantVector), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Variant", "bool opEquals(const VariantMap&in) const", asMETHODPR(Variant, operator ==, (const VariantMap&) const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "int GetInt() const", asMETHOD(Variant, GetInt), asCALL_THISCALL);
@@ -415,6 +431,8 @@ static void RegisterVariant(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Variant", "const Quaternion& GetQuaternion() const", asMETHOD(Variant, GetQuaternion), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "const Color& GetColor() const", asMETHOD(Variant, GetColor), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "const String& GetString() const", asMETHOD(Variant, GetString), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Variant", "const ResourceRef& GetResourceRef() const", asMETHOD(Variant, GetResourceRef), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Variant", "const ResourceRefList& GetResourceRefList() const", asMETHOD(Variant, GetResourceRefList), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "Array<Variant>@ GetVariantVector() const", asFUNCTION(VariantGetVariantVector), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Variant", "const VariantMap& GetVariantMap() const", asMETHOD(Variant, GetVariantMap), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "void FromString(const String&in, const String&in)", asMETHOD(Variant, FromString), asCALL_THISCALL);

+ 25 - 25
Engine/Engine/DebugHud.h

@@ -36,63 +36,63 @@ static const unsigned DEBUGHUD_SHOW_MODE = 0x2;
 static const unsigned DEBUGHUD_SHOW_PROFILER = 0x4;
 static const unsigned DEBUGHUD_SHOW_ALL = 0x7;
 
-/// Displays rendering stats and profiling information
+/// Displays rendering stats and profiling information.
 class DebugHud : public Object
 {
     OBJECT(DebugHud);
     
 public:
-    /// Construct
+    /// Construct.
     DebugHud(Context* context);
-    /// Destruct
+    /// Destruct.
     ~DebugHud();
     
-    /// Update. Called by HandleUpdate()
+    /// Update. Called by HandleUpdate().
     void Update(float timeStep);
-    /// %Set UI elements' style from an XML file
+    /// %Set UI elements' style from an XML file.
     void SetStyle(XMLFile* style);
-    /// %Set elements to show
+    /// %Set elements to show.
     void SetMode(unsigned mode);
-    /// %Set profiler accumulation interval
+    /// %Set profiler accumulation interval.
     void SetProfilerInterval(float interval);
-    /// %Set whether to show 3D geometry primitive/batch count only. Default false
+    /// %Set whether to show 3D geometry primitive/batch count only. Default false.
     void SetUseRendererStats(bool enable);
-    /// Toggle elements
+    /// Toggle elements.
     void Toggle(unsigned mode);
-    /// Toggle all elements
+    /// Toggle all elements.
     void ToggleAll();
     
-    /// Return the UI style file
+    /// Return the UI style file.
     XMLFile* GetStyle() const { return style_; }
-    /// Return rendering stats text
+    /// Return rendering stats text.
     Text* GetStatsText() const { return statsText_; }
-    /// Return rendering mode text
+    /// Return rendering mode text.
     Text* GetModeText() const { return modeText_; }
-    /// Return profiler text
+    /// Return profiler text.
     Text* GetProfilerText() const { return profilerText_; }
-    /// Return currently shown elements
+    /// Return currently shown elements.
     unsigned GetMode() const;
-    /// Return profiler accumulation interval
+    /// Return profiler accumulation interval.
     float GetProfilerInterval() const { return profilerInterval_; }
-    /// Return whether showing 3D geometry primitive/batch count only
+    /// Return whether showing 3D geometry primitive/batch count only.
     bool GetUseRendererStats() const { return useRendererStats_; }
     
 private:
-    /// Handle logic update event
+    /// Handle logic update event.
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
     
-    /// UI style file
+    /// UI style file.
     SharedPtr<XMLFile> style_;
-    /// Rendering stats text
+    /// Rendering stats text.
     SharedPtr<Text> statsText_;
-    /// Rendering mode text
+    /// Rendering mode text.
     SharedPtr<Text> modeText_;
-    /// Profiling information text
+    /// Profiling information text.
     SharedPtr<Text> profilerText_;
-    /// Profiler accumulation interval
+    /// Profiler accumulation interval.
     float profilerInterval_;
-    /// Profiler accumulation timer
+    /// Profiler accumulation timer.
     float profilerTimer_;
-    /// Show 3D geometry primitive/batch count flag
+    /// Show 3D geometry primitive/batch count flag.
     bool useRendererStats_;
 };

+ 32 - 32
Engine/Engine/Engine.h

@@ -29,79 +29,79 @@
 class Console;
 class DebugHud;
 
-/// Urho3D engine. Creates the other subsystems
+/// Urho3D engine. Creates the other subsystems.
 class Engine : public Object
 {
     OBJECT(Engine);
     
 public:
-    /// Construct
+    /// Construct.
     Engine(Context* context);
-    /// Destruct. Free all subsystems
+    /// Destruct. Free all subsystems.
     virtual ~Engine();
     
-    /// Initialize and show the application window. Return true if successful
+    /// Initialize and show the application window. Return true if successful.
     bool Initialize(const String& windowTitle = "Urho3D", const String& logName = "Urho3D.log", const Vector<String>&
         arguments = Vector<String>());
-    /// Initialize script subsystem and register the script API. Return true if successful (engine must be initialized first)
+    /// Initialize script subsystem and register the script API. Return true if successful (engine must be initialized first.)
     bool InitializeScripting();
-    /// Run one frame
+    /// Run one frame.
     void RunFrame();
-    /// Create the console and return it. May return null if engine configuration does not allow creation (headless mode)
+    /// Create the console and return it. May return null if engine configuration does not allow creation (headless mode.)
     Console* CreateConsole();
-    /// Create the debug hud
+    /// Create the debug hud.
     DebugHud* CreateDebugHud();
-    /// %Set minimum frames per second. If FPS goes lower than this, time will appear to slow down
+    /// %Set minimum frames per second. If FPS goes lower than this, time will appear to slow down.
     void SetMinFps(int fps);
-    /// %Set maximum frames per second. The engine will sleep if FPS is higher than this
+    /// %Set maximum frames per second. The engine will sleep if FPS is higher than this.
     void SetMaxFps(int fps);
-    /// %Set maximum frames per second when the application is inactive
+    /// %Set maximum frames per second when the application is inactive.
     void SetMaxInactiveFps(int fps);
-    /// Close the application window and set the exit flag
+    /// Close the application window and set the exit flag.
     void Exit();
-    /// Dump profiling information to the log
+    /// Dump profiling information to the log.
     void DumpProfilingData();
-    /// Dump information of all resources to the log
+    /// Dump information of all resources to the log.
     void DumpResources();
     
-    /// Return the minimum frames per second
+    /// Return the minimum frames per second.
     int GetMinFps() const { return minFps_; }
-    /// Return the maximum frames per second
+    /// Return the maximum frames per second.
     int GetMaxFps() const { return maxFps_; }
-    /// Return the maximum frames per second when the application is inactive
+    /// Return the maximum frames per second when the application is inactive.
     int GetMaxInactiveFps() const { return maxInactiveFps_; }
-    /// Return whether engine has been initialized
+    /// Return whether engine has been initialized.
     bool IsInitialized() const { return initialized_; }
-    /// Return whether exit has been requested
+    /// Return whether exit has been requested.
     bool IsExiting() const { return exiting_; }
-    /// Return whether the engine has been created in headless mode
+    /// Return whether the engine has been created in headless mode.
     bool IsHeadless() const { return headless_; }
     
-    /// Render after frame update
+    /// Render after frame update.
     void Render();
-    /// Get the timestep for the next frame and sleep for frame limiting if necessary
+    /// Get the timestep for the next frame and sleep for frame limiting if necessary.
     void ApplyFrameLimit();
     
 private:
-    /// Register object factories and attributes
+    /// Register object factories and attributes.
     void RegisterObjects();
-    /// Create and register subsystems. In headless mode graphics, input & UI are not created
+    /// Create and register subsystems. In headless mode graphics, input & UI are not created.
     void RegisterSubsystems();
     
-    /// Frame update timer
+    /// Frame update timer.
     Timer frameTimer_;
-    /// Next frame timestep in milliseconds
+    /// Next frame timestep in milliseconds.
     unsigned timeStep_;
-    /// Minimum frames per second
+    /// Minimum frames per second.
     unsigned minFps_;
-    /// Maximum frames per second
+    /// Maximum frames per second.
     unsigned maxFps_;
-    /// Maximum frames per second when the application is inactive
+    /// Maximum frames per second when the application is inactive.
     unsigned maxInactiveFps_;
-    /// Initialized flag
+    /// Initialized flag.
     bool initialized_;
-    /// Exiting flag
+    /// Exiting flag.
     bool exiting_;
-    /// Headless mode flag
+    /// Headless mode flag.
     bool headless_;
 };

+ 5 - 1
Engine/Engine/SceneAPI.cpp

@@ -89,7 +89,6 @@ static void RegisterScene(asIScriptEngine* engine)
     RegisterNode<Scene>(engine, "Scene");
     RegisterObjectConstructor<Scene>(engine, "Scene");
     RegisterNamedObjectConstructor<Scene>(engine, "Scene");
-    engine->RegisterObjectMethod("Scene", "void Update(float)", asMETHOD(Scene, Update), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "bool LoadXML(File@+)", asFUNCTION(SceneLoadXML), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Scene", "bool SaveXML(File@+)", asFUNCTION(SceneSaveXML), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Scene", "bool LoadAsync(File@+)", asMETHOD(Scene, LoadAsync), asCALL_THISCALL);
@@ -98,8 +97,13 @@ static void RegisterScene(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Scene", "void Clear()", asMETHOD(Scene, Clear), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "void AddRequiredPackageFile(PackageFile@+)", asMETHOD(Scene, AddRequiredPackageFile), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "void ClearRequiredPackageFiles()", asMETHOD(Scene, ClearRequiredPackageFiles), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Scene", "void RegisterVar(const String&in)", asMETHOD(Scene, RegisterVar), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Scene", "void UnregisterVar(const String&in)", asMETHOD(Scene, UnregisterVar), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Scene", "void UnregisterAllVars(const String&in)", asMETHOD(Scene, UnregisterAllVars), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "Component@+ GetComponentByID(uint)", asMETHOD(Scene, GetComponentByID), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "Node@+ GetNodeByID(uint)", asMETHOD(Scene, GetNodeByID), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Scene", "const String& GetVarName(ShortStringHash) const", asMETHOD(Scene, GetVarName), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Scene", "void Update(float)", asMETHOD(Scene, Update), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "void set_active(bool)", asMETHOD(Scene, SetActive), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "bool get_active() const", asMETHOD(Scene, IsActive), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "void set_smoothingConstant(float)", asMETHOD(Scene, SetSmoothingConstant), asCALL_THISCALL);

+ 13 - 13
Engine/Engine/ScriptAPI.h

@@ -26,29 +26,29 @@
 class Context;
 class asIScriptEngine;
 
-/// Register the Math library to script
+/// Register the Math library to script.
 void RegisterMathAPI(asIScriptEngine* engine);
-/// Register the Core library to script
+/// Register the Core library to script.
 void RegisterCoreAPI(asIScriptEngine* engine);
-/// Register the IO library to script
+/// Register the IO library to script.
 void RegisterIOAPI(asIScriptEngine* engine);
-/// Register the Resource library to script
+/// Register the Resource library to script.
 void RegisterResourceAPI(asIScriptEngine* engine);
-/// Register the Scene library to script
+/// Register the Scene library to script.
 void RegisterSceneAPI(asIScriptEngine* engine);
-/// Register the Graphics library to script
+/// Register the Graphics library to script.
 void RegisterGraphicsAPI(asIScriptEngine* engine);
-/// Register the Input library to script
+/// Register the Input library to script.
 void RegisterInputAPI(asIScriptEngine* engine);
-/// Register the Audio library to script
+/// Register the Audio library to script.
 void RegisterAudioAPI(asIScriptEngine* engine);
-/// Register the UI library to script
+/// Register the UI library to script.
 void RegisterUIAPI(asIScriptEngine* engine);
-/// Register the Network library to script
+/// Register the Network library to script.
 void RegisterNetworkAPI(asIScriptEngine* engine);
-/// Register the Physics library to script
+/// Register the Physics library to script.
 void RegisterPhysicsAPI(asIScriptEngine* engine);
-/// Register the Script library to script
+/// Register the Script library to script.
 void RegisterScriptAPI(asIScriptEngine* engine);
-/// Register the Engine library to script
+/// Register the Engine library to script.
 void RegisterEngineAPI(asIScriptEngine* engine);

+ 80 - 80
Engine/Graphics/AnimatedModel.h

@@ -31,7 +31,7 @@ class Animation;
 class AnimationState;
 class DebugRenderer;
 
-/// Animated model component
+/// Animated model component.
 class AnimatedModel : public StaticModel
 {
     OBJECT(AnimatedModel);
@@ -39,171 +39,171 @@ class AnimatedModel : public StaticModel
     friend class AnimationState;
     
 public:
-    /// Construct
+    /// Construct.
     AnimatedModel(Context* context);
-    /// Destruct. Free the animation states
+    /// Destruct.
     virtual ~AnimatedModel();
-    /// Register object factory. Drawable must be registered first
+    /// Register object factory. Drawable must be registered first.
     static void RegisterObject(Context* context);
     
-    /// Perform finalization after a scene load or network update
+    /// Perform finalization after a scene load or network update.
     virtual void FinishUpdate();
-    /// Process renderer raycast
+    /// Process renderer raycast.
     virtual void ProcessRayQuery(RayOctreeQuery& query, float initialDistance);
-    /// Update before octree reinsertion. Animation is updated here
+    /// Update before octree reinsertion. Animation is updated here.
     virtual void Update(const FrameInfo& frame);
-    /// Calculate distance for rendering
+    /// Calculate distance for rendering.
     virtual void UpdateDistance(const FrameInfo& frame);
-    /// Prepare geometry for rendering
+    /// Prepare geometry for rendering.
     virtual void UpdateGeometry(const FrameInfo& frame);
-    /// Return rendering batch
+    /// Return rendering batch.
     virtual void GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch);
-    /// Add debug geometry to the debug graphics
+    /// Add debug geometry to the debug graphics.
     virtual void DrawDebugGeometry(DebugRenderer* debug, bool depthTest);
     
-    /// %Set model
+    /// %Set model.
     void SetModel(Model* model, bool createBones = true);
-    /// Add an animation
+    /// Add an animation.
     AnimationState* AddAnimationState(Animation* animation);
-    /// Remove an animation by animation pointer
+    /// Remove an animation by animation pointer.
     void RemoveAnimationState(Animation* animation);
-    /// Remove an animation by animation name
+    /// Remove an animation by animation name.
     void RemoveAnimationState(const String& animationName);
-    /// Remove an animation by animation name hash
+    /// Remove an animation by animation name hash.
     void RemoveAnimationState(StringHash animationNameHash);
-    /// Remove an animation by AnimationState pointer
+    /// Remove an animation by AnimationState pointer.
     void RemoveAnimationState(AnimationState* state);
-    /// Remove all animations
+    /// Remove all animations.
     void RemoveAllAnimationStates();
-    /// %Set animation LOD bias
+    /// %Set animation LOD bias.
     void SetAnimationLodBias(float bias);
-    /// %Set animation LOD distance factor when not visible (default 0 = do not update at all when invisible)
+    /// %Set animation LOD distance factor when not visible (default 0 = do not update at all when invisible.)
     void SetInvisibleLodFactor(float factor);
-    /// %Set vertex morph weight by index
+    /// %Set vertex morph weight by index.
     void SetMorphWeight(unsigned index, float weight);
-    /// %Set vertex morph weight by name
+    /// %Set vertex morph weight by name.
     void SetMorphWeight(const String& name, float weight);
-    /// %Set vertex morph weight by name hash
+    /// %Set vertex morph weight by name hash.
     void SetMorphWeight(StringHash nameHash, float weight);
-    /// Reset all vertex morphs to zero
+    /// Reset all vertex morphs to zero.
     void ResetMorphWeights();
     
-    /// Return skeleton
+    /// Return skeleton.
     Skeleton& GetSkeleton() { return skeleton_; }
-    /// Return all animation states
+    /// Return all animation states.
     const Vector<SharedPtr<AnimationState> >& GetAnimationStates() const { return animationStates_; }
-    /// Return number of animation states
+    /// Return number of animation states.
     unsigned GetNumAnimationStates() const { return animationStates_.Size(); }
-    /// Return animation state by animation pointer
+    /// Return animation state by animation pointer.
     AnimationState* GetAnimationState(Animation* animation) const;
-    /// Return animation state by animation name
+    /// Return animation state by animation name.
     AnimationState* GetAnimationState(const String& animationName) const;
-    /// Return animation state by animation name hash
+    /// Return animation state by animation name hash.
     AnimationState* GetAnimationState(const StringHash animationNameHash) const;
-    /// Return animation state by index
+    /// Return animation state by index.
     AnimationState* GetAnimationState(unsigned index) const;
-    /// Return animation LOD bias
+    /// Return animation LOD bias.
     float GetAnimationLodBias() const { return animationLodBias_; }
-    /// Return animation LOD distance factor when not visible
+    /// Return animation LOD distance factor when not visible.
     float GetInvisibleLodFactor() const { return invisibleLodFactor_; }
-    /// Return all vertex morphs
+    /// Return all vertex morphs.
     const Vector<ModelMorph>& GetMorphs() const { return morphs_; }
-    /// Return all morph vertex buffers
+    /// Return all morph vertex buffers.
     const Vector<SharedPtr<VertexBuffer> >& GetMorphVertexBuffers() const { return morphVertexBuffers_; }
-    /// Return number of vertex morphs
+    /// Return number of vertex morphs.
     unsigned GetNumMorphs() const { return morphs_.Size(); }
-    /// Return vertex morph weight by index
+    /// Return vertex morph weight by index.
     float GetMorphWeight(unsigned index) const;
-    /// Return vertex morph weight by name
+    /// Return vertex morph weight by name.
     float GetMorphWeight(const String& name) const;
-    /// Return vertex morph weight by name hash
+    /// Return vertex morph weight by name hash.
     float GetMorphWeight(StringHash nameHash) const;
-    /// Return whether is the master (first) animated model
+    /// Return whether is the master (first) animated model.
     bool IsMaster() const { return isMaster_; }
     
-    /// %Set model attribute
+    /// %Set model attribute.
     void SetModelAttr(ResourceRef value);
-    /// %Set bones' animation enabled attribute
+    /// %Set bones' animation enabled attribute.
     void SetBonesEnabledAttr(PODVector<unsigned char> value);
-    /// %Set animation states attribute
+    /// %Set animation states attribute.
     void SetAnimationStatesAttr(PODVector<unsigned char> value);
-    /// Return model attribute
+    /// Return model attribute.
     ResourceRef GetModelAttr() const;
-    /// Return bones' animation enabled attribute
+    /// Return bones' animation enabled attribute.
     PODVector<unsigned char> GetBonesEnabledAttr() const;
-    /// Return animation states attribute
+    /// Return animation states attribute.
     PODVector<unsigned char> GetAnimationStatesAttr() const;
     
 protected:
-    /// Handle node being assigned
+    /// Handle node being assigned.
     virtual void OnNodeSet(Node* node);
-    /// Handle node transform being dirtied
+    /// Handle node transform being dirtied.
     virtual void OnMarkedDirty(Node* node);
-    /// Update world-space bounding box
+    /// Update world-space bounding box.
     virtual void OnWorldBoundingBoxUpdate();
     
 private:
-    /// Assign skeleton and animation bone node references as a postprocess. Called by FinishUpdate
+    /// Assign skeleton and animation bone node references as a postprocess. Called by FinishUpdate.
     void AssignBoneNodes();
-    /// Mark animation and skinning to require an update
+    /// Mark animation and skinning to require an update.
     void MarkAnimationDirty();
-    /// Mark animation and skinning to require a forced update (blending order changed)
+    /// Mark animation and skinning to require a forced update (blending order changed.)
     void MarkAnimationOrderDirty();
-    /// Mark morphs to require an update
+    /// Mark morphs to require an update.
     void MarkMorphsDirty();
-    /// %Set skeleton
+    /// %Set skeleton.
     void SetSkeleton(const Skeleton& skeleton, bool createBones);
-    /// Refresh mapping of subgeometry bone indices
+    /// Refresh mapping of subgeometry bone indices.
     void RefreshGeometryBoneMappings();
-    /// Clone geometries as required
+    /// Clone geometries as required.
     void cloneGeometries();
-    /// Recalculate animations. Called from updateNode()
+    /// Recalculate animations. Called from UpdateNode().
     void UpdateAnimation(const FrameInfo& frame);
-    /// Recalculate skinning
+    /// Recalculate skinning.
     void UpdateSkinning();
-    /// Reapply all vertex morphs
+    /// Reapply all vertex morphs.
     void UpdateMorphs();
-    /// Apply a vertex morph
+    /// Apply a vertex morph.
     void ApplyMorph(VertexBuffer* buffer, void* lockedMorphRange, const VertexBufferMorph& morph, float weight);
-    /// Handle model reload finished
+    /// Handle model reload finished.
     void HandleModelReloadFinished(StringHash eventType, VariantMap& eventData);
     
-    /// Skeleton
+    /// Skeleton.
     Skeleton skeleton_;
-    /// Morph vertex buffers
+    /// Morph vertex buffers.
     Vector<SharedPtr<VertexBuffer> > morphVertexBuffers_;
-    /// Vertex morphs
+    /// Vertex morphs.
     Vector<ModelMorph> morphs_;
-    /// Animation states
+    /// Animation states.
     Vector<SharedPtr<AnimationState> > animationStates_;
-    /// Skinning matrices
+    /// Skinning matrices.
     PODVector<Matrix3x4> skinMatrices_;
-    /// Mapping of subgeometry bone indices, used if more bones than skinning shader can manage
+    /// Mapping of subgeometry bone indices, used if more bones than skinning shader can manage.
     Vector<PODVector<unsigned> > geometryBoneMappings_;
-    /// Subgeometry skinning matrices, used if more bones than skinning shader can manage
+    /// Subgeometry skinning matrices, used if more bones than skinning shader can manage.
     Vector<PODVector<Matrix3x4> > geometrySkinMatrices_;
-    /// Subgeometry skinning matrix pointers, if more bones than skinning shader can manage
+    /// Subgeometry skinning matrix pointers, if more bones than skinning shader can manage.
     Vector<PODVector<Matrix3x4*> > geometrySkinMatrixPtrs_;
-    /// The frame number animation LOD distance was last calculated on
+    /// The frame number animation LOD distance was last calculated on.
     unsigned animationLodFrameNumber_;
-    /// Animation LOD bias
+    /// Animation LOD bias.
     float animationLodBias_;
-    /// Animation LOD timer
+    /// Animation LOD timer.
     float animationLodTimer_;
-    /// Animation LOD distance, the minimum of all LOD view distances last frame
+    /// Animation LOD distance, the minimum of all LOD view distances last frame.
     float animationLodDistance_;
-    /// Animation LOD distance factor when not visible
+    /// Animation LOD distance factor when not visible.
     float invisibleLodFactor_;
-    /// Animation dirty flag
+    /// Animation dirty flag.
     bool animationDirty_;
-    /// Animation order dirty flag
+    /// Animation order dirty flag.
     bool animationOrderDirty_;
-    /// Vertex morphs dirty flag
+    /// Vertex morphs dirty flag.
     bool morphsDirty_;
-    /// Skinning dirty flag
+    /// Skinning dirty flag.
     bool skinningDirty_;
-    /// Master model flag
+    /// Master model flag.
     bool isMaster_;
-    /// Bone nodes assignment pending flag
+    /// Bone nodes assignment pending flag.
     bool assignBonesPending_;
 };

+ 32 - 32
Engine/Graphics/Animation.h

@@ -28,32 +28,32 @@
 #include "Ptr.h"
 #include "Vector3.h"
 
-/// Skeletal animation keyframe
+/// Skeletal animation keyframe.
 struct AnimationKeyFrame
 {
-    /// Keyframe time
+    /// Keyframe time.
     float time_;
-    /// Bone position
+    /// Bone position.
     Vector3 position_;
-    /// Bone rotation
+    /// Bone rotation.
     Quaternion rotation_;
-    /// Bone scale
+    /// Bone scale.
     Vector3 scale_;
 };
 
-/// Skeletal animation track, stores keyframes of a single bone
+/// Skeletal animation track, stores keyframes of a single bone.
 struct AnimationTrack
 {
-    /// Return keyframe index based on time and previous index
+    /// Return keyframe index based on time and previous index.
     void GetKeyFrameIndex(float time, unsigned& index) const;
     
-    /// Bone name
+    /// Bone name.
     String name_;
-    /// Bone name hash
+    /// Bone name hash.
     StringHash nameHash_;
-    /// Bitmask of included data (position, rotation, scale)
+    /// Bitmask of included data (position, rotation, scale.)
     unsigned char channelMask_;
-    /// Keyframes
+    /// Keyframes.
     Vector<AnimationKeyFrame> keyFrames_;
 };
 
@@ -61,55 +61,55 @@ static const unsigned char CHANNEL_POSITION = 0x1;
 static const unsigned char CHANNEL_ROTATION = 0x2;
 static const unsigned char CHANNEL_SCALE = 0x4;
 
-/// Skeletal animation resource
+/// Skeletal animation resource.
 class Animation : public Resource
 {
     OBJECT(Animation);
     
 public:
-    /// Construct
+    /// Construct.
     Animation(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~Animation();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Load resource. Return true if successful
+    /// Load resource. Return true if successful.
     virtual bool Load(Deserializer& source);
-    /// Save resource. Return true if successful
+    /// Save resource. Return true if successful.
     virtual bool Save(Serializer& dest);
     
-    /// %Set animation name
+    /// %Set animation name.
     void SetAnimationName(const String& name);
-    /// %Set animation length
+    /// %Set animation length.
     void SetLength(float length);
-    /// %Set all animation tracks
+    /// %Set all animation tracks.
     void SetTracks(const Vector<AnimationTrack>& tracks);
     
-    /// Return animation name
+    /// Return animation name.
     const String& GetAnimationName() const { return animationName_; }
-    /// Return animation name hash
+    /// Return animation name hash.
     StringHash GetAnimationNameHash() const { return animationNameHash_; }
-    /// Return animation length
+    /// Return animation length.
     float GetLength() const { return length_; }
-    /// Return all animation tracks
+    /// Return all animation tracks.
     const Vector<AnimationTrack>& GetTracks() const { return tracks_; }
-    /// Return number of animation tracks
+    /// Return number of animation tracks.
     unsigned GetNumTracks() const;
-    /// Return animation track by index
+    /// Return animation track by index.
     const AnimationTrack* GetTrack(unsigned index) const;
-    /// Return animation track by bone name
+    /// Return animation track by bone name.
     const AnimationTrack* GetTrack(const String& name) const;
-    /// Return animation track by bone name hash
+    /// Return animation track by bone name hash.
     const AnimationTrack* GetTrack(StringHash nameHash) const;
     
 private:
-    /// Animation name
+    /// Animation name.
     String animationName_;
-    /// Animation name hash
+    /// Animation name hash.
     StringHash animationNameHash_;
-    /// Animation length
+    /// Animation length.
     float length_;
-    /// Animation tracks
+    /// Animation tracks.
     Vector<AnimationTrack> tracks_;
 };

+ 56 - 56
Engine/Graphics/AnimationController.h

@@ -30,10 +30,10 @@ class Animation;
 class AnimationState;
 struct Bone;
 
-/// Control data for an animation
+/// Control data for an animation.
 struct AnimationControl
 {
-    /// Construct with defaults
+    /// Construct with defaults.
     AnimationControl() :
         speed_(1.0f),
         targetWeight_(0.0f),
@@ -48,127 +48,127 @@ struct AnimationControl
     {
     }
 
-    /// Animation resource name hash
+    /// Animation resource name hash.
     StringHash hash_;
-    /// Animation speed
+    /// Animation speed.
     float speed_;
-    /// Animation target weight
+    /// Animation target weight.
     float targetWeight_;
-    /// Animation weight fade time, 0 if no fade
+    /// Animation weight fade time, 0 if no fade.
     float fadeTime_;
-    /// Animation autofade on stop -time, 0 if disabled
+    /// Animation autofade on stop -time, 0 if disabled.
     float autoFadeTime_;
-    /// %Set time command time-to-live
+    /// %Set time command time-to-live.
     float setTimeTtl_;
-    /// %Set weight command time-to-live
+    /// %Set weight command time-to-live.
     float setWeightTtl_;
-    /// %Set time command
+    /// %Set time command.
     unsigned short setTime_;
-    /// %Set weight command
+    /// %Set weight command.
     unsigned char setWeight_;
-    /// %Set time command revision
+    /// %Set time command revision.
     unsigned char setTimeRev_;
-    /// %Set weight command revision
+    /// %Set weight command revision.
     unsigned char setWeightRev_;
 };
 
-/// Component that drives an AnimatedModel's animations
+/// Component that drives an AnimatedModel's animations.
 class AnimationController : public Component
 {
     OBJECT(AnimationController);
 
 public:
-    /// Construct
+    /// Construct.
     AnimationController(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~AnimationController();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Update the animations. Is called from HandleScenePostUpdate()
+    /// Update the animations. Is called from HandleScenePostUpdate().
     void Update(float timeStep);
-    /// Play an animation and set full target weight. Name must be the full resource name. Return true on success
+    /// Play an animation and set full target weight. Name must be the full resource name. Return true on success.
     bool Play(const String& name, unsigned char layer, bool looped, float fadeInTime = 0.0f);
-    /// Play an animation, set full target weight and fade out all other animations on the same layer. Name must be the full resource name. Return true on success
+    /// Play an animation, set full target weight and fade out all other animations on the same layer. Name must be the full resource name. Return true on success.
     bool PlayExclusive(const String& name, unsigned char layer, bool looped, float fadeTime = 0.0f);
-    /// Stop an animation. Zero fadetime is instant. Return true on success
+    /// Stop an animation. Zero fadetime is instant. Return true on success.
     bool Stop(const String& name, float fadeOutTime = 0.0f);
-    /// Stop all animations on a specific layer. Zero fadetime is instant
+    /// Stop all animations on a specific layer. Zero fadetime is instant.
     void StopLayer(unsigned char layer, float fadeOutTime = 0.0f);
-    /// Stop all animations. Zero fadetime is instant
+    /// Stop all animations. Zero fadetime is instant.
     void StopAll(float fadeTime = 0.0f);
-    /// Fade animation to target weight. Return true on success
+    /// Fade animation to target weight. Return true on success.
     bool Fade(const String& name, float targetWeight, float fadeTime);
-    /// Fade other animations on the same layer to target weight. Return true on success
+    /// Fade other animations on the same layer to target weight. Return true on success.
     bool FadeOthers(const String& name, float targetWeight, float fadeTime);
     
-    /// %Set animation blending layer priority. Return true on success
+    /// %Set animation blending layer priority. Return true on success.
     bool SetLayer(const String& name, unsigned char layer);
-    /// %Set animation start bone. Return true on success
+    /// %Set animation start bone. Return true on success.
     bool SetStartBone(const String& name, const String& startBoneName);
-    /// %Set animation time position. Return true on success
+    /// %Set animation time position. Return true on success.
     bool SetTime(const String& name, float time);
-    /// %Set animation weight. Return true on success
+    /// %Set animation weight. Return true on success.
     bool SetWeight(const String& name, float weight);
-    /// %Set animation looping. Return true on success
+    /// %Set animation looping. Return true on success.
     bool SetLooped(const String& name, bool enable);
-    /// %Set animation speed. Return true on success
+    /// %Set animation speed. Return true on success.
     bool SetSpeed(const String& name, float speed);
-    /// %Set animation autofade on stop (non-looped animations only.) Zero time disables. Return true on success
+    /// %Set animation autofade on stop (non-looped animations only.) Zero time disables. Return true on success.
     bool SetAutoFade(const String& name, float fadeOutTime);
     
-    /// Return whether an animation is active
+    /// Return whether an animation is active.
     bool IsPlaying(const String& name) const;
-    /// Return whether an animation is fading in
+    /// Return whether an animation is fading in.
     bool IsFadingIn(const String& name) const;
-    /// Return whether an animation is fading out
+    /// Return whether an animation is fading out.
     bool IsFadingOut(const String& name) const;
-    /// Return animation blending layer
+    /// Return animation blending layer.
     unsigned char GetLayer(const String& name) const;
-    /// Return animation start bone, or null if no such animation
+    /// Return animation start bone, or null if no such animation.
     Bone* GetStartBone(const String& name) const;
-    /// Return animation start bone name, or null if no such animation
+    /// Return animation start bone name, or null if no such animation.
     const String& GetStartBoneName(const String& name) const;
-    /// Return animation time position
+    /// Return animation time position.
     float GetTime(const String& name) const;
-    /// Return animation weight
+    /// Return animation weight.
     float GetWeight(const String& name) const;
-    /// Return animation looping
+    /// Return animation looping.
     bool IsLooped(const String& name) const;
-    /// Return animation length
+    /// Return animation length.
     float GetLength(const String& name) const;
-    /// Return animation speed
+    /// Return animation speed.
     float GetSpeed(const String& name) const;
-    /// Return animation fade target weight
+    /// Return animation fade target weight.
     float GetFadeTarget(const String& name) const;
-    /// Return animation fade time
+    /// Return animation fade time.
     float GetFadeTime(const String& name) const;
-    /// Return animation autofade time
+    /// Return animation autofade time.
     float GetAutoFade(const String& name) const;
     
-    /// %Set animations attribute
+    /// %Set animations attribute.
     void SetAnimationsAttr(const PODVector<unsigned char>& value);
-    /// %Set network animations attribute
+    /// %Set network animations attribute.
     void SetNetAnimationsAttr(const PODVector<unsigned char>& value);
-    /// Return animations attribute
+    /// Return animations attribute.
     const PODVector<unsigned char>& GetAnimationsAttr() const;
-    /// Return net animations attribute
+    /// Return net animations attribute.
     const PODVector<unsigned char>& GetNetAnimationsAttr() const;
     
 protected:
-    /// Handle node being assigned
+    /// Handle node being assigned.
     virtual void OnNodeSet(Node* node);
     
 private:
-    /// Find the internal index and animation state of an animation
+    /// Find the internal index and animation state of an animation.
     void FindAnimation(const String& name, unsigned& index, AnimationState*& state) const;
-    /// Find the animation state only
+    /// Find the animation state only.
     AnimationState* FindAnimationState(const String& name) const;
-    /// Handle scene post-update event
+    /// Handle scene post-update event.
     void HandleScenePostUpdate(StringHash eventType, VariantMap& eventData);
     
-    /// Controlled animations
+    /// Controlled animations.
     Vector<AnimationControl> animations_;
-    /// Attribute buffer for network replication
+    /// Attribute buffer for network replication.
     mutable VectorBuffer attrBuffer_;
 };

+ 31 - 31
Engine/Graphics/AnimationState.h

@@ -34,73 +34,73 @@ class Skeleton;
 struct AnimationTrack;
 struct Bone;
 
-/// Animation instance in an animated model
+/// Animation instance in an animated model.
 class AnimationState : public RefCounted
 {
 public:
-    /// Construct with animated model and animation pointers
+    /// Construct with animated model and animation pointers.
     AnimationState(AnimatedModel* model, Animation* animation);
-    /// Destruct
+    /// Destruct.
     ~AnimationState();
     
-    /// %Set start bone
+    /// %Set start bone.
     void SetStartBone(Bone* bone);
-    /// %Set looping enabled/disabled
+    /// %Set looping enabled/disabled.
     void SetLooped(bool looped);
-    /// %Set blending weight
+    /// %Set blending weight.
     void SetWeight(float weight);
-    /// %Set time position
+    /// %Set time position.
     void SetTime(float time);
-    /// Modify blending weight
+    /// Modify blending weight.
     void AddWeight(float delta);
-    /// Modify time position
+    /// Modify time position.
     void AddTime(float delta);
-    /// %Set blending layer
+    /// %Set blending layer.
     void SetLayer(unsigned char layer);
-    /// %Set whether to use nlerp instead of slerp for rotation, default false
+    /// %Set whether to use nlerp instead of slerp for rotation, default false.
     void SetUseNlerp(bool enable);
     
-    /// Return animation
+    /// Return animation.
     Animation* GetAnimation() const { return animation_; }
-    /// Return start bone
+    /// Return start bone.
     Bone* GetStartBone() const;
-    /// Return whether weight is nonzero
+    /// Return whether weight is nonzero.
     bool IsEnabled() const { return weight_ > 0.0f; }
-    /// Return whether looped
+    /// Return whether looped.
     bool IsLooped() const { return looped_; }
-    /// Return blending weight
+    /// Return blending weight.
     float GetWeight() const { return weight_; }
-    /// Return time position
+    /// Return time position.
     float GetTime() const { return time_; }
-    /// Return animation length
+    /// Return animation length.
     float GetLength() const;
-    /// Return blending layer
+    /// Return blending layer.
     unsigned char GetLayer() const { return layer_; }
-    /// Return whether using nlerp for rotation
+    /// Return whether using nlerp for rotation.
     bool GetUseNlerp() const { return useNlerp_; }
     
-    /// Apply to the animated model's skeleton. Called by AnimatedModel
+    /// Apply to the animated model's skeleton. Called by AnimatedModel.
     void Apply();
     
 private:
-    /// Animated model
+    /// Animated model.
     WeakPtr<AnimatedModel> model_;
-    /// Animation
+    /// Animation.
     SharedPtr<Animation> animation_;
-    /// Start bone
+    /// Start bone.
     Bone* startBone_;
-    /// Mapping of animation track indices to bones
+    /// Mapping of animation track indices to bones.
     HashMap<unsigned, Bone*> trackToBoneMap_;
-    /// Last keyframe on each animation track for optimized keyframe search
+    /// Last keyframe on each animation track for optimized keyframe search.
     PODVector<unsigned> lastKeyFrame_;
-    /// Looped flag
+    /// Looped flag.
     bool looped_;
-    /// Blending weight
+    /// Blending weight.
     float weight_;
-    /// Time position
+    /// Time position.
     float time_;
-    /// Blending layer
+    /// Blending layer.
     unsigned char layer_;
-    /// Nlerp flag
+    /// Nlerp flag.
     bool useNlerp_;
 };

+ 68 - 68
Engine/Graphics/Batch.h

@@ -41,10 +41,10 @@ class Matrix3x4;
 class ShaderVariation;
 class VertexBuffer;
 
-/// Description of a 3D geometry draw call
+/// Description of a 3D geometry draw call.
 struct Batch
 {
-    /// Construct with defaults
+    /// Construct with defaults.
     Batch() :
         light_(0),
         shaderData_(0),
@@ -55,127 +55,127 @@ struct Batch
     {
     }
     
-    /// Calculate sort key, which consists of priority flag, light, pass and geometry
+    /// Calculate sort key, which consists of priority flag, light, pass and geometry.
     void CalculateSortKey();
-    /// Prepare for rendering
+    /// Prepare for rendering.
     void Prepare(Graphics* graphics, const HashMap<StringHash, Vector4>& shaderParameters, bool setModelTransform = true) const;
-    /// Prepare and draw
+    /// Prepare and draw.
     void Draw(Graphics* graphics, const HashMap<StringHash, Vector4>& shaderParameters) const;
     
-    /// Geometry
+    /// Geometry.
     Geometry* geometry_;
-    /// Model world transform
+    /// Model world transform.
     const Matrix3x4* worldTransform_;
-    /// Camera
+    /// Camera.
     Camera* camera_;
-    /// Light that affects the geometry, if any
+    /// Light that affects the geometry, if any.
     Light* light_;
-    /// Material
+    /// Material.
     Material* material_;
-    /// Material pass
+    /// Material pass.
     Pass* pass_;
-    /// Vertex shader
+    /// Vertex shader.
     ShaderVariation* vertexShader_;
-    /// Pixel shader
+    /// Pixel shader.
     ShaderVariation* pixelShader_;
-    /// Vertex shader data
+    /// Vertex shader data.
     const float* shaderData_;
-    /// Vertex shader data size in floats
+    /// Vertex shader data size in floats.
     unsigned shaderDataSize_;
-    /// Distance from camera
+    /// Distance from camera.
     float distance_;
-    /// State sorting key
+    /// State sorting key.
     unsigned long long sortKey_;
-    /// Geometry type
+    /// Geometry type.
     GeometryType geometryType_;
-    /// Vertex shader index
+    /// Vertex shader index.
     unsigned char vertexShaderIndex_;
-    /// Override view transform flag
+    /// Override view transform flag.
     bool overrideView_;
-    /// Priority flag
+    /// Priority flag.
     bool hasPriority_;
 };
 
-/// Data for one geometry instance
+/// Data for one geometry instance.
 struct InstanceData
 {
-    /// Construct undefined
+    /// Construct undefined.
     InstanceData()
     {
     }
     
-    /// Construct with transform and distance
+    /// Construct with transform and distance.
     InstanceData(const Matrix3x4* worldTransform, float distance) :
         worldTransform_(worldTransform),
         distance_(distance)
     {
     }
     
-    /// World transform
+    /// World transform.
     const Matrix3x4* worldTransform_;
-    /// Distance from camera
+    /// Distance from camera.
     float distance_;
 };
 
-/// Instanced 3D geometry draw call
+/// Instanced 3D geometry draw call.
 struct BatchGroup
 {
-    /// Construct with defaults
+    /// Construct with defaults.
     BatchGroup() :
         startIndex_(M_MAX_UNSIGNED)
     {
     }
     
-    /// Destruct
+    /// Destruct.
     ~BatchGroup()
     {
     }
     
-    /// Pre-set the instance transforms. Buffer must be big enough to hold all transforms
+    /// Pre-set the instance transforms. Buffer must be big enough to hold all transforms.
     void SetTransforms(void* lockedData, unsigned& freeIndex);
-    /// Prepare and draw
+    /// Prepare and draw.
     void Draw(Graphics* graphics, VertexBuffer* instanceBuffer, const HashMap<StringHash, Vector4>& shaderParameters) const;
     
-    /// Geometry
+    /// Geometry.
     Geometry* geometry_;
-    /// Instance data
+    /// Instance data.
     PODVector<InstanceData> instances_;
-    /// Camera
+    /// Camera.
     Camera* camera_;
-    /// Light that affects the geometry, if any
+    /// Light that affects the geometry, if any.
     Light* light_;
-    /// Material
+    /// Material.
     Material* material_;
-    /// Material pass
+    /// Material pass.
     Pass* pass_;
-    /// Vertex shader
+    /// Vertex shader.
     ShaderVariation* vertexShader_;
-    /// Pixel shader
+    /// Pixel shader.
     ShaderVariation* pixelShader_;
-    /// Vertex shader index
+    /// Vertex shader index.
     unsigned char vertexShaderIndex_;
-    /// Instance stream start index, or M_MAX_UNSIGNED if transforms not pre-set
+    /// Instance stream start index, or M_MAX_UNSIGNED if transforms not pre-set.
     unsigned startIndex_;
 };
 
-/// Instanced draw call key
+/// Instanced draw call key.
 struct BatchGroupKey
 {
-    /// Light that affects the geometry, if any
+    /// Light that affects the geometry, if any.
     Light* light_;
-    /// Material pass
+    /// Material pass.
     Pass* pass_;
-    /// Material
+    /// Material.
     Material* material_;
-    /// Geometry
+    /// Geometry.
     Geometry* geometry_;
     
-    /// Test for equality with another batch group key
+    /// Test for equality with another batch group key.
     bool operator == (const BatchGroupKey& rhs) const { return light_ == rhs.light_ && pass_ == rhs.pass_ && material_ == rhs.material_ && geometry_ == rhs.geometry_; }
-    /// Test for inequality with another batch group key
+    /// Test for inequality with another batch group key.
     bool operator != (const BatchGroupKey& rhs) const { return light_ != rhs.light_ || pass_ != rhs.pass_ || material_ != rhs.material_ || geometry_ != rhs.geometry_; }
     
-    /// Test if less than another batch group key
+    /// Test if less than another batch group key.
     bool operator < (const BatchGroupKey& rhs) const
     {
         if (light_ == rhs.light_)
@@ -194,7 +194,7 @@ struct BatchGroupKey
             return light_ < rhs.light_;
     }
     
-    /// Test if greater than another batch group key
+    /// Test if greater than another batch group key.
     bool operator > (const BatchGroupKey& rhs) const
     {
         if (light_ == rhs.light_)
@@ -214,48 +214,48 @@ struct BatchGroupKey
     }
 };
 
-/// Queue that contains both instanced and non-instanced draw calls
+/// Queue that contains both instanced and non-instanced draw calls.
 struct BatchQueue
 {
 public:
-    /// Clear everything
+    /// Clear everything.
     void Clear();
-    /// Add a batch, with instancing if possible
+    /// Add a batch, with instancing if possible.
     void AddBatch(const Batch& batch, bool noInstancing = false);
-    /// Sort non-instanced draw calls back to front
+    /// Sort non-instanced draw calls back to front.
     void SortBackToFront();
-    /// Sort instanced and non-instanced draw calls front to back
+    /// Sort instanced and non-instanced draw calls front to back.
     void SortFrontToBack();
-    /// Pre-set instance transforms of all groups. The vertex buffer must be big enough to hold all transforms
+    /// Pre-set instance transforms of all groups. The vertex buffer must be big enough to hold all transforms.
     void SetTransforms(void* lockedData, unsigned& freeIndex);
     
-    /// Return the combined amount of instances
+    /// Return the combined amount of instances.
     unsigned GetNumInstances() const;
-    /// Return whether the batch group is empty
+    /// Return whether the batch group is empty.
     bool IsEmpty() const { return batches_.Empty() && priorityBatchGroups_.Empty() && batchGroups_.Empty(); }
-    /// Unsorted non-instanced draw calls
+    /// Unsorted non-instanced draw calls.
     PODVector<Batch> batches_;
-    /// Sorted non-instanced draw calls with priority flag
+    /// Sorted non-instanced draw calls with priority flag.
     PODVector<Batch*> sortedPriorityBatches_;
-    /// Sorted non-instanced draw calls
+    /// Sorted non-instanced draw calls.
     PODVector<Batch*> sortedBatches_;
-    /// Instanced draw calls with priority flag
+    /// Instanced draw calls with priority flag.
     Map<BatchGroupKey, BatchGroup> priorityBatchGroups_;
-    /// Instanced draw calls
+    /// Instanced draw calls.
     Map<BatchGroupKey, BatchGroup> batchGroups_;
 };
 
 /// Queue for light related draw calls
 struct LightBatchQueue
 {
-    /// Light drawable
+    /// Light drawable.
     Light* light_;
-    /// Shadowcaster draw calls
+    /// Shadowcaster draw calls.
     BatchQueue shadowBatches_;
-    /// Lit geometry draw calls
+    /// Lit geometry draw calls.
     BatchQueue litBatches_;
-    /// Light volume draw calls, should be only one
+    /// Light volume draw calls, should be only one.
     PODVector<Batch> volumeBatches_;
-    /// Last split flag for clearing the stencil buffer
+    /// Last split flag for clearing the stencil buffer.
     bool lastSplit_;
 };

+ 56 - 56
Engine/Graphics/BillboardSet.h

@@ -31,133 +31,133 @@ class IndexBuffer;
 class Graphics;
 class VertexBuffer;
 
-/// One billboard in the billboard set
+/// One billboard in the billboard set.
 struct Billboard
 {
-    /// Position
+    /// Position.
     Vector3 position_;
-    /// Two-dimensional size
+    /// Two-dimensional size.
     Vector2 size_;
-    /// UV coordinates
+    /// UV coordinates.
     Rect uv_;
-    /// Color
+    /// Color.
     Color color_;
-    /// Rotation
+    /// Rotation.
     float rotation_;
-    /// Enabled flag
+    /// Enabled flag.
     bool enabled_;
-    /// Sort distance
+    /// Sort distance.
     float sortDistance_;
 };
 
-/// Billboard component
+/// Billboard component.
 class BillboardSet : public Drawable
 {
     OBJECT(BillboardSet);
     
 public:
-    /// Construct
+    /// Construct.
     BillboardSet(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~BillboardSet();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Calculate distance for rendering
+    /// Calculate distance for rendering.
     virtual void UpdateDistance(const FrameInfo& frame);
-    /// Prepare geometry for rendering
+    /// Prepare geometry for rendering.
     virtual void UpdateGeometry(const FrameInfo& frame);
-    /// Return number of batches
+    /// Return number of batches.
     virtual unsigned GetNumBatches();
-    /// Return rendering batch
+    /// Return rendering batch.
     virtual void GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch);
     
-    /// %Set material
+    /// %Set material.
     void SetMaterial(Material* material);
-    /// %Set number of billboards
+    /// %Set number of billboards.
     void SetNumBillboards(unsigned num);
-    /// %Set whether billboards are relative to the scene node
+    /// %Set whether billboards are relative to the scene node.
     void SetRelative(bool enable);
-    /// %Set whether scene node scale affects billboards' size
+    /// %Set whether scene node scale affects billboards' size.
     void SetScaled(bool enable);
-    /// %Set whether billboards are sorted by distance
+    /// %Set whether billboards are sorted by distance.
     void SetSorted(bool enable);
-    /// %Set animation LOD bias
+    /// %Set animation LOD bias.
     void SetAnimationLodBias(float bias);
-    /// Call after changing the billboards
+    /// Call after changing the billboards.
     void Updated();
     
-    /// Return material
+    /// Return material.
     Material* GetMaterial() const { return material_; }
-    /// Return number of billboards
+    /// Return number of billboards.
     unsigned GetNumBillboards() const { return billboards_.Size(); }
-    /// Return all billboards
+    /// Return all billboards.
     PODVector<Billboard>& GetBillboards() { return billboards_; }
-    /// Return billboard by index
+    /// Return billboard by index.
     Billboard* GetBillboard(unsigned index);
-    /// Return whether billboards are relative to the scene node
+    /// Return whether billboards are relative to the scene node.
     bool IsRelative() const { return relative_; }
-    /// Return whether scene node scale affects billboards' size
+    /// Return whether scene node scale affects billboards' size.
     bool IsScaled() const { return scaled_; }
-    /// Return whether billboards are sorted
+    /// Return whether billboards are sorted.
     bool IsSorted() const { return sorted_; }
-    /// Return animation LOD bias
+    /// Return animation LOD bias.
     float GetAnimationLodBias() const { return animationLodBias_; }
     
-    /// %Set material attribute
+    /// %Set material attribute.
     void SetMaterialAttr(ResourceRef value);
-    /// %Set billboards attribute
+    /// %Set billboards attribute.
     void SetBillboardsAttr(PODVector<unsigned char> value);
-    /// Return material attribute
+    /// Return material attribute.
     ResourceRef GetMaterialAttr() const;
-    /// Return billboards attribute
+    /// Return billboards attribute.
     PODVector<unsigned char> GetBillboardsAttr() const;
     
 protected:
-    /// Transform has changed. Mark billboards dirty if necessary
+    /// Transform has changed. Mark billboards dirty if necessary.
     virtual void OnMarkedDirty(Node* node);
-    /// Update world-space bounding box
+    /// Update world-space bounding box.
     virtual void OnWorldBoundingBoxUpdate();
-    /// Mark billboard vertex buffer to need an update
+    /// Mark billboard vertex buffer to need an update.
     void MarkPositionsDirty();
     
-    /// Billboards
+    /// Billboards.
     PODVector<Billboard> billboards_;
-    /// Animation LOD bias
+    /// Animation LOD bias.
     float animationLodBias_;
-    /// Animation LOD timer
+    /// Animation LOD timer.
     float animationLodTimer_;
-    /// Billboards relative flag
+    /// Billboards relative flag.
     bool relative_;
-    /// Scale affects billboard scale flag
+    /// Scale affects billboard scale flag.
     bool scaled_;
-    /// Billboards sorted flag
+    /// Billboards sorted flag.
     bool sorted_;
     
 private:
-    /// Resize billboard vertex and index buffers
+    /// Resize billboard vertex and index buffers.
     void UpdateBufferSize();
-    /// Rewrite billboard vertex buffer
+    /// Rewrite billboard vertex buffer.
     void UpdateVertexBuffer(const FrameInfo& frame);
     
-    /// Geometry
+    /// Geometry.
     SharedPtr<Geometry> geometry_;
-    /// Material
+    /// Material.
     SharedPtr<Material> material_;
-    /// Vertex buffer
+    /// Vertex buffer.
     SharedPtr<VertexBuffer> vertexBuffer_;
-    /// Index buffer
+    /// Index buffer.
     SharedPtr<IndexBuffer> indexBuffer_;
-    /// Buffers need resize flag
+    /// Buffers need resize flag.
     bool bufferSizeDirty_;
-    /// Vertex buffer needs rewrite flag
+    /// Vertex buffer needs rewrite flag.
     bool bufferDirty_;
-    /// Force update flag (ignore animation LOD momentarily)
+    /// Force update flag (ignore animation LOD momentarily.)
     bool forceUpdate_;
-    /// Frame number on which was last sorted
+    /// Frame number on which was last sorted.
     unsigned sortFrameNumber_;
-    /// Previous offset to camera for determining whether sorting is necessary
+    /// Previous offset to camera for determining whether sorting is necessary.
     Vector3 previousOffset_;
-    /// Billboard pointers for sorting
+    /// Billboard pointers for sorting.
     Vector<Billboard*> sortedBillboards_;
 };

+ 55 - 55
Engine/Graphics/Camera.h

@@ -33,123 +33,123 @@ static const unsigned VOF_LOW_MATERIAL_QUALITY = 0x1;
 static const unsigned VOF_DISABLE_SHADOWS = 0x2;
 static const unsigned VOF_DISABLE_OCCLUSION = 0x4;
 
-/// Camera component
+/// Camera component.
 class Camera : public Component
 {
     OBJECT(Camera);
     
 public:
-    /// Construct
+    /// Construct.
     Camera(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~Camera();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// %Set near clip distance
+    /// %Set near clip distance.
     void SetNearClip(float nearClip);
-    /// %Set far clip distance
+    /// %Set far clip distance.
     void SetFarClip(float farClip);
-    /// %Set field of view
+    /// %Set field of view.
     void SetFov(float fov);
-    /// %Set orthographic mode view uniform size
+    /// %Set orthographic mode view uniform size.
     void SetOrthoSize(float orthoSize);
-    /// %Set orthographic mode view size
+    /// %Set orthographic mode view size.
     void SetOrthoSize(const Vector2& orthoSize);
-    /// %Set aspect ratio
+    /// %Set aspect ratio.
     void SetAspectRatio(float aspectRatio);
-    /// %Set zoom
+    /// %Set zoom.
     void SetZoom(float zoom);
-    /// %Set LOD bias
+    /// %Set LOD bias.
     void SetLodBias(float bias);
-    /// %Set view mask. Will be and'ed with object's view mask to see if the object should be rendered
+    /// %Set view mask. Will be and'ed with object's view mask to see if the object should be rendered.
     void SetViewMask(unsigned mask);
-    /// %Set view override flags
+    /// %Set view override flags.
     void SetViewOverrideFlags(unsigned flags);
-    /// %Set orthographic mode enabled/disabled
+    /// %Set orthographic mode enabled/disabled.
     void SetOrthographic(bool enable);
-    /// %Set automatic aspect ratio based on viewport dimensions
+    /// %Set automatic aspect ratio based on viewport dimensions.
     void SetAutoAspectRatio(bool enable);
-    /// %Set projection jitter offset. It needs to be calculated as (offset in pixels) / (viewport dimensions)
+    /// %Set projection jitter offset. It needs to be calculated as (offset in pixels) / (viewport dimensions.)
     void SetProjectionOffset(const Vector2& offset);
     
-    /// Return far clip distance
+    /// Return far clip distance.
     float GetFarClip() const { return farClip_; }
-    /// Return near clip distance
+    /// Return near clip distance.
     float GetNearClip() const;
-    /// Return field of view
+    /// Return field of view.
     float GetFov() const { return fov_; }
-    /// Return orthographic mode size
+    /// Return orthographic mode size.
     float GetOrthoSize() const { return orthoSize_; } 
-    /// Return aspect ratio
+    /// Return aspect ratio.
     float GetAspectRatio() const { return aspectRatio_; }
-    /// Return zoom
+    /// Return zoom.
     float GetZoom() const { return zoom_; }
-    /// Return LOD bias
+    /// Return LOD bias.
     float GetLodBias() const { return lodBias_; }
-    /// Return view mask
+    /// Return view mask.
     unsigned GetViewMask() const { return viewMask_; }
-    /// Return view override flags
+    /// Return view override flags.
     unsigned GetViewOverrideFlags() const { return viewOverrideFlags_; }
-    /// Return orthographic flag
+    /// Return orthographic flag.
     bool IsOrthographic() const { return orthographic_; }
-    /// Return auto aspect ratio flag
+    /// Return auto aspect ratio flag.
     bool GetAutoAspectRatio() const { return autoAspectRatio_; }
-    /// Return frustum in world space
+    /// Return frustum in world space.
     Frustum GetFrustum() const;
-    /// Return projection matrix
+    /// Return projection matrix.
     Matrix4 GetProjection(bool enableOffset = true) const;
-    /// Return frustum near and far sizes
+    /// Return frustum near and far sizes.
     void GetFrustumSize(Vector3& near, Vector3& far) const;
-    /// Return half view size
+    /// Return half view size.
     float GetHalfViewSize() const;
-    /// Return frustum transformed to view space
+    /// Return frustum transformed to view space.
     Frustum GetViewSpaceFrustum() const;
-    /// Return frustum split by custom near and far clip distances
+    /// Return frustum split by custom near and far clip distances.
     Frustum GetSplitFrustum(float nearClip, float farClip);
-    /// Return ray corresponding to screen coordinates (0.0 to 1.0)
+    /// Return ray corresponding to screen coordinates (0.0 to 1.0.)
     Ray GetScreenRay(float x, float y);
-    /// Return forward vector
+    /// Return forward vector.
     Vector3 GetForwardVector();
-    /// Return right vector
+    /// Return right vector.
     Vector3 GetRightVector();
-    /// Return up vector
+    /// Return up vector.
     Vector3 GetUpVector();
-    /// Return projection jitter offset
+    /// Return projection jitter offset.
     const Vector2& GetProjectionOffset() const { return projectionOffset_; }
-    /// Return distance to position. In orthographic mode uses only Z coordinate
+    /// Return distance to position. In orthographic mode uses only Z coordinate.
     float GetDistance(const Vector3& worldPos);
-    /// Return squared distance to position. In orthographic mode uses only Z coordinate
+    /// Return squared distance to position. In orthographic mode uses only Z coordinate.
     float GetDistanceSquared(const Vector3& worldPos);
-    /// Return a scene node's LOD scaled distance
+    /// Return a scene node's LOD scaled distance.
     float GetLodDistance(float distance, float scale, float bias) const;
     
-    /// Return inverse world transform (view matrix)
+    /// Return inverse world transform, also known as the view matrix.
     Matrix3x4 GetInverseWorldTransform() const { return GetWorldTransform().Inverse(); }
     
 private:
-    /// Near clip distance
+    /// Near clip distance.
     float nearClip_;
-    /// Far clip distance
+    /// Far clip distance.
     float farClip_;
-    /// Field of view
+    /// Field of view.
     float fov_;
-    /// Orthographic view size
+    /// Orthographic view size.
     float orthoSize_;
-    /// Aspect ratio
+    /// Aspect ratio.
     float aspectRatio_;
-    /// Zoom
+    /// Zoom.
     float zoom_;
-    /// LOD bias
+    /// LOD bias.
     float lodBias_;
-    /// View mask
+    /// View mask.
     unsigned viewMask_;
-    /// View override flags
+    /// View override flags.
     unsigned viewOverrideFlags_;
-    /// Orthographic mode flag
+    /// Orthographic mode flag.
     bool orthographic_;
-    /// Auto aspect ratio flag
+    /// Auto aspect ratio flag.
     bool autoAspectRatio_;
-    /// Projection jitter offset
+    /// Projection jitter offset.
     Vector2 projectionOffset_;
 };

+ 27 - 27
Engine/Graphics/DebugRenderer.h

@@ -37,15 +37,15 @@ class Matrix3x4;
 class Renderer;
 class Skeleton;
 
-/// Debug rendering line
+/// Debug rendering line.
 struct DebugLine
 {
-    /// Construct as undefined
+    /// Construct undefined.
     DebugLine()
     {
     }
     
-    /// Construct with start and end positions and color
+    /// Construct with start and end positions and color.
     DebugLine(const Vector3& start, const Vector3& end, unsigned color) :
         start_(start),
         end_(end),
@@ -53,63 +53,63 @@ struct DebugLine
     {
     }
     
-    /// Start position
+    /// Start position.
     Vector3 start_;
-    /// End position
+    /// End position.
     Vector3 end_;
-    /// Color
+    /// Color.
     unsigned color_;
 };
 
-/// Debug geometry rendering component. Should be added only to the root scene node
+/// Debug geometry rendering component. Should be added only to the root scene node.
 class DebugRenderer : public Component
 {
     OBJECT(DebugRenderer);
     
 public:
-    /// Construct
+    /// Construct.
     DebugRenderer(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~DebugRenderer();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// %Set the camera viewpoint. Call before rendering, or before adding geometry if you want to use culling
+    /// %Set the camera viewpoint. Call before rendering, or before adding geometry if you want to use culling.
     void SetView(Camera* camera);
-    /// Add a line
+    /// Add a line.
     void AddLine(const Vector3& start, const Vector3& end, const Color& color, bool depthTest = true);
-    /// Add a bounding box
+    /// Add a bounding box.
     void AddBoundingBox(const BoundingBox& box, const Color& color, bool depthTest = true);
-    /// Add a bounding box with transform
+    /// Add a bounding box with transform.
     void AddBoundingBox(const BoundingBox& box, const Matrix3x4& transform, const Color& color, bool depthTest = true);
-    /// Add a frustum
+    /// Add a frustum.
     void AddFrustum(const Frustum& frustum, const Color& color, bool depthTest = true);
-    /// Add a skeleton
+    /// Add a skeleton.
     void AddSkeleton(const Skeleton& skeleton, const Color& color, bool depthTest = true);
-    /// Render all debug lines. The viewport and rendertarget should be set before
+    /// Render all debug lines. The viewport and rendertarget should be set before.
     void Render();
     
-    /// Return the view transform
+    /// Return the view transform.
     const Matrix3x4& GetView() const { return view_; }
-    /// Return the projection transform
+    /// Return the projection transform.
     const Matrix4& GetProjection() const { return projection_; }
-    /// Return the view frustum
+    /// Return the view frustum.
     const Frustum& GetFrustum() const { return frustum_; }
-    /// Check whether a bounding box is inside the view frustum
+    /// Check whether a bounding box is inside the view frustum.
     bool IsInside(const BoundingBox& box) const;
     
 private:
-    /// Handle end of frame. Clear debug geometry
+    /// Handle end of frame. Clear debug geometry.
     void HandleEndFrame(StringHash eventType, VariantMap& eventData);
     
-    /// Lines rendered with depth test
+    /// Lines rendered with depth test.
     PODVector<DebugLine> lines_;
-    /// Lines rendered without depth test
+    /// Lines rendered without depth test.
     PODVector<DebugLine> noDepthLines_;
-    /// View transform
+    /// View transform.
     Matrix3x4 view_;
-    /// Projection transform
+    /// Projection transform.
     Matrix4 projection_;
-    /// View frustum
+    /// View frustum.
     Frustum frustum_;
 };

+ 9 - 9
Engine/Graphics/Direct3D9/D3D9GPUObject.h

@@ -31,26 +31,26 @@ class Graphics;
 class GPUObject
 {
 public:
-    /// Construct with graphics subsystem pointer
+    /// Construct with graphics subsystem pointer.
     GPUObject(Graphics* graphics);
-    /// Destruct. Remove from the Graphics
+    /// Destruct. Remove from the graphics subsystem.
     virtual ~GPUObject();
     
-    /// Release default pool resources
+    /// Release default pool resources.
     virtual void OnDeviceLost() {}
-    /// Recreate default pool resources
+    /// Recreate default pool resources.
     virtual void OnDeviceReset() {}
-    /// Unconditionally release the GPU resource
+    /// Unconditionally release the GPU resource.
     virtual void Release() {}
     
-    /// Return the graphics subsystem
+    /// Return the graphics subsystem.
     Graphics* GetGraphics() const { return graphics_; }
-    /// Return Direct3D object
+    /// Return Direct3D object.
     void* GetGPUObject() const { return object_; }
     
 protected:
-    /// Graphics subsystem
+    /// Graphics subsystem.
     WeakPtr<Graphics> graphics_;
-    /// Direct3D object
+    /// Direct3D object.
     void* object_;
 };

+ 231 - 231
Engine/Graphics/Direct3D9/D3D9Graphics.h

@@ -51,11 +51,11 @@ static const int IMMEDIATE_BUFFER_DEFAULT_SIZE = 1024;
 /// Shader parameter information
 struct ShaderParameterInfo
 {
-    /// Shader type
+    /// Shader type.
     ShaderType type_;
-    /// Hardware register
+    /// Hardware register.
     unsigned register_;
-    /// Last source
+    /// Last source.
     const void* lastSource_;
 };
 
@@ -65,473 +65,473 @@ class Graphics : public Object
     OBJECT(Graphics);
     
 public:
-    /// Construct
+    /// Construct.
     Graphics(Context* context);
-    /// Destruct. Close the window and release the Direct3D9 device 
+    /// Destruct. Close the window and release the Direct3D9 device .
     virtual ~Graphics();
     
-    /// %Set window title
+    /// %Set window title.
     void SetWindowTitle(const String& windowTitle);
-    /// %Set screen mode. In deferred rendering modes multisampling means edge filtering instead of MSAA
+    /// %Set screen mode. In deferred rendering modes multisampling means edge filtering instead of MSAA.
     bool SetMode(RenderMode mode, int width, int height, bool fullscreen, bool vsync, int multiSample);
-    /// %Set screen resolution only
+    /// %Set screen resolution only.
     bool SetMode(int width, int height);
-    /// %Set rendering mode only
+    /// %Set rendering mode only.
     bool SetMode(RenderMode mode);
-    /// Toggle between full screen and windowed mode
+    /// Toggle between full screen and windowed mode.
     bool ToggleFullscreen();
-    /// Close the window
+    /// Close the window.
     void Close();
-    /// Take a screenshot
+    /// Take a screenshot.
     bool TakeScreenShot(Image& destImage);
-    /// %Set whether to flush GPU command queue at the end of each frame. Default true
+    /// %Set whether to flush GPU command queue at the end of each frame. Default true.
     void SetFlushGPU(bool enable);
     
-    /// Begin frame rendering
+    /// Begin frame rendering.
     bool BeginFrame();
-    /// End frame rendering and swap buffers
+    /// End frame rendering and swap buffers.
     void EndFrame();
-    /// Clear any or all of render target, depth buffer and stencil buffer
+    /// Clear any or all of render target, depth buffer and stencil buffer.
     void Clear(unsigned flags, const Color& color = Color(0.0f, 0.0f, 0.0f, 0.0f), float depth = 1.0f, unsigned stencil = 0);
-    /// Draw non-indexed geometry
+    /// Draw non-indexed geometry.
     void Draw(PrimitiveType type, unsigned vertexStart, unsigned vertexCount);
-    /// Draw indexed geometry
+    /// Draw indexed geometry.
     void Draw(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount);
-    /// Draw indexed, instanced geometry. An instancing vertex buffer must be set
+    /// Draw indexed, instanced geometry. An instancing vertex buffer must be set.
     void DrawInstanced(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount, unsigned instanceCount);
-    /// %Set vertex buffer
+    /// %Set vertex buffer.
     void SetVertexBuffer(VertexBuffer* buffer);
-    /// %Set multiple vertex buffers
+    /// %Set multiple vertex buffers.
     bool SetVertexBuffers(const Vector<VertexBuffer*>& buffers, const PODVector<unsigned>& elementMasks, unsigned instanceOffset = 0);
-    /// %Set multiple vertex buffers
+    /// %Set multiple vertex buffers.
     bool SetVertexBuffers(const Vector<SharedPtr<VertexBuffer> >& buffers, const PODVector<unsigned>& elementMasks, unsigned instanceOffset = 0);
-    /// %Set index buffer
+    /// %Set index buffer.
     void SetIndexBuffer(IndexBuffer* buffer);
-    /// %Set shaders
+    /// %Set shaders.
     void SetShaders(ShaderVariation* vs, ShaderVariation* ps);
-    /// %Set shader bool constants
+    /// %Set shader bool constants.
     void SetShaderParameter(StringHash param, const bool* data, unsigned count);
-    /// %Set shader float constants
+    /// %Set shader float constants.
     void SetShaderParameter(StringHash param, const float* data, unsigned count);
-    /// %Set shader int constants
+    /// %Set shader int constants.
     void SetShaderParameter(StringHash param, const int* data, unsigned count);
-    /// %Set shader float constant
+    /// %Set shader float constant.
     void SetShaderParameter(StringHash param, float value);
-    /// %Set shader color constant
+    /// %Set shader color constant.
     void SetShaderParameter(StringHash param, const Color& color);
-    /// %Set shader 3x3 matrix constant
+    /// %Set shader 3x3 matrix constant.
     void SetShaderParameter(StringHash param, const Matrix3& matrix);
-    /// %Set shader 3D vector constant
+    /// %Set shader 3D vector constant.
     void SetShaderParameter(StringHash param, const Vector3& vector);
-    /// %Set shader 4x4 matrix constant
+    /// %Set shader 4x4 matrix constant.
     void SetShaderParameter(StringHash param, const Matrix4& matrix);
-    /// %Set shader 4D vector constant
+    /// %Set shader 4D vector constant.
     void SetShaderParameter(StringHash param, const Vector4& vector);
-    /// %Set shader 4x3 matrix constant
+    /// %Set shader 4x3 matrix constant.
     void SetShaderParameter(StringHash param, const Matrix3x4& matrix);
-    /// Define a shader parameter. Called by Shader
+    /// Define a shader parameter. Called by Shader.
     void DefineShaderParameter(StringHash param, ShaderType type, unsigned hwReg);
-    /// Check whether a shader parameter in the currently set shaders needs update
+    /// Check whether a shader parameter in the currently set shaders needs update.
     bool NeedParameterUpdate(StringHash param, const void* source);
-    /// Check whether the current pixel shader uses a texture unit
+    /// Check whether the current pixel shader uses a texture unit.
     bool NeedTextureUnit(TextureUnit unit);
-    /// Clear remembered shader parameter sources
+    /// Clear remembered shader parameter sources.
     void ClearParameterSources();
-    /// Clear remembered transform shader parameter sources
+    /// Clear remembered transform shader parameter sources.
     void ClearTransformSources();
-    /// %Set texture
+    /// %Set texture.
     void SetTexture(unsigned index, Texture* texture);
-    /// %Set default texture filtering mode
+    /// %Set default texture filtering mode.
     void SetDefaultTextureFilterMode(TextureFilterMode mode);
-    /// %Set texture anisotropy
+    /// %Set texture anisotropy.
     void SetTextureAnisotropy(unsigned level);
-    /// Reset all render targets and depth buffer (render to back buffer and back buffer depth stencil)
+    /// Reset all render targets and depth buffer (render to back buffer and back buffer depth stencil.)
     void ResetRenderTargets();
-    /// Reset specific render target
+    /// Reset specific render target.
     void ResetRenderTarget(unsigned index);
-    /// Reset depth stencil
+    /// Reset depth stencil.
     void ResetDepthStencil();
-    /// %Set render target
+    /// %Set render target.
     void SetRenderTarget(unsigned index, RenderSurface* renderTarget);
-    /// %Set render target
+    /// %Set render target.
     void SetRenderTarget(unsigned index, Texture2D* renderTexture);
-    /// %Set depth stencil buffer
+    /// %Set depth stencil buffer.
     void SetDepthStencil(RenderSurface* depthStencil);
-    /// %Set depth stencil buffer
+    /// %Set depth stencil buffer.
     void SetDepthStencil(Texture2D* depthTexture);
-    /// %Set viewport
+    /// %Set viewport.
     void SetViewport(const IntRect& rect);
-    /// %Set "view texture" to prevent sampling from the destination render target
+    /// %Set deferred rendering destination render target to prevent sampling from it during G-buffer rendering.
     void SetViewTexture(Texture* texture);
-    /// %Set alpha test
+    /// %Set alpha test.
     void SetAlphaTest(bool enable, CompareMode mode = CMP_ALWAYS, float alphaRef = 0.5f);
-    /// %Set blending mode
+    /// %Set blending mode.
     void SetBlendMode(BlendMode mode);
-    /// %Set color write on/off
+    /// %Set color write on/off.
     void SetColorWrite(bool enable);
-    /// %Set hardware culling mode
+    /// %Set hardware culling mode.
     void SetCullMode(CullMode mode);
-    /// %Set depth bias
+    /// %Set depth bias.
     void SetDepthBias(float constantBias, float slopeScaledBias);
-    /// %Set depth compare
+    /// %Set depth compare.
     void SetDepthTest(CompareMode mode);
-    /// %Set depth write on/off
+    /// %Set depth write on/off.
     void SetDepthWrite(bool enable);
-    /// %Set polygon fill mode
+    /// %Set polygon fill mode.
     void SetFillMode(FillMode mode);
-    /// %Set scissor test
+    /// %Set scissor test.
     void SetScissorTest(bool enable, const Rect& rect = Rect::FULL, bool borderInclusive = true);
-    /// %Set scissor test
+    /// %Set scissor test.
     void SetScissorTest(bool enable, const IntRect& rect);
-    /// %Set stencil test
+    /// %Set stencil test.
     void SetStencilTest(bool enable, CompareMode mode = CMP_ALWAYS, StencilOp pass = OP_KEEP, StencilOp fail = OP_KEEP, StencilOp zFail = OP_KEEP, unsigned stencilRef = 0, unsigned stencilMask = M_MAX_UNSIGNED);
-    /// %Set vertex buffer stream frequency
+    /// %Set vertex buffer stream frequency.
     void SetStreamFrequency(unsigned index, unsigned frequency);
-    /// Reset stream frequencies
+    /// Reset stream frequencies.
     void ResetStreamFrequencies();
-    /// Begin immediate rendering command
+    /// Begin immediate rendering command.
     bool BeginImmediate(PrimitiveType type, unsigned vertexCount, unsigned elementMask);
-    /// Define immediate vertex
+    /// Define immediate vertex.
     bool DefineVertex(const Vector3& vertex);
-    /// Define immediate normal
+    /// Define immediate normal.
     bool DefineNormal(const Vector3& normal);
-    /// Define immediate texture coordinate
+    /// Define immediate texture coordinate.
     bool DefineTexCoord(const Vector2& texCoord);
-    /// Define immediate color
+    /// Define immediate color.
     bool DefineColor(const Color& color);
-    /// Define immediate color
+    /// Define immediate color.
     bool DefineColor(unsigned color);
-    /// End immediate rendering command and render
+    /// End immediate rendering command and render.
     void EndImmediate();
     /// %Set force Shader Model 2 flag. Needs to be set before setting initial screen mode to have effect.
     void SetForceSM2(bool enable);
     
-    /// Return whether rendering initialized
+    /// Return whether rendering initialized.
     bool IsInitialized() const;
-    /// Return graphics implementation, which holds the actual API-specific resources
+    /// Return graphics implementation, which holds the actual API-specific resources.
     GraphicsImpl* GetImpl() const { return impl_; }
-    /// Return window title
+    /// Return window title.
     const String& GetWindowTitle() const { return windowTitle_; }
-    /// Return rendering mode
+    /// Return rendering mode.
     RenderMode GetRenderMode() const { return mode_; }
-    /// Return window width
+    /// Return window width.
     int GetWidth() const { return width_; }
-    /// Return window height
+    /// Return window height.
     int GetHeight() const { return height_; }
-    /// Return multisample mode (1 = no multisampling)
+    /// Return multisample mode (1 = no multisampling.)
     int GetMultiSample() const { return multiSample_; }
-    /// Return whether window is fullscreen
+    /// Return whether window is fullscreen.
     bool GetFullscreen() const { return fullscreen_; }
-    /// Return whether vertical sync is on
+    /// Return whether vertical sync is on.
     bool GetVSync() const { return vsync_; }
-    /// Return whether GPU command queue is flushed at the end of each frame
+    /// Return whether GPU command queue is flushed at the end of each frame.
     bool GetFlushGPU() const { return flushGPU_; }
-    /// Return whether Direct3D device is lost, and can not yet render. This happens during fullscreen resolution switching
+    /// Return whether Direct3D device is lost, and can not yet render. This happens during fullscreen resolution switching.
     bool IsDeviceLost() const { return deviceLost_; }
-    /// Return immediate rendering data pointer
+    /// Return immediate rendering data pointer.
     unsigned char* GetImmediateDataPtr() const;
-    /// Return window handle
+    /// Return window handle.
     unsigned GetWindowHandle() const;
-    /// Return number of primitives drawn this frame
+    /// Return number of primitives drawn this frame.
     unsigned GetNumPrimitives() const { return numPrimitives_; }
-    /// Return number of batches drawn this frame
+    /// Return number of batches drawn this frame.
     unsigned GetNumBatches() const { return numBatches_; }
-    /// Return dummy color texture format for shadow maps. Is "NULL" (consume no video memory) if supported
+    /// Return dummy color texture format for shadow maps. Is "NULL" (consume no video memory) if supported.
     unsigned GetDummyColorFormat() const { return dummyColorFormat_; }
-    /// Return shadow map depth texture format, or 0 if not supported
+    /// Return shadow map depth texture format, or 0 if not supported.
     unsigned GetShadowMapFormat() const { return shadowMapFormat_; }
-    /// Return 24-bit shadow map depth texture format, or 0 if not supported
+    /// Return 24-bit shadow map depth texture format, or 0 if not supported.
     unsigned GetHiresShadowMapFormat() const { return hiresShadowMapFormat_; }
-    /// Return whether texture render targets are supported
+    /// Return whether texture render targets are supported.
     bool GetRenderTargetSupport() const { return renderTargetSupport_; }
-    /// Return whether deferred rendering is supported
+    /// Return whether deferred rendering is supported.
     bool GetDeferredSupport() const { return deferredSupport_; }
-    /// Return whether Shader Model 3 is supported
+    /// Return whether Shader Model 3 is supported.
     bool GetSM3Support() const { return hasSM3_; }
-    /// Return whether shadow map depth compare is done in hardware
+    /// Return whether shadow map depth compare is done in hardware.
     bool GetHardwareShadowSupport() const { return hardwareShadowSupport_; }
-    /// Return whether 24-bit shadow maps are supported
+    /// Return whether 24-bit shadow maps are supported.
     bool GetHiresShadowSupport() const { return hiresShadowSupport_; }
-    /// Return whether stream offset is supported
+    /// Return whether stream offset is supported.
     bool GetStreamOffsetSupport() const { return streamOffsetSupport_; }
-    /// Return supported fullscreen resolutions
+    /// Return supported fullscreen resolutions.
     PODVector<IntVector2> GetResolutions() const;
-    /// Return supported multisampling levels
+    /// Return supported multisampling levels.
     PODVector<int> GetMultiSampleLevels() const;
-    /// Return vertex buffer by index
+    /// Return vertex buffer by index.
     VertexBuffer* GetVertexBuffer(unsigned index) const;
-    /// Return index buffer
+    /// Return index buffer.
     IndexBuffer* GetIndexBuffer() const { return indexBuffer_; }
-    /// Return vertex declaration
+    /// Return vertex declaration.
     VertexDeclaration* GetVertexDeclaration() const { return vertexDeclaration_; }
-    /// Return vertex shader
+    /// Return vertex shader.
     ShaderVariation* GetVertexShader() const { return vertexShader_; }
-    /// Return pixel shader
+    /// Return pixel shader.
     ShaderVariation* GetPixelShader() const { return pixelShader_; }
-    /// Return texture unit index by name
+    /// Return texture unit index by name.
     TextureUnit GetTextureUnit(const String& name);
-    /// Return texture by texture unit index
+    /// Return texture by texture unit index.
     Texture* GetTexture(unsigned index) const;
-    /// Return the "view texture"
+    /// Return deferred rendering destination render target.
     Texture* GetViewTexture() const { return viewTexture_; }
-    /// Return default texture filtering mode
+    /// Return default texture filtering mode.
     TextureFilterMode GetDefaultTextureFilterMode() const { return defaultTextureFilterMode_; }
-    /// Return render target by index
+    /// Return render target by index.
     RenderSurface* GetRenderTarget(unsigned index) const;
-    /// Return depth stencil buffer
+    /// Return depth stencil buffer.
     RenderSurface* GetDepthStencil() const { return depthStencil_; }
-    /// Return the viewport coordinates
+    /// Return the viewport coordinates.
     IntRect GetViewport() const { return viewport_; }
-    /// Return whether alpha testing is enabled
+    /// Return whether alpha testing is enabled.
     bool GetAlphaTest() const { return alphaTest_; }
-    /// Return alpha test compare mode
+    /// Return alpha test compare mode.
     CompareMode GetAlphaTestMode() const { return alphaTestMode_; }
-    /// Return texture anisotropy
+    /// Return texture anisotropy.
     unsigned GetTextureAnisotropy() const { return textureAnisotropy_; }
-    /// Return alpha test reference value
+    /// Return alpha test reference value.
     float GetAlphaRef() const { return alphaRef_; }
-    /// Return blending mode
+    /// Return blending mode.
     BlendMode GetBlendMode() const { return blendMode_; }
-    /// Return whether color write is enabled
+    /// Return whether color write is enabled.
     bool GetColorWrite() const { return colorWrite_; }
-    /// Return hardware culling mode
+    /// Return hardware culling mode.
     CullMode GetCullMode() const { return cullMode_; }
-    /// Return depth constant bias
+    /// Return depth constant bias.
     float GetDepthConstantBias() const { return constantDepthBias_; }
-    /// Return depth slope scaled bias
+    /// Return depth slope scaled bias.
     float GetDepthSlopeScaledBias() const { return slopeScaledDepthBias_; }
-    /// Return depth compare mode
+    /// Return depth compare mode.
     CompareMode GetDepthTest() const { return depthTestMode_; }
-    /// Return whether depth write is enabled
+    /// Return whether depth write is enabled.
     bool GetDepthWrite() const { return depthWrite_; }
-    /// Return polygon fill mode
+    /// Return polygon fill mode.
     FillMode GetFillMode() const { return fillMode_; }
-    /// Return whether stencil test is enabled
+    /// Return whether stencil test is enabled.
     bool GetStencilTest() const { return stencilTest_; }
-    /// Return whether scissor test is enabled
+    /// Return whether scissor test is enabled.
     bool GetScissorTest() const { return scissorTest_; }
-    /// Return scissor rectangle coordinates
+    /// Return scissor rectangle coordinates.
     const IntRect& GetScissorRect() const { return scissorRect_; }
-    /// Return stencil compare mode
+    /// Return stencil compare mode.
     CompareMode GetStencilTestMode() const { return stencilTestMode_; }
-    /// Return stencil operation to do if stencil test passes
+    /// Return stencil operation to do if stencil test passes.
     StencilOp GetStencilPass() const { return stencilPass_; }
-    /// Return stencil operation to do if stencil test fails
+    /// Return stencil operation to do if stencil test fails.
     StencilOp GetStencilFail() const { return stencilFail_; }
-    /// Return stencil operation to do if depth compare fails
+    /// Return stencil operation to do if depth compare fails.
     StencilOp GetStencilZFail() const { return stencilZFail_; }
-    /// Return stencil reference value
+    /// Return stencil reference value.
     unsigned GetStencilRef() const { return stencilRef_; }
-    /// Return stencil compare bitmask
+    /// Return stencil compare bitmask.
     unsigned GetStencilMask() const { return stencilMask_; }
-    /// Return stream frequency by vertex buffer index
+    /// Return stream frequency by vertex buffer index.
     unsigned GetStreamFrequency(unsigned index) const;
-    /// Return render target width and height
+    /// Return render target width and height.
     IntVector2 GetRenderTargetDimensions() const;
-    /// Return diffuse buffer for deferred rendering
+    /// Return diffuse buffer for deferred rendering.
     Texture2D* GetDiffBuffer() const { return diffBuffer_; }
-    /// Return normal buffer for deferred rendering
+    /// Return normal buffer for deferred rendering.
     Texture2D* GetNormalBuffer() const { return normalBuffer_; }
-    /// Return depth buffer for deferred rendering. If reading hardware depth is supported, return a depth texture
+    /// Return depth buffer for deferred rendering. If reading hardware depth is supported, return a depth texture.
     Texture2D* GetDepthBuffer() const { return depthBuffer_; }
-    /// Return screen buffer for post-processing
+    /// Return screen buffer for post-processing.
     Texture2D* GetScreenBuffer() const { return screenBuffer_; }
     
     /// Add a GPU object to keep track of. Called by GPUObject.
     void AddGPUObject(GPUObject* object);
-    /// Remove a GPU object. Called by GPUObject
+    /// Remove a GPU object. Called by GPUObject.
     void RemoveGPUObject(GPUObject* object);
     
-    /// Return the API-specific alpha texture format
+    /// Return the API-specific alpha texture format.
     static unsigned GetAlphaFormat();
-    /// Return the API-specific luminance texture format
+    /// Return the API-specific luminance texture format.
     static unsigned GetLuminanceFormat();
-    /// Return the API-specific luminance alpha texture format
+    /// Return the API-specific luminance alpha texture format.
     static unsigned GetLuminanceAlphaFormat();
-    /// Return the API-specific RGB texture format
+    /// Return the API-specific RGB texture format.
     static unsigned GetRGBFormat();
-    /// Return the API-specific RGBA texture format
+    /// Return the API-specific RGBA texture format.
     static unsigned GetRGBAFormat();
-    /// Return the API-specific deferred rendering depth texture format
+    /// Return the API-specific deferred rendering depth texture format.
     static unsigned GetDepthFormat();
-    /// Return the API-specific depth stencil texture format
+    /// Return the API-specific depth stencil texture format.
     static unsigned GetDepthStencilFormat();
     
 private:
-    /// Create the application window
+    /// Create the application window.
     bool OpenWindow(int width, int height);
-    /// Adjust the window for new resolution and fullscreen mode
+    /// Adjust the window for new resolution and fullscreen mode.
     void AdjustWindow(int newWidth, int newHeight, bool newFullscreen);
-    /// Create the Direct3D interface
+    /// Create the Direct3D interface.
     bool CreateInterface();
-    /// Create the Direct3D device
+    /// Create the Direct3D device.
     bool CreateDevice(unsigned adapter, unsigned deviceType);
-    /// Create deferred rendering render targets
+    /// Create deferred rendering render targets.
     void CreateRenderTargets();
-    /// Reset the Direct3D device
+    /// Reset the Direct3D device.
     void ResetDevice();
-    /// Notify all GPU resources so they can release themselves as needed
+    /// Notify all GPU resources so they can release themselves as needed.
     void OnDeviceLost();
-    /// Notify all GPU resources so they can recreate themselves as needed
+    /// Notify all GPU resources so they can recreate themselves as needed.
     void OnDeviceReset();
-    /// Reset cached rendering state
+    /// Reset cached rendering state.
     void ResetCachedState();
-    /// Initialize texture unit mappings
+    /// Initialize texture unit mappings.
     void SetTextureUnitMappings();
-    /// Handle operating system window message
+    /// Handle operating system window message.
     void HandleWindowMessage(StringHash eventType, VariantMap& eventData);
     
-    /// Implementation
+    /// Implementation.
     GraphicsImpl* impl_;
-    /// Window title
+    /// Window title.
     String windowTitle_;
-    /// Rendering mode
+    /// Rendering mode.
     RenderMode mode_;
-    /// Window width
+    /// Window width.
     int width_;
-    /// Window height
+    /// Window height.
     int height_;
-    /// Multisampling mode
+    /// Multisampling mode.
     int multiSample_;
-    /// Stored window X-position
+    /// Stored window X-position.
     int windowPosX_;
-    /// Stored window Y-position
+    /// Stored window Y-position.
     int windowPosY_;
-    /// Fullscreen flag
+    /// Fullscreen flag.
     bool fullscreen_;
-    /// Vertical sync flag
+    /// Vertical sync flag.
     bool vsync_;
-    /// Flush GPU command queue flag
+    /// Flush GPU command queue flag.
     bool flushGPU_;
-    /// Direct3D device lost flag
+    /// Direct3D device lost flag.
     bool deviceLost_;
-    /// Query issued (used to flush the GPU command queue) flag
+    /// Query issued (used to flush the GPU command queue) flag.
     bool queryIssued_;
-    /// Texture render target support flag
+    /// Texture render target support flag.
     bool renderTargetSupport_;
-    /// Deferred rendering support flag
+    /// Deferred rendering support flag.
     bool deferredSupport_;
-    /// Hardware shadow map depth compare support flag
+    /// Hardware shadow map depth compare support flag.
     bool hardwareShadowSupport_;
-    /// 24-bit shadow map support flag
+    /// 24-bit shadow map support flag.
     bool hiresShadowSupport_;
-    /// Stream offset support flag
+    /// Stream offset support flag.
     bool streamOffsetSupport_;
-    /// Shader Model 3 flag
+    /// Shader Model 3 flag.
     bool hasSM3_;
-    /// Force Shader Model 2 flag
+    /// Force Shader Model 2 flag.
     bool forceSM2_;
-    /// Number of primitives this frame
+    /// Number of primitives this frame.
     unsigned numPrimitives_;
-    /// Number of batches this frame
+    /// Number of batches this frame.
     unsigned numBatches_;
-    /// Immediate rendering primitive type
+    /// Immediate rendering primitive type.
     PrimitiveType immediateType_;
-    /// Immediate vertex buffer start position
+    /// Immediate vertex buffer start position.
     unsigned immediateStartPos_;
-    /// Immediate rendering total number of vertices
+    /// Immediate rendering total number of vertices.
     unsigned immediateVertexCount_;
-    /// Immediate rendering current vertex number
+    /// Immediate rendering current vertex number.
     unsigned immediateCurrentVertex_;
-    /// Immediate rendering vertex buffer in use
+    /// Immediate rendering vertex buffer in use.
     VertexBuffer* immediateBuffer_;
-    /// Immediate rendering data pointer
+    /// Immediate rendering data pointer.
     unsigned char* immediateDataPtr_;
-    /// GPU objects
+    /// GPU objects.
     Vector<GPUObject*> gpuObjects_;
-    /// Vertex declarations
+    /// Vertex declarations.
     HashMap<unsigned long long, SharedPtr<VertexDeclaration> > vertexDeclarations_;
-    /// Immediate rendering vertex buffers by vertex declaration
+    /// Immediate rendering vertex buffers by vertex declaration.
     HashMap<unsigned, SharedPtr<VertexBuffer> > immediateVertexBuffers_;
-    /// Immediate rendering vertex buffer start positions
+    /// Immediate rendering vertex buffer start positions.
     HashMap<unsigned, unsigned> immediateVertexBufferPos_;
-    /// Deferred rendering diffuse buffer
+    /// Deferred rendering diffuse buffer.
     SharedPtr<Texture2D> diffBuffer_;
-    /// Deferred rendering normal buffer
+    /// Deferred rendering normal buffer.
     SharedPtr<Texture2D> normalBuffer_;
-    /// Deferred rendering depth buffer
+    /// Deferred rendering depth buffer.
     SharedPtr<Texture2D> depthBuffer_;
-    /// Screen buffer for post processing
+    /// Screen buffer for post processing.
     SharedPtr<Texture2D> screenBuffer_;
-    /// Shadow map dummy color texture format
+    /// Shadow map dummy color texture format.
     unsigned dummyColorFormat_;
-    /// Shadow map depth texture format
+    /// Shadow map depth texture format.
     unsigned shadowMapFormat_;
-    /// Shadow map 24-bit depth texture format
+    /// Shadow map 24-bit depth texture format.
     unsigned hiresShadowMapFormat_;
-    /// Vertex buffers in use
+    /// Vertex buffers in use.
     VertexBuffer* vertexBuffers_[MAX_VERTEX_STREAMS];
-    /// Stream frequencies by vertex buffer
+    /// Stream frequencies by vertex buffer.
     unsigned streamFrequencies_[MAX_VERTEX_STREAMS];
-    /// Stream offsets by vertex buffer
+    /// Stream offsets by vertex buffer.
     unsigned streamOffsets_[MAX_VERTEX_STREAMS];
-    /// Index buffer in use
+    /// Index buffer in use.
     IndexBuffer* indexBuffer_;
-    /// Vertex declaration in use
+    /// Vertex declaration in use.
     VertexDeclaration* vertexDeclaration_;
-    /// Vertex shader in use
+    /// Vertex shader in use.
     ShaderVariation* vertexShader_;
-    /// Pixel shader in use
+    /// Pixel shader in use.
     ShaderVariation* pixelShader_;
-    /// Shader parameters
+    /// Shader parameters.
     HashMap<StringHash, ShaderParameterInfo> shaderParameters_;
-    /// Textures in use
+    /// Textures in use.
     Texture* textures_[MAX_TEXTURE_UNITS];
-    /// "View texture" to prevent sampling the destination render target
+    /// Deferred rendering destination render target.
     Texture* viewTexture_;
-    /// Texture unit mappings
+    /// Texture unit mappings.
     HashMap<String, TextureUnit> textureUnits_;
-    /// Render targets in use
+    /// Render targets in use.
     RenderSurface* renderTargets_[MAX_RENDERTARGETS];
-    /// Depth stencil buffer in use
+    /// Depth stencil buffer in use.
     RenderSurface* depthStencil_;
-    /// Viewport coordinates
+    /// Viewport coordinates.
     IntRect viewport_;
-    /// Alpha test enable flag
+    /// Alpha test enable flag.
     bool alphaTest_;
-    /// Alpha test compare mode
+    /// Alpha test compare mode.
     CompareMode alphaTestMode_;
-    /// Alpha test reference value
+    /// Alpha test reference value.
     float alphaRef_;
-    /// Texture anisotropy level
+    /// Texture anisotropy level.
     unsigned textureAnisotropy_;
-    /// Blending mode
+    /// Blending mode.
     BlendMode blendMode_;
-    /// Color write enable
+    /// Color write enable.
     bool colorWrite_;
-    /// Hardware culling mode
+    /// Hardware culling mode.
     CullMode cullMode_;
-    /// Depth constant bias
+    /// Depth constant bias.
     float constantDepthBias_;
-    /// Depth slope scaled bias
+    /// Depth slope scaled bias.
     float slopeScaledDepthBias_;
-    /// Depth compare mode
+    /// Depth compare mode.
     CompareMode depthTestMode_;
-    /// Depth write enable flag
+    /// Depth write enable flag.
     bool depthWrite_;
-    /// Polygon fill mode
+    /// Polygon fill mode.
     FillMode fillMode_;
-    /// Scissor test rectangle
+    /// Scissor test rectangle.
     IntRect scissorRect_;
-    /// Scissor test enable flag
+    /// Scissor test enable flag.
     bool scissorTest_;
-    /// Stencil test compare mode
+    /// Stencil test compare mode.
     CompareMode stencilTestMode_;
-    /// Stencil operation on pass
+    /// Stencil operation on pass.
     StencilOp stencilPass_;
-    /// Stencil operation on fail
+    /// Stencil operation on fail.
     StencilOp stencilFail_;
-    /// Stencil operation on depth fail
+    /// Stencil operation on depth fail.
     StencilOp stencilZFail_;
-    /// Stencil test enable flag
+    /// Stencil test enable flag.
     bool stencilTest_;
-    /// Stencil test reference value
+    /// Stencil test reference value.
     unsigned stencilRef_;
-    /// Stencil compare bitmask
+    /// Stencil compare bitmask.
     unsigned stencilMask_;
-    /// Default texture filtering mode
+    /// Default texture filtering mode.
     TextureFilterMode defaultTextureFilterMode_;
 };
 
-/// Register Graphics library objects
+/// Register Graphics library objects.
 void RegisterGraphicsLibrary(Context* context);

+ 30 - 30
Engine/Graphics/Direct3D9/D3D9GraphicsImpl.h

@@ -34,67 +34,67 @@ class GraphicsImpl
     friend class Graphics;
     
 public:
-    /// Construct
+    /// Construct.
     GraphicsImpl();
     
-    /// Return Direct3D device
+    /// Return Direct3D device.
     IDirect3DDevice9* GetDevice() const { return device_; }
-    /// Return device capabilities
+    /// Return device capabilities.
     const D3DCAPS9& GetDeviceCaps() const { return deviceCaps_; }
-    /// Return window handle
+    /// Return window handle.
     HWND GetWindowHandle() const { return window_; }
-    /// Return adapter identifier
+    /// Return adapter identifier.
     const D3DADAPTER_IDENTIFIER9& GetAdapterIdentifier() const { return adapterIdentifier_; }
-    /// Return whether a texture format and usage is supported
+    /// Return whether a texture format and usage is supported.
     bool CheckFormatSupport(D3DFORMAT format, DWORD usage, D3DRESOURCETYPE type);
-    /// Return desktop texture format
+    /// Return desktop texture format.
     D3DFORMAT GetDesktopFormat();
-    /// Return desktop width/height
+    /// Return desktop width/height.
     IntVector2 GetDesktopResolution();
     
 private:
-    /// Direct3D interface
+    /// Direct3D interface.
     IDirect3D9* interface_;
-    /// Direct3D device
+    /// Direct3D device.
     IDirect3DDevice9* device_;
-    /// Default color surface
+    /// Default color surface.
     IDirect3DSurface9* defaultColorSurface_;
-    /// Default depth stencil surfac
+    /// Default depth stencil surface.
     IDirect3DSurface9* defaultDepthStencilSurface_;
-    /// Frame query for flushing the GPU command queue
+    /// Frame query for flushing the GPU command queue.
     IDirect3DQuery9* frameQuery_;
-    /// Adapter number
+    /// Adapter number.
     DWORD adapter_;
-    /// Device type
+    /// Device type.
     D3DDEVTYPE deviceType_;
-    /// Device capabilities
+    /// Device capabilities.
     D3DCAPS9 deviceCaps_;
-    /// Adapter identifier
+    /// Adapter identifier.
     D3DADAPTER_IDENTIFIER9 adapterIdentifier_;
-    /// Application instance
+    /// Application instance.
     HINSTANCE instance_;
-    /// Application window
+    /// Application window.
     HWND window_;
-    /// Direct3D presentation parameters
+    /// Direct3D presentation parameters.
     D3DPRESENT_PARAMETERS presentParams_;
-    /// Texture min/mag filter modes in use
+    /// Texture min/mag filter modes in use.
     D3DTEXTUREFILTERTYPE minMagFilters_[MAX_TEXTURE_UNITS];
-    /// Texture mip filter modes in use
+    /// Texture mip filter modes in use.
     D3DTEXTUREFILTERTYPE mipFilters_[MAX_TEXTURE_UNITS];
-    /// Texture U coordinate addressing modes in use
+    /// Texture U coordinate addressing modes in use.
     D3DTEXTUREADDRESS uAddressModes_[MAX_TEXTURE_UNITS];
-    /// Texture V coordinate addressing modes in use
+    /// Texture V coordinate addressing modes in use.
     D3DTEXTUREADDRESS vAddressModes_[MAX_TEXTURE_UNITS];
-    /// Texture border colors in use
+    /// Texture border colors in use.
     Color borderColors_[MAX_TEXTURE_UNITS];
-    /// Color surfaces in use
+    /// Color surfaces in use.
     IDirect3DSurface9* colorSurfaces_[MAX_RENDERTARGETS];
-    /// Depth stencil buffer in use
+    /// Depth stencil buffer in use.
     IDirect3DSurface9* depthStencilSurface_;
-    /// Blending enabled flag
+    /// Blending enabled flag.
     DWORD blendEnable_;
-    /// Source blend mode
+    /// Source blend mode.
     D3DBLEND srcBlend_;
-    /// Destination blend mode
+    /// Destination blend mode.
     D3DBLEND destBlend_;
 };

+ 28 - 38
Engine/Graphics/Direct3D9/D3D9IndexBuffer.cpp

@@ -71,14 +71,14 @@ void IndexBuffer::Release()
         if (!graphics_)
             return;
         
+        Unlock();
+        
         if (graphics_->GetIndexBuffer() == this)
             graphics_->SetIndexBuffer(0);
         
         ((IDirect3DIndexBuffer9*)object_)->Release();
         object_ = 0;
     }
-    
-    fallbackData_.Reset();
 }
 
 bool IndexBuffer::SetSize(unsigned indexCount, bool largeIndices, bool dynamic)
@@ -127,7 +127,7 @@ bool IndexBuffer::SetDataRange(const void* data, unsigned start, unsigned count)
 
 void* IndexBuffer::Lock(unsigned start, unsigned count, LockMode mode)
 {
-    if (!object_ && !fallbackData_)
+    if (!object_)
         return 0;
 
     if (locked_)
@@ -143,26 +143,20 @@ void* IndexBuffer::Lock(unsigned start, unsigned count, LockMode mode)
     }
     
     void* hwData = 0;
-    
-    if (object_)
-    {
-        DWORD flags = 0;
-        
-        if (mode == LOCK_DISCARD && usage_ & D3DUSAGE_DYNAMIC)
-            flags = D3DLOCK_DISCARD;
-        if (mode == LOCK_NOOVERWRITE && usage_ & D3DUSAGE_DYNAMIC)
-            flags = D3DLOCK_NOOVERWRITE;
-        if (mode == LOCK_READONLY)
-            flags = D3DLOCK_READONLY;
+    DWORD flags = 0;
+    
+    if (mode == LOCK_DISCARD && usage_ & D3DUSAGE_DYNAMIC)
+        flags = D3DLOCK_DISCARD;
+    if (mode == LOCK_NOOVERWRITE && usage_ & D3DUSAGE_DYNAMIC)
+        flags = D3DLOCK_NOOVERWRITE;
+    if (mode == LOCK_READONLY)
+        flags = D3DLOCK_READONLY;
         
-        if (FAILED(((IDirect3DIndexBuffer9*)object_)->Lock(start * indexSize_, count * indexSize_, &hwData, flags)))
-        {
-            LOGERROR("Could not lock index buffer");
-            return 0;
-        }
+    if (FAILED(((IDirect3DIndexBuffer9*)object_)->Lock(start * indexSize_, count * indexSize_, &hwData, flags)))
+    {
+        LOGERROR("Could not lock index buffer");
+        return 0;
     }
-    else
-        hwData = fallbackData_.Get() + start * indexSize_;
     
     locked_ = true;
     return hwData;
@@ -172,8 +166,7 @@ void IndexBuffer::Unlock()
 {
     if (locked_)
     {
-        if (object_)
-            ((IDirect3DIndexBuffer9*)object_)->Unlock();
+        ((IDirect3DIndexBuffer9*)object_)->Unlock();
         locked_ = false;
     }
 }
@@ -234,24 +227,21 @@ bool IndexBuffer::Create()
     
     if (!indexCount_)
         return true;
+    if (!graphics_)
+        return false;
     
-    if (graphics_)
+    IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
+    if (!device || FAILED(device->CreateIndexBuffer(
+        indexCount_ * indexSize_,
+        usage_,
+        indexSize_ == sizeof(unsigned) ? D3DFMT_INDEX32 : D3DFMT_INDEX16,
+        (D3DPOOL)pool_,
+        (IDirect3DIndexBuffer9**)&object_,
+        0)))
     {
-        IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
-        if (!device || FAILED(device->CreateIndexBuffer(
-            indexCount_ * indexSize_,
-            usage_,
-            indexSize_ == sizeof(unsigned) ? D3DFMT_INDEX32 : D3DFMT_INDEX16,
-            (D3DPOOL)pool_,
-            (IDirect3DIndexBuffer9**)&object_,
-            0)))
-        {
-            LOGERROR("Could not create index buffer");
-            return false;
-        }
+        LOGERROR("Could not create index buffer");
+        return false;
     }
-    else
-        fallbackData_ = new unsigned char[indexCount_ * indexSize_];
     
     return true;
 }

+ 23 - 25
Engine/Graphics/Direct3D9/D3D9IndexBuffer.h

@@ -34,58 +34,56 @@ class IndexBuffer : public Object, public GPUObject
     OBJECT(IndexBuffer);
     
 public:
-    /// Construct
+    /// Construct.
     IndexBuffer(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~IndexBuffer();
     
-    /// Release default pool resources
+    /// Release default pool resources.
     virtual void OnDeviceLost();
-    /// Recreate default pool resources
+    /// Recreate default pool resources.
     virtual void OnDeviceReset();
-    /// Release buffer
+    /// Release buffer.
     virtual void Release();
     
-    /// %Set buffer size and dynamic mode. Previous data will be lost
+    /// %Set buffer size and dynamic mode. Previous data will be lost.
     bool SetSize(unsigned indexCount, bool largeIndices, bool dynamic = false);
-    /// %Set all data in the buffer,
+    /// %Set all data in the buffer.
     bool SetData(const void* data);
-    /// %Set a data range in the buffer
+    /// %Set a data range in the buffer.
     bool SetDataRange(const void* data, unsigned start, unsigned count);
-    /// Lock a data range in the buffer. Return pointer to locked data if successful
+    /// Lock a data range in the buffer. Return pointer to locked data if successful.
     void* Lock(unsigned start, unsigned count, LockMode mode);
-    /// Unlock buffer
+    /// Unlock buffer.
     void Unlock();
-    /// Clear data lost flag
+    /// Clear data lost flag.
     void ClearDataLost();
     
-    /// Return whether is dynamic
+    /// Return whether is dynamic.
     bool IsDynamic() const;
-    /// Return whether default pool data lost
+    /// Return whether default pool data lost.
     bool IsDataLost() const { return dataLost_; }
-    /// Return number of indices
+    /// Return number of indices.
     unsigned GetIndexCount() const {return indexCount_; }
-    /// Return index size
+    /// Return index size.
     unsigned GetIndexSize() const { return indexSize_; }
-    /// Return used vertex range from index range
+    /// Return used vertex range from index range.
     bool GetUsedVertexRange(unsigned start, unsigned count, unsigned& minVertex, unsigned& vertexCount);
     
 private:
-    /// Create buffer
+    /// Create buffer.
     bool Create();
     
-    /// Fallback data when operating with a null graphics subsystem
-    SharedArrayPtr<unsigned char> fallbackData_;
-    /// Memory pool
+    /// Memory pool.
     unsigned pool_;
-    /// Usage type
+    /// Usage type.
     unsigned usage_;
-    /// Number of indices
+    /// Number of indices.
     unsigned indexCount_;
-    /// Index size
+    /// Index size.
     unsigned indexSize_;
-    /// Buffer locked flag
+    /// Buffer locked flag.
     bool locked_;
-    /// Default pool data lost flag
+    /// Default pool data lost flag.
     bool dataLost_;
 };

+ 25 - 25
Engine/Graphics/Direct3D9/D3D9RenderSurface.h

@@ -34,18 +34,18 @@ class Texture;
 /// Viewport definition either for a RenderSurface or the backbuffer
 struct Viewport
 {
-    /// Construct with defaults
+    /// Construct with defaults.
     Viewport();
-    /// Construct with a full rectangle
+    /// Construct with a full rectangle.
     Viewport(Scene* scene, Camera* camera);
-    /// Construct with a specified rectangle
+    /// Construct with a specified rectangle.
     Viewport(Scene* scene, Camera* camera, const IntRect& rect);
     
-    /// Scene pointer
+    /// Scene pointer.
     WeakPtr<Scene> scene_;
-    /// Camera pointer
+    /// Camera pointer.
     WeakPtr<Camera> camera_;
-    /// Viewport rectangle
+    /// Viewport rectangle.
     IntRect rect_;
 };
 
@@ -56,46 +56,46 @@ class RenderSurface : public RefCounted
     friend class TextureCube;
     
 public:
-    /// Construct with parent texture
+    /// Construct with parent texture.
     RenderSurface(Texture* parentTexture);
-    /// Destruct
+    /// Destruct.
     ~RenderSurface();
     
-    /// %Set viewport for auxiliary view rendering
+    /// %Set viewport for auxiliary view rendering.
     void SetViewport(const Viewport& viewport);
-    /// %Set linked color buffer
+    /// %Set linked color buffer.
     void SetLinkedRenderTarget(RenderSurface* renderTarget);
-    /// %Set linked depth buffer
+    /// %Set linked depth buffer.
     void SetLinkedDepthBuffer(RenderSurface* depthBuffer);
-    /// Release surface
+    /// Release surface.
     void Release();
     
-    /// Return parent texture
+    /// Return parent texture.
     Texture* GetParentTexture() const { return parentTexture_; }
-    /// Return Direct3D surface
+    /// Return Direct3D surface.
     void* GetSurface() const { return surface_; }
-    /// Return width
+    /// Return width.
     int GetWidth() const;
-    /// Return height
+    /// Return height.
     int GetHeight() const;
-    /// Return usage
+    /// Return usage.
     TextureUsage GetUsage() const;
-    /// Return auxiliary view rendering viewport
+    /// Return auxiliary view rendering viewport.
     const Viewport& GetViewport() const { return viewport_; }
-    /// Return linked color buffer
+    /// Return linked color buffer.
     RenderSurface* GetLinkedRenderTarget() const { return linkedRenderTarget_; }
-    /// Return linked depth buffer
+    /// Return linked depth buffer.
     RenderSurface* GetLinkedDepthBuffer() const { return linkedDepthBuffer_; }
     
 private:
-    /// Parent texture
+    /// Parent texture.
     Texture* parentTexture_;
-    /// Direct3D surface
+    /// Direct3D surface.
     void* surface_;
-    /// Viewport
+    /// Viewport.
     Viewport viewport_;
-    /// Linked color buffer
+    /// Linked color buffer.
     WeakPtr<RenderSurface> linkedRenderTarget_;
-    /// Linked depth buffer
+    /// Linked depth buffer.
     WeakPtr<RenderSurface> linkedDepthBuffer_;
 };

+ 13 - 13
Engine/Graphics/Direct3D9/D3D9Shader.h

@@ -33,35 +33,35 @@ class Shader : public Resource
     OBJECT(Shader);
     
 public:
-    /// Construct
+    /// Construct.
     Shader(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~Shader();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Load resource. Return true if successful
+    /// Load resource. Return true if successful.
     virtual bool Load(Deserializer& source);
     
-    /// Get a named variation. Return null if not found or could not be created
+    /// Get a named variation. Return null if not found or could not be created.
     ShaderVariation* GetVariation(const String& name);
-    /// Get a named variation. Return null if not found or could not be created
+    /// Get a named variation. Return null if not found or could not be created.
     ShaderVariation* GetVariation(StringHash nameHash);
-    /// Release (unload) all variations
+    /// Release (unload) all variations.
     void ReleaseAll();
     
-    /// Return shader type
+    /// Return shader type.
     ShaderType GetShaderType() const { return shaderType_; }
-    /// Return whether requires Shader Model 3
+    /// Return whether requires Shader Model 3.
     bool IsSM3() const { return isSM3_; }
-    /// Return number of variations
+    /// Return number of variations.
     unsigned GetNumVariations() const { return variations_.Size(); }
     
 private:
-    /// Shader type
+    /// Shader type.
     ShaderType shaderType_;
-    /// Shader Model 3 flag
+    /// Shader Model 3 flag.
     bool isSM3_;
-    /// Shader variations. Will be in an unloaded state until requested
+    /// Shader variations. Will be in an unloaded state until requested.
     Map<StringHash, SharedPtr<ShaderVariation> > variations_;
 };

+ 23 - 23
Engine/Graphics/Direct3D9/D3D9ShaderVariation.h

@@ -35,55 +35,55 @@ class Shader;
 class ShaderVariation : public RefCounted, public GPUObject
 {
 public:
-    /// Construct
+    /// Construct.
     ShaderVariation(Shader* shader, ShaderType type, bool isSM3);
-    /// Destruct
+    /// Destruct.
     virtual ~ShaderVariation();
     
-    /// Create the shader program. Return true if successful
+    /// Create the shader program. Return true if successful.
     bool Create();
-    /// Release shader
+    /// Release shader.
     virtual void Release();
     
-    /// %Set name
+    /// %Set name.
     void SetName(const String& name);
-    /// %Set bytecode
+    /// %Set bytecode.
     void SetByteCode(const SharedArrayPtr<unsigned char>& byteCode);
-    /// %Set to use a parameter
+    /// %Set to use a parameter.
     void SetUseParameter(StringHash param, bool enable);
-    /// %Set to use a texture unit
+    /// %Set to use a texture unit.
     void SetUseTextureUnit(TextureUnit unit, bool enable);
-    /// Clear parameter and texture unit use flags
+    /// Clear parameter and texture unit use flags.
     void ClearParameters();
     
-    /// Return shader type
+    /// Return shader type.
     ShaderType GetShaderType() const { return shaderType_; }
-    /// Return full shader name
+    /// Return full shader name.
     const String& GetName() const { return name_; }
-    /// Return whether created successfully
+    /// Return whether created successfully.
     bool IsCreated() const;
-    /// Return whether compile failed
+    /// Return whether compile failed.
     bool IsFailed() const { return failed_; }
-    /// Return whether requires Shader Model 3
+    /// Return whether requires Shader Model 3.
     bool IsSM3() const { return isSM3_; }
-    /// Return whether uses a specific shader parameter
+    /// Return whether uses a specific shader parameter.
     bool HasParameter(StringHash param) const { return useParameter_.Contains(param); }
-    /// Return whether uses a texture unit (only for pixel shaders)
+    /// Return whether uses a texture unit (only for pixel shaders.)
     bool HasTextureUnit(TextureUnit unit) const { return useTextureUnit_[unit]; }
     
 private:
-    /// Shader type
+    /// Shader type.
     ShaderType shaderType_;
-    /// Full shader name
+    /// Full shader name.
     String name_;
-    /// Shader bytecode
+    /// Shader bytecode.
     SharedArrayPtr<unsigned char> byteCode_;
-    /// Shader Model 3 flag
+    /// Shader Model 3 flag.
     bool isSM3_;
-    /// Compile failed flag
+    /// Compile failed flag.
     bool failed_;
-    /// Parameter use flags
+    /// Parameter use flags.
     HashSet<StringHash> useParameter_;
-    /// Texture unit use flags
+    /// Texture unit use flags.
     bool useTextureUnit_[MAX_TEXTURE_UNITS];
 };

+ 39 - 39
Engine/Graphics/Direct3D9/D3D9Texture.h

@@ -37,87 +37,87 @@ class XMLFile;
 class Texture : public Resource, public GPUObject
 {
 public:
-    /// Construct
+    /// Construct.
     Texture(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~Texture();
     
-    /// %Set number of requested mip levels. Needs to be called before setting size
+    /// %Set number of requested mip levels. Needs to be called before setting size.
     void SetNumLevels(unsigned levels);
-    /// %Set filtering mode
+    /// %Set filtering mode.
     void SetFilterMode(TextureFilterMode filter);
-    /// %Set addressing mode by texture coordinate
+    /// %Set addressing mode by texture coordinate.
     void SetAddressMode(TextureCoordinate coord, TextureAddressMode address);
-    /// %Set border color for border addressing mode
+    /// %Set border color for border addressing mode.
     void SetBorderColor(const Color& color);
-    /// %Set backup texture to use when rendering to this texture
+    /// %Set backup texture to use when rendering to this texture.
     void SetBackupTexture(Texture* texture);
-    /// Clear default pool data lost flag
+    /// Clear default pool data lost flag.
     void ClearDataLost();
     
-    /// Return texture format
+    /// Return texture format.
     unsigned GetFormat() const { return format_; }
-    /// Return number of mip levels
+    /// Return number of mip levels.
     unsigned GetLevels() const { return levels_; }
-    /// Return width
+    /// Return width.
     int GetWidth() const { return width_; }
-    /// Return height
+    /// Return height.
     int GetHeight() const { return height_; }
-    /// Return whether default pool data is lost
+    /// Return whether default pool data is lost.
     bool IsDataLost() const { return dataLost_; }
-    /// Return filtering mode
+    /// Return filtering mode.
     TextureFilterMode GetFilterMode() const { return filterMode_; }
-    /// Return addressing mode by texture coordinate
+    /// Return addressing mode by texture coordinate.
     TextureAddressMode GetAddressMode(TextureCoordinate coord) const { return addressMode_[coord]; }
-    /// Return border color
+    /// Return border color.
     const Color& GetBorderColor() const { return borderColor_; }
-    /// Return backup texture
+    /// Return backup texture.
     Texture* GetBackupTexture() const { return backupTexture_; }
-    /// Return mip level width, or 0 if level does not exist
+    /// Return mip level width, or 0 if level does not exist.
     int GetLevelWidth(unsigned level) const;
-    /// Return mip level width, or 0 if level does not exist
+    /// Return mip level width, or 0 if level does not exist.
     int GetLevelHeight(unsigned level) const;
-    /// Return texture usage type
+    /// Return texture usage type.
     TextureUsage GetUsage() const;
-    /// Return data size in bytes for a rectangular region
+    /// Return data size in bytes for a rectangular region.
     unsigned GetDataSize(int width, int height) const;
-    /// Return data size in bytes for a pixel or block row
+    /// Return data size in bytes for a pixel or block row.
     unsigned GetRowDataSize(int width) const;
-    /// Return API-specific DXT compressed texture format
+    /// Return API-specific DXT compressed texture format.
     static unsigned GetDXTFormat(CompressedFormat format);
     
 protected:
-    /// Load parameters
+    /// Load parameters.
     void LoadParameters();
-    /// Load parameters from an XML file
+    /// Load parameters from an XML file.
     void LoadParameters(XMLFile* xml);
-    /// Check whether texture memory budget has been exceeded. Free unused materials in that case to release the texture references
+    /// Check whether texture memory budget has been exceeded. Free unused materials in that case to release the texture references.
     void CheckTextureBudget(ShortStringHash type);
     
-    /// Texture format
+    /// Texture format.
     unsigned format_;
-    /// Memory pool
+    /// Memory pool.
     unsigned pool_;
-    /// Texture usage type
+    /// Texture usage type.
     unsigned usage_;
-    /// Current mip levels
+    /// Current mip levels.
     unsigned levels_;
-    /// Requested mip levels
+    /// Requested mip levels.
     unsigned requestedLevels_;
-    /// Texture width
+    /// Texture width.
     int width_;
-    /// Texture height
+    /// Texture height.
     int height_;
-    /// Default pool data lost flag
+    /// Default pool data lost flag.
     bool dataLost_;
-    /// Filtering mode
+    /// Filtering mode.
     TextureFilterMode filterMode_;
-    /// Addressing mode
+    /// Addressing mode.
     TextureAddressMode addressMode_[MAX_COORDS];
-    /// Mipmaps to skip when loading
+    /// Mipmaps to skip when loading.
     unsigned mipsToSkip_[MAX_TEXTURE_QUALITY_LEVELS];
-    /// Border color
+    /// Border color.
     Color borderColor_;
-    /// Backup texture
+    /// Backup texture.
     SharedPtr<Texture> backupTexture_;
 };

+ 15 - 15
Engine/Graphics/Direct3D9/D3D9Texture2D.h

@@ -35,40 +35,40 @@ class Texture2D : public Texture
     OBJECT(Texture2D);
     
 public:
-    /// Construct
+    /// Construct.
     Texture2D(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~Texture2D();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Load resource. Return true if successful
+    /// Load resource. Return true if successful.
     virtual bool Load(Deserializer& source);
-    /// Release default pool resources
+    /// Release default pool resources.
     virtual void OnDeviceLost();
-    /// Recreate default pool resources
+    /// Recreate default pool resources.
     virtual void OnDeviceReset();
-    /// Release texture
+    /// Release texture.
     virtual void Release();
     
-    /// %Set size, format and usage. Zero size will follow application window size. Return true if successful
+    /// %Set size, format and usage. Zero size will follow application window size. Return true if successful.
     bool SetSize(int width, int height, unsigned format, TextureUsage usage = TEXTURE_STATIC);
-    /// %Set data either partially or fully on a mip level. Return true if successful
+    /// %Set data either partially or fully on a mip level. Return true if successful.
     bool SetData(unsigned level, int x, int y, int width, int height, const void* data);
-    /// Load from an image. Return true if successful
+    /// Load from an image. Return true if successful.
     bool Load(SharedPtr<Image> image, bool useAlpha = false);
     
-    /// Get data from a mip level. The destination buffer must be big enough. Return true if successful
+    /// Get data from a mip level. The destination buffer must be big enough. Return true if successful.
     bool GetData(unsigned level, void* dest) const;
-    /// Return render surface
+    /// Return render surface.
     RenderSurface* GetRenderSurface() const { return renderSurface_; }
     
 private:
-    /// Create texture
+    /// Create texture.
     bool Create();
     
-    /// Render surface
+    /// Render surface.
     SharedPtr<RenderSurface> renderSurface_;
-    /// Follow window size flag
+    /// Follow window size flag.
     bool followWindowSize_;
 };

+ 18 - 18
Engine/Graphics/Direct3D9/D3D9TextureCube.h

@@ -36,46 +36,46 @@ class TextureCube : public Texture
     OBJECT(TextureCube);
     
 public:
-    /// Construct
+    /// Construct.
     TextureCube(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~TextureCube();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Load resource. Return true if successful
+    /// Load resource. Return true if successful.
     virtual bool Load(Deserializer& source);
-    /// Release default pool resources
+    /// Release default pool resources.
     virtual void OnDeviceLost();
-    /// ReCreate default pool resources
+    /// ReCreate default pool resources.
     virtual void OnDeviceReset();
-    /// Release texture
+    /// Release texture.
     virtual void Release();
     
-    /// %Set size, format and usage. Return true if successful
+    /// %Set size, format and usage. Return true if successful.
     bool SetSize(int size, unsigned format, TextureUsage usage = TEXTURE_STATIC);
-    /// %Set data either partially or fully on a face's mip level. Return true if successful
+    /// %Set data either partially or fully on a face's mip level. Return true if successful.
     bool SetData(CubeMapFace face, unsigned level, int x, int y, int width, int height, const void* data);
-    /// Load one face from a stream. Return true if successful
+    /// Load one face from a stream. Return true if successful.
     bool Load(CubeMapFace face, Deserializer& source);
-    /// Load one face from an image. Return true if successful
+    /// Load one face from an image. Return true if successful.
     bool Load(CubeMapFace face, SharedPtr<Image> image, bool useAlpha = false);
     
-    /// Get data from a face's mip level. The destination buffer must be big enough. Return true if successful
+    /// Get data from a face's mip level. The destination buffer must be big enough. Return true if successful.
     bool GetData(CubeMapFace face, unsigned level, void* dest) const;
-    /// Return render surface for one face
+    /// Return render surface for one face.
     RenderSurface* GetRenderSurface(CubeMapFace face) const { return renderSurfaces_[face]; }
     
 private:
-    /// Create texture
+    /// Create texture.
     bool Create();
     
-    /// Render surfaces
+    /// Render surfaces.
     SharedPtr<RenderSurface> renderSurfaces_[MAX_CUBEMAP_FACES];
-    /// Memory use per face
+    /// Memory use per face.
     unsigned faceMemoryUse_[MAX_CUBEMAP_FACES];
-    /// Currently locked mip level
+    /// Currently locked mip level.
     int lockedLevel_;
-    /// Currently locked face
+    /// Currently locked face.
     CubeMapFace lockedFace_;
 };

+ 27 - 37
Engine/Graphics/Direct3D9/D3D9VertexBuffer.cpp

@@ -107,6 +107,8 @@ void VertexBuffer::Release()
         if (!graphics_)
             return;
         
+        Unlock();
+        
         for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
         {
             if (graphics_->GetVertexBuffer(i) == this)
@@ -116,8 +118,6 @@ void VertexBuffer::Release()
         ((IDirect3DVertexBuffer9*)object_)->Release();
         object_ = 0;
     }
-    
-    fallbackData_.Reset();
 }
 
 bool VertexBuffer::SetSize(unsigned vertexCount, unsigned elementMask, bool dynamic)
@@ -191,7 +191,7 @@ void VertexBuffer::SetMorphRangeResetData(const SharedArrayPtr<unsigned char>& d
 
 void* VertexBuffer::Lock(unsigned start, unsigned count, LockMode mode)
 {
-    if (!object_ && !fallbackData_)
+    if (!object_)
         return 0;
 
     if (locked_)
@@ -207,26 +207,20 @@ void* VertexBuffer::Lock(unsigned start, unsigned count, LockMode mode)
     }
     
     void* hwData = 0;
+    DWORD flags = 0;
     
-    if (object_)
+    if (mode == LOCK_DISCARD && usage_ & D3DUSAGE_DYNAMIC)
+        flags = D3DLOCK_DISCARD;
+    if (mode == LOCK_NOOVERWRITE && usage_ & D3DUSAGE_DYNAMIC)
+        flags = D3DLOCK_NOOVERWRITE;
+    if (mode == LOCK_READONLY)
+        flags = D3DLOCK_READONLY;
+    
+    if (FAILED(((IDirect3DVertexBuffer9*)object_)->Lock(start * vertexSize_, count * vertexSize_, &hwData, flags)))
     {
-        DWORD flags = 0;
-        
-        if (mode == LOCK_DISCARD && usage_ & D3DUSAGE_DYNAMIC)
-            flags = D3DLOCK_DISCARD;
-        if (mode == LOCK_NOOVERWRITE && usage_ & D3DUSAGE_DYNAMIC)
-            flags = D3DLOCK_NOOVERWRITE;
-        if (mode == LOCK_READONLY)
-            flags = D3DLOCK_READONLY;
-        
-        if (FAILED(((IDirect3DVertexBuffer9*)object_)->Lock(start * vertexSize_, count * vertexSize_, &hwData, flags)))
-        {
-            LOGERROR("Could not lock vertex buffer");
-            return 0;
-        }
+        LOGERROR("Could not lock vertex buffer");
+        return 0;
     }
-    else
-        hwData = fallbackData_.Get() + start * vertexSize_;
     
     locked_ = true;
     return hwData;
@@ -236,8 +230,7 @@ void VertexBuffer::Unlock()
 {
     if (locked_)
     {
-        if (object_)
-            ((IDirect3DVertexBuffer9*)object_)->Unlock();
+        ((IDirect3DVertexBuffer9*)object_)->Unlock();
         locked_ = false;
     }
 }
@@ -321,24 +314,21 @@ bool VertexBuffer::Create()
     
     if (!vertexCount_ || !elementMask_)
         return true;
+    if (!graphics_)
+        return false;
     
-    if (graphics_)
+    IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
+    if (!device || FAILED(device->CreateVertexBuffer(
+        vertexCount_ * vertexSize_,
+        usage_,
+        0,
+        (D3DPOOL)pool_,
+        (IDirect3DVertexBuffer9**)&object_,
+        0)))
     {
-        IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
-        if (!device || FAILED(device->CreateVertexBuffer(
-            vertexCount_ * vertexSize_,
-            usage_,
-            0,
-            (D3DPOOL)pool_,
-            (IDirect3DVertexBuffer9**)&object_,
-            0)))
-        {
-            LOGERROR("Could not create vertex buffer");
-            return false;
-        }
+        LOGERROR("Could not create vertex buffer");
+        return false;
     }
-    else
-        fallbackData_ = new unsigned char[vertexCount_ * vertexSize_];
     
     return true;
 }

+ 42 - 44
Engine/Graphics/Direct3D9/D3D9VertexBuffer.h

@@ -33,98 +33,96 @@ class VertexBuffer : public Object, public GPUObject
     OBJECT(VertexBuffer);
     
 public:
-    /// Construct
+    /// Construct.
     VertexBuffer(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~VertexBuffer();
     
-    /// Release default pool resources
+    /// Release default pool resources.
     virtual void OnDeviceLost();
-    /// ReCreate default pool resources
+    /// ReCreate default pool resources.
     virtual void OnDeviceReset();
-    /// Release buffer
+    /// Release buffer.
     virtual void Release();
     
-    /// %Set size and vertex elements and dynamic mode. Previous data will be lost
+    /// %Set size and vertex elements and dynamic mode. Previous data will be lost.
     bool SetSize(unsigned vertexCount, unsigned elementMask, bool dynamic = false);
-    /// %Set all data in the buffer
+    /// %Set all data in the buffer.
     bool SetData(const void* data);
-    /// %Set a data range in the buffer
+    /// %Set a data range in the buffer.
     bool SetDataRange(const void* data, unsigned first, unsigned count);
-    /// %Set the vertex range to use for morphing
+    /// %Set the vertex range to use for morphing.
     bool SetMorphRange(unsigned start, unsigned count);
-    /// %Set data to be used for resetting the morph vertex range
+    /// %Set data to be used for resetting the morph vertex range.
     void SetMorphRangeResetData(const SharedArrayPtr<unsigned char>& data);
-    /// Lock a data range in the buffer. Return pointer to locked data if successful
+    /// Lock a data range in the buffer. Return pointer to locked data if successful.
     void* Lock(unsigned start, unsigned count, LockMode mode);
-    /// Unlock buffer
+    /// Unlock buffer.
     void Unlock();
-    /// Lock the morph vertex range. Return pointer to locked data if successful
+    /// Lock the morph vertex range. Return pointer to locked data if successful.
     void* LockMorphRange();
-    /// Reset the morph vertex range. Needs to be locked first
+    /// Reset the morph vertex range. Needs to be locked first.
     void ResetMorphRange(void* lockedMorphRange);
-    /// Clear data lost flag
+    /// Clear data lost flag.
     void ClearDataLost();
     
-    /// Return whether is dynamic
+    /// Return whether is dynamic.
     bool IsDynamic() const;
-    /// Return whether default pool data lost
+    /// Return whether default pool data lost.
     bool IsDataLost() const { return dataLost_; }
-    /// Return number of vertices
+    /// Return number of vertices.
     unsigned GetVertexCount() const {return vertexCount_; }
-    /// Return vertex size
+    /// Return vertex size.
     unsigned GetVertexSize() const { return vertexSize_; }
-    /// Return bitmask of vertex elements
+    /// Return bitmask of vertex elements.
     unsigned GetElementMask() const { return elementMask_; }
-    /// Return offset of a specified element within a vertex
+    /// Return offset of a specified element within a vertex.
     unsigned GetElementOffset(VertexElement element) const { return elementOffset_[element]; }
-    /// Return morph vertex range start
+    /// Return morph vertex range start.
     unsigned GetMorphRangeStart() const { return morphRangeStart_; }
-    /// Return number of vertices in the morph range
+    /// Return number of vertices in the morph range.
     unsigned GetMorphRangeCount() const { return morphRangeCount_; }
-    /// Return morph vertex range reset data
+    /// Return morph vertex range reset data.
     const SharedArrayPtr<unsigned char>& GetMorphRangeResetData() { return morphRangeResetData_; }
-    /// Return whether has a morph vertex range defined
+    /// Return whether has a morph vertex range defined.
     bool HasMorphRange() const { return morphRangeCount_ > 0; }
-    /// Return buffer hash for state sorting
+    /// Return buffer hash for state sorting.
     unsigned long long GetHash(unsigned streaindex_, unsigned useMask);
     
-    /// Return vertex size corresponding to a vertex element mask
+    /// Return vertex size corresponding to a vertex element mask.
     static unsigned GetVertexSize(unsigned elementMask);
     
-    /// Vertex element sizes
+    /// Vertex element sizes.
     static const unsigned elementSize[];
-    /// Vertex element names
+    /// Vertex element names.
     static const String elementName[];
     
 private:
-    /// Update offsets of vertex elements
+    /// Update offsets of vertex elements.
     void UpdateOffsets();
-    /// Create buffer
+    /// Create buffer.
     bool Create();
     
-    /// Fallback data when operating with a null graphics subsystem
-    SharedArrayPtr<unsigned char> fallbackData_;
-    /// Morph vertex range reset data
+    /// Morph vertex range reset data.
     SharedArrayPtr<unsigned char> morphRangeResetData_;
-    /// Memory pool
+    /// Memory pool.
     unsigned pool_;
-    /// Usage type
+    /// Usage type.
     unsigned usage_;
-    /// Number of vertices
+    /// Number of vertices.
     unsigned vertexCount_;
-    /// Vertex size
+    /// Vertex size.
     unsigned vertexSize_;
-    /// Vertex element bitmask
+    /// Vertex element bitmask.
     unsigned elementMask_;
-    /// Vertex element offsets
+    /// Vertex element offsets.
     unsigned elementOffset_[MAX_VERTEX_ELEMENTS];
-    /// Morph vertex range start
+    /// Morph vertex range start.
     unsigned morphRangeStart_;
-    /// Number of vertices in the morph range
+    /// Number of vertices in the morph range.
     unsigned morphRangeCount_;
-    /// Locked flag
+    /// Locked flag.
     bool locked_;
-    /// Default pool data lost flag
+    /// Default pool data lost flag.
     bool dataLost_;
 };

+ 11 - 11
Engine/Graphics/Direct3D9/D3D9VertexDeclaration.h

@@ -35,11 +35,11 @@ class VertexBuffer;
 /// Element in the vertex declaration
 struct VertexDeclarationElement
 {
-    /// Stream index
+    /// Stream index.
     unsigned stream_;
-    /// Element type
+    /// Element type.
     VertexElement element_;
-    /// Element offset
+    /// Element offset.
     unsigned offset_;
 };
 
@@ -47,24 +47,24 @@ struct VertexDeclarationElement
 class VertexDeclaration : public RefCounted
 {
 public:
-    /// Construct with graphics subsystem pointer and vertex element mask
+    /// Construct with graphics subsystem pointer and vertex element mask.
     VertexDeclaration(Graphics* graphics, unsigned elementMask);
-    /// Construct with graphics subsystem pointer and vertex buffers to base declaration on
+    /// Construct with graphics subsystem pointer and vertex buffers to base declaration on.
     VertexDeclaration(Graphics* graphics, const Vector<VertexBuffer*>& buffers, const PODVector<unsigned>& elementMasks);
-    /// Construct with graphics subsystem pointer and vertex buffers to base declaration on
+    /// Construct with graphics subsystem pointer and vertex buffers to base declaration on.
     VertexDeclaration(Graphics* graphics, const Vector<SharedPtr<VertexBuffer> >& buffers, const PODVector<unsigned>& elementMasks);
-    /// Destruct
+    /// Destruct.
     ~VertexDeclaration();
     
-    /// Return Direct3D vertex declaration
+    /// Return Direct3D vertex declaration.
     IDirect3DVertexDeclaration9* GetDeclaration() const { return declaration_; }
     
 private:
-    /// Create declaration
+    /// Create declaration.
     void Create(Graphics* graphics, const PODVector<VertexDeclarationElement>& elements);
-    /// Release declaration
+    /// Release declaration.
     void Release();
     
-    /// Direct3D vertex declaration
+    /// Direct3D vertex declaration.
     IDirect3DVertexDeclaration9* declaration_;
 };

+ 80 - 80
Engine/Graphics/Drawable.h

@@ -45,20 +45,20 @@ class OcclusionBuffer;
 class Octant;
 class RayOctreeQuery;
 
-/// Rendering frame update parameters
+/// Rendering frame update parameters.
 struct FrameInfo
 {
-    /// Frame number
+    /// Frame number.
     unsigned frameNumber_;
-    /// Time elapsed since last frame
+    /// Time elapsed since last frame.
     float timeStep_;
-    /// Viewport size
+    /// Viewport size.
     IntVector2 viewSize_;
-    /// Camera being used
+    /// Camera being used.
     Camera* camera_;
 };
 
-/// Base class for visible components
+/// Base class for visible components.
 class Drawable : public Component
 {
     OBJECT(Drawable);
@@ -66,160 +66,160 @@ class Drawable : public Component
     friend class Octant;
     
 public:
-    /// Construct
+    /// Construct.
     Drawable(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~Drawable();
-    /// Register object attributes. Drawable must be registered first
+    /// Register object attributes. Drawable must be registered first.
     static void RegisterObject(Context* context);
     
-    /// Process octree raycast
+    /// Process octree raycast.
     virtual void ProcessRayQuery(RayOctreeQuery& query, float initialDistance);
-    /// Update before octree reinsertion. Needs to be requested with MarkForUpdate()
+    /// Update before octree reinsertion. Needs to be requested with MarkForUpdate().
     virtual void Update(const FrameInfo& frame) {}
-    /// Calculate distance for rendering
+    /// Calculate distance for rendering.
     virtual void UpdateDistance(const FrameInfo& frame);
-    /// Prepare geometry for rendering
+    /// Prepare geometry for rendering.
     virtual void UpdateGeometry(const FrameInfo& frame) {}
-    /// Return number of rendering batches
+    /// Return number of rendering batches.
     virtual unsigned GetNumBatches() { return 0; }
-    /// Return rendering batch
+    /// Return rendering batch.
     virtual void GetBatch(const FrameInfo& frame, unsigned batchIndex, Batch& batch) {}
-    /// Draw to occlusion buffer
+    /// Draw to occlusion buffer.
     virtual bool DrawOcclusion(OcclusionBuffer* buffer) { return true; }
-    /// Draw debug geometry
+    /// Draw debug geometry.
     virtual void DrawDebugGeometry(DebugRenderer* debug, bool depthTest);
     
-    /// %Set draw distance
+    /// %Set draw distance.
     void SetDrawDistance(float distance);
-    /// %Set shadow draw distance
+    /// %Set shadow draw distance.
     void SetShadowDistance(float distance);
-    /// %Set LOD bias
+    /// %Set LOD bias.
     void SetLodBias(float bias);
-    /// %Set view mask. Will be and'ed with camera's view mask to see if the object should be rendered
+    /// %Set view mask. Will be and'ed with camera's view mask to see if the object should be rendered.
     void SetViewMask(unsigned mask);
-    /// %Set light mask. Will be and'ed with light's light mask to see if the object should be lit
+    /// %Set light mask. Will be and'ed with light's light mask to see if the object should be lit.
     void SetLightMask(unsigned mask);
-    /// %Set maximum number of lights (forward lighting only). Default 0 is unlimited
+    /// %Set maximum number of lights (forward lighting only). Default 0 is unlimited.
     void SetMaxLights(unsigned num);
-    /// %Set visible flag
+    /// %Set visible flag.
     void SetVisible(bool enable);
-    /// %Set shadowcaster flag
+    /// %Set shadowcaster flag.
     void SetCastShadows(bool enable);
-    /// %Set occlusion flag
+    /// %Set occlusion flag.
     void SetOccluder(bool enable);
-    /// Mark for update before octree reinsertion
+    /// Mark for update before octree reinsertion.
     void MarkForUpdate();
     
-    /// Return world bounding box
+    /// Return world bounding box.
     const BoundingBox& GetWorldBoundingBox();
-    /// Return drawable flags
+    /// Return drawable flags.
     unsigned char GetDrawableFlags() const { return drawableFlags_; }
-    /// Return draw distance
+    /// Return draw distance.
     float GetDrawDistance() const { return drawDistance_; }
-    /// Return shadow draw distance
+    /// Return shadow draw distance.
     float GetShadowDistance() const { return shadowDistance_; }
-    /// Return LOD bias
+    /// Return LOD bias.
     float GetLodBias() const { return lodBias_; }
-    /// Return view mask
+    /// Return view mask.
     unsigned GetViewMask() const { return viewMask_; }
-    /// Return light mask
+    /// Return light mask.
     unsigned GetLightMask() const { return lightMask_; }
-    /// Return maximum number of lights
+    /// Return maximum number of lights.
     unsigned GetMaxLights() const { return maxLights_; }
-    /// Return visible flag
+    /// Return visible flag.
     bool IsVisible() const { return visible_; }
-    /// Return shadowcaster flag
+    /// Return shadowcaster flag.
     bool GetCastShadows() const { return castShadows_; }
-    /// Return occlusion flag
+    /// Return occlusion flag.
     bool IsOccluder() const { return occluder_; }
     
-    /// Return octree octant
+    /// Return octree octant.
     Octant* GetOctant() const { return octant_; }
-    /// %Set sorting value. Called by View
+    /// %Set sorting value. Called by View.
     void SetSortValue(float value);
-    /// Mark in view this frame. Called by View
+    /// Mark in view this frame. Called by View.
     void MarkInView(const FrameInfo& frame);
-    /// Mark in a shadow camera view this frame. If an actual view is already set, does not override it. Called by View
+    /// Mark in a shadow camera view this frame. If an actual view is already set, does not override it. Called by View.
     void MarkInShadowView(const FrameInfo& frame);
-    /// Clear base pass flags. Also resets light vector
+    /// Clear base pass flags. Also resets light vector.
     void ClearBasePass();
-    /// %Set base pass flag for a batch
+    /// %Set base pass flag for a batch.
     void SetBasePass(unsigned batchIndex);
-    /// Add a light, for drawables that limit the maximum light count
+    /// Add a light, for drawables that limit the maximum light count.
     void AddLight(Light* light);
-    /// Sort and limit lights to maximum allowed
+    /// Sort and limit lights to maximum allowed.
     void LimitLights();
-    /// Return distance from camera
+    /// Return distance from camera.
     float GetDistance() const { return distance_; }
-    /// Return LOD scaled distance from camera
+    /// Return LOD scaled distance from camera.
     float GetLodDistance() const { return lodDistance_; }
-    /// Return sorting value
+    /// Return sorting value.
     float GetSortValue() const { return sortValue_; }
-    /// Return whether is in view this frame
+    /// Return whether is in view this frame.
     bool IsInView(unsigned frameNumber) const;
-    /// Return whether is visible in a specific view this frame
+    /// Return whether is visible in a specific view this frame.
     bool IsInView(const FrameInfo& frame) const;
-    /// Return whether has a base pass
+    /// Return whether has a base pass.
     bool HasBasePass(unsigned batchIndex) const { return (basePassFlags_ & (1 << batchIndex)) != 0; }
-    /// Return lights
+    /// Return lights.
     const PODVector<Light*>& GetLights() const { return lights_; }
     
 protected:
-    /// Handle node being assigned
+    /// Handle node being assigned.
     virtual void OnNodeSet(Node* node);
-    /// Handle node transform being dirtied
+    /// Handle node transform being dirtied.
     virtual void OnMarkedDirty(Node* node);
-    /// Recalculate world bounding box
+    /// Recalculate world bounding box.
     virtual void OnWorldBoundingBoxUpdate() = 0;
-    /// Add to octree
+    /// Add to octree.
     void AddToOctree();
-    /// Remove from octree
+    /// Remove from octree.
     void RemoveFromOctree();
-    /// Move into another octree octant
+    /// Move into another octree octant.
     void SetOctant(Octant* octant) { octant_ = octant; }
     
-    /// Octree octant
+    /// Octree octant.
     Octant* octant_;
-    /// World bounding box
+    /// World bounding box.
     BoundingBox worldBoundingBox_;
-    /// Draw distance
+    /// Draw distance.
     float drawDistance_;
-    /// Shadow distance
+    /// Shadow distance.
     float shadowDistance_;
-    /// LOD bias
+    /// LOD bias.
     float lodBias_;
-    /// View mask
+    /// View mask.
     unsigned viewMask_;
-    /// Light mask
+    /// Light mask.
     unsigned lightMask_;
-    /// Maximum lights
+    /// Maximum lights.
     unsigned maxLights_;
-    /// Drawable flags
+    /// Drawable flags.
     unsigned char drawableFlags_;
-    /// Visible flag
+    /// Visible flag.
     bool visible_;
-    /// Shadowcaster flag
+    /// Shadowcaster flag.
     bool castShadows_;
-    /// Occluder flag
+    /// Occluder flag.
     bool occluder_;
-    /// Current distance to camera
+    /// Current distance to camera.
     float distance_;
-    /// LOD scaled distance
+    /// LOD scaled distance.
     float lodDistance_;
-    /// Current sort value
+    /// Current sort value.
     float sortValue_;
-    /// Last visible frame number
+    /// Last visible frame number.
     unsigned viewFrameNumber_;
-    /// Base pass flags per batch index
+    /// Base pass flags per batch index.
     unsigned basePassFlags_;
-    /// Last camera rendered from. Not safe to dereference
+    /// Last camera rendered from. Not safe to dereference.
     Camera* viewCamera_;
-    /// Lights affecting this drawable, when light count is limited
+    /// Lights affecting this drawable, when light count is limited.
     PODVector<Light*> lights_;
-    /// Bounding box dirty flag
+    /// Bounding box dirty flag.
     bool worldBoundingBoxDirty_;
-    /// Lod levels dirty flag
+    /// Lod levels dirty flag.
     bool lodLevelsDirty_;
 };
 

+ 39 - 39
Engine/Graphics/Geometry.h

@@ -32,91 +32,91 @@ class Ray;
 class Graphics;
 class VertexBuffer;
 
-/// Defines one or more vertex buffers, an index buffer and a draw range
+/// Defines one or more vertex buffers, an index buffer and a draw range.
 class Geometry : public Object
 {
     OBJECT(Geometry);
     
 public:
-    /// Construct with one empty vertex buffer
+    /// Construct with one empty vertex buffer.
     Geometry(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~Geometry();
     
-    /// %Set number of vertex buffer
+    /// %Set number of vertex buffer.
     bool SetNumVertexBuffers(unsigned num);
-    /// %Set a vertex buffer by index
+    /// %Set a vertex buffer by index.
     bool SetVertexBuffer(unsigned index, VertexBuffer* buffer, unsigned elementMask = MASK_DEFAULT);
-    /// %Set the index buffer
+    /// %Set the index buffer.
     void SetIndexBuffer(IndexBuffer* buffer);
-    /// %Set the draw range
+    /// %Set the draw range.
     bool SetDrawRange(PrimitiveType type, unsigned indexStart, unsigned indexCount, bool GetUsedVertexRange = true);
-    /// %Set the draw range
+    /// %Set the draw range.
     bool SetDrawRange(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned vertexStart, unsigned vertexCount);
-    /// %Set the LOD distance to report
+    /// %Set the LOD distance.
     void SetLodDistance(float distance);
-    /// %Set vertex and index raw data for CPU access. Vertex raw data should contain positions only
+    /// %Set vertex and index raw data for CPU access. Vertex raw data should contain positions only.
     void SetRawData(const SharedArrayPtr<unsigned char>& vertexData, const SharedArrayPtr<unsigned char>& indexData);
-    /// Draw
+    /// Draw.
     void Draw(Graphics* graphics);
     
-    /// Return all vertex buffers
+    /// Return all vertex buffers.
     const Vector<SharedPtr<VertexBuffer> >& GetVertexBuffers() const { return vertexBuffers_; }
-    /// Return vertex element masks
+    /// Return vertex element masks.
     const PODVector<unsigned>& GetVertexElementMasks() const { return elementMasks_; }
-    /// Return number of vertex buffers
+    /// Return number of vertex buffers.
     unsigned GetNumVertexBuffers() const { return vertexBuffers_.Size(); }
-    /// Return vertex buffer by index
+    /// Return vertex buffer by index.
     VertexBuffer* GetVertexBuffer(unsigned index) const;
-    /// Return vertex element mask by index
+    /// Return vertex element mask by index.
     unsigned GetVertexElementMask(unsigned index) const;
-    /// Return the index buffer
+    /// Return the index buffer.
     IndexBuffer* GetIndexBuffer() const { return indexBuffer_; }
-    /// Return primitive type
+    /// Return primitive type.
     PrimitiveType GetPrimitiveType() const { return primitiveType_; }
-    /// Return start index
+    /// Return start index.
     unsigned GetIndexStart() const { return indexStart_; }
-    /// Return number of indices
+    /// Return number of indices.
     unsigned GetIndexCount() const { return indexCount_; }
-    /// Return first used vertex
+    /// Return first used vertex.
     unsigned GetVertexStart() const { return vertexStart_; }
-    /// Return number of used vertices
+    /// Return number of used vertices.
     unsigned GetVertexCount() const { return vertexCount_; }
-    /// Return LOD distance
+    /// Return LOD distance.
     float GetLodDistance() const { return lodDistance_; }
-    /// Return buffers' combined hash value for state sorting
+    /// Return buffers' combined hash value for state sorting.
     unsigned short GetBufferHash() const;
-    /// Return raw vertex and index data for CPU operations, or null pointers if not available
+    /// Return raw vertex and index data for CPU operations, or null pointers if not available.
     void GetRawData(const unsigned char*& vertexData, unsigned& vertexSize, const unsigned char*& indexData, unsigned& indexSize);
-    /// Return ray hit distance or infinity if no hit. Requires raw data to be set
+    /// Return ray hit distance or infinity if no hit. Requires raw data to be set.
     float GetDistance(const Ray& ray);
     
 private:
-    /// Locate vertex buffer with position data
+    /// Locate vertex buffer with position data.
     void GetPositionBufferIndex();
     
-    /// Vertex buffers
+    /// Vertex buffers.
     Vector<SharedPtr<VertexBuffer> > vertexBuffers_;
-    /// Vertex element masks
+    /// Vertex element masks.
     PODVector<unsigned> elementMasks_;
-    /// Index buffer
+    /// Index buffer.
     SharedPtr<IndexBuffer> indexBuffer_;
-    /// Primitive type
+    /// Primitive type.
     PrimitiveType primitiveType_;
-    /// Start index
+    /// Start index.
     unsigned indexStart_;
-    /// Number of indices
+    /// Number of indices.
     unsigned indexCount_;
-    /// First used vertex
+    /// First used vertex.
     unsigned vertexStart_;
-    /// Number of used vertices
+    /// Number of used vertices.
     unsigned vertexCount_;
-    /// Index of vertex buffer with position data
+    /// Index of vertex buffer with position data.
     unsigned positionBufferIndex_;
-    /// LOD distance
+    /// LOD distance.
     float lodDistance_;
-    /// Raw vertex data (positions only) for CPU operations
+    /// Raw vertex data (positions only) for CPU operations.
     SharedArrayPtr<unsigned char> rawVertexData_;
-    /// Raw index data for CPU operations
+    /// Raw index data for CPU operations.
     SharedArrayPtr<unsigned char> rawIndexData_;
 };

+ 18 - 18
Engine/Graphics/GraphicsDefs.h

@@ -26,21 +26,21 @@
 #include "HashBase.h"
 #include "StringHash.h"
 
-/// Rendering mode
+/// Rendering mode.
 enum RenderMode
 {
     RENDER_FORWARD = 0,
     RENDER_DEFERRED
 };
 
-/// Primitive type
+/// Primitive type.
 enum PrimitiveType
 {
     TRIANGLE_LIST = 0,
     LINE_LIST
 };
 
-/// Geometry type
+/// Geometry type.
 enum GeometryType
 {
     GEOM_STATIC = 0,
@@ -50,7 +50,7 @@ enum GeometryType
     MAX_GEOMETRYTYPES
 };
 
-/// Blending mode
+/// Blending mode.
 enum BlendMode
 {
     BLEND_REPLACE = 0,
@@ -63,7 +63,7 @@ enum BlendMode
     MAX_BLENDMODES
 };
 
-/// Depth or stencil compare mode
+/// Depth or stencil compare mode.
 enum CompareMode
 {
     CMP_ALWAYS = 0,
@@ -76,7 +76,7 @@ enum CompareMode
     MAX_COMPAREMODES
 };
 
-/// Culling mode
+/// Culling mode.
 enum CullMode
 {
     CULL_NONE = 0,
@@ -85,14 +85,14 @@ enum CullMode
     MAX_CULLMODES
 };
 
-/// Fill mode
+/// Fill mode.
 enum FillMode
 {
     FILL_SOLID = 0,
     FILL_WIREFRAME
 };
 
-/// Stencil operation
+/// Stencil operation.
 enum StencilOp
 {
     OP_KEEP = 0,
@@ -102,7 +102,7 @@ enum StencilOp
     OP_DECR
 };
 
-/// Buffer lock mode
+/// Buffer lock mode.
 enum LockMode
 {
     LOCK_NORMAL,
@@ -111,7 +111,7 @@ enum LockMode
     LOCK_READONLY
 };
 
-/// Vertex elements
+/// Vertex elements.
 enum VertexElement
 {
     ELEMENT_POSITION = 0,
@@ -130,7 +130,7 @@ enum VertexElement
     MAX_VERTEX_ELEMENTS
 };
 
-/// Texture filtering mode
+/// Texture filtering mode.
 enum TextureFilterMode
 {
     FILTER_NEAREST = 0,
@@ -141,7 +141,7 @@ enum TextureFilterMode
     MAX_FILTERMODES
 };
 
-/// Texture addressing mode
+/// Texture addressing mode.
 enum TextureAddressMode
 {
     ADDRESS_WRAP = 0,
@@ -151,7 +151,7 @@ enum TextureAddressMode
     MAX_ADDRESSMODES
 };
 
-/// Texture coordinates
+/// Texture coordinates.
 enum TextureCoordinate
 {
     COORD_U = 0,
@@ -160,7 +160,7 @@ enum TextureCoordinate
     MAX_COORDS
 };
 
-/// Texture usage types
+/// Texture usage types.
 enum TextureUsage
 {
     TEXTURE_STATIC = 0,
@@ -169,7 +169,7 @@ enum TextureUsage
     TEXTURE_DEPTHSTENCIL
 };
 
-/// Rendering passes
+/// Rendering passes.
 enum PassType
 {
     PASS_GBUFFER,
@@ -181,7 +181,7 @@ enum PassType
     MAX_PASSES
 };
 
-/// Cube map faces
+/// Cube map faces.
 enum CubeMapFace
 {
     FACE_POSITIVE_X = 0,
@@ -193,7 +193,7 @@ enum CubeMapFace
     MAX_CUBEMAP_FACES
 };
 
-/// Shader types
+/// Shader types.
 enum ShaderType
 {
     VS = 0,
@@ -236,7 +236,7 @@ extern StringHash PSP_SHADOWINTENSITY;
 extern StringHash PSP_SHADOWPROJ;
 extern StringHash PSP_SPOTPROJ;
 
-/// Texture units
+/// Texture units.
 enum TextureUnit
 {
     TU_DIFFUSE = 0,

+ 4 - 11
Engine/Graphics/GraphicsEvents.h

@@ -25,7 +25,7 @@
 
 #include "Object.h"
 
-/// Operating system window message
+/// Operating system window message.
 EVENT(E_WINDOWMESSAGE, WindowMessage)
 {
     PARAM(P_WINDOW, Window);              // int
@@ -35,14 +35,7 @@ EVENT(E_WINDOWMESSAGE, WindowMessage)
     PARAM(P_HANDLED, Handled);            // bool
 }
 
-/// Application activation state changed. Sent by the Input subsystem
-EVENT(E_ACTIVATION, Activation)
-{
-    PARAM(P_ACTIVE, Active);              // bool
-    PARAM(P_MINIMIZED, Minimized);        // bool
-}
-
-/// New screen mode set
+/// New screen mode set.
 EVENT(E_SCREENMODE, ScreenMode)
 {
     PARAM(P_WIDTH, Width);                // int
@@ -50,12 +43,12 @@ EVENT(E_SCREENMODE, ScreenMode)
     PARAM(P_FULLSCREEN, Fullscreen);      // bool
 }
 
-/// Frame rendering started
+/// Frame rendering started.
 EVENT(E_BEGINRENDERING, BeginRendering)
 {
 }
 
-/// Frame rendering ended
+/// Frame rendering ended.
 EVENT(E_ENDRENDERING, EndRendering)
 {
 }

+ 109 - 109
Engine/Graphics/Light.h

@@ -32,7 +32,7 @@ class Texture;
 class Texture2D;
 class TextureCube;
 
-/// Light types
+/// Light types.
 enum LightType
 {
     LIGHT_DIRECTIONAL = 0,
@@ -41,39 +41,39 @@ enum LightType
     LIGHT_SPLITPOINT
 };
 
-/// Shadow depth bias parameters
+/// Shadow depth bias parameters.
 struct BiasParameters
 {
-    /// Construct as undefined
+    /// Construct undefined.
     BiasParameters()
     {
     }
     
-    /// Construct with initial values
+    /// Construct with initial values.
     BiasParameters(float constantBias, float slopeScaledBias) :
         constantBias_(constantBias),
         slopeScaledBias_(slopeScaledBias)
     {
     }
     
-    /// Validate parameters
+    /// Validate parameters.
     void Validate();
     
-    /// Constant bias
+    /// Constant bias.
     float constantBias_;
-    /// Slope scaled bias
+    /// Slope scaled bias.
     float slopeScaledBias_;
 };
 
-/// Cascaded shadow map parameters
+/// Cascaded shadow map parameters.
 struct CascadeParameters
 {
-    /// Construct as undefined
+    /// Construct undefined.
     CascadeParameters()
     {
     }
     
-    /// Construct with initial values
+    /// Construct with initial values.
     CascadeParameters(unsigned splits, float lambda, float splitFadeRange, float shadowRange) :
         splits_(splits),
         lambda_(lambda),
@@ -82,28 +82,28 @@ struct CascadeParameters
     {
     }
     
-    /// Validate parameters
+    /// Validate parameters.
     void Validate();
     
-    /// Number of splits
+    /// Number of splits.
     unsigned splits_;
-    /// Split lambda
+    /// Split lambda.
     float lambda_;
-    /// Fade range between splits
+    /// Fade range between splits.
     float splitFadeRange_;
-    /// Maximum shadow distance
+    /// Maximum shadow distance.
     float shadowRange_;
 };
 
-/// Shadow map focusing parameters
+/// Shadow map focusing parameters.
 struct FocusParameters
 {
-    /// Construct as undefined
+    /// Construct undefined.
     FocusParameters()
     {
     }
     
-    /// Construct with initial values
+    /// Construct with initial values.
     FocusParameters(bool focus, bool nonUniform, bool zoomOut, float quantize, float minView) :
         focus_(focus),
         nonUniform_(nonUniform),
@@ -113,18 +113,18 @@ struct FocusParameters
     {
     }
     
-    /// Validate parameters
+    /// Validate parameters.
     void Validate();
     
-    /// Focus flag
+    /// Focus flag.
     bool focus_;
-    /// Non-uniform focusing flag
+    /// Non-uniform focusing flag.
     bool nonUniform_;
-    /// Zoom out flag
+    /// Zoom out flag.
     bool zoomOut_;
-    /// Focus quantization
+    /// Focus quantization.
     float quantize_;
-    /// Minimum view size
+    /// Minimum view size.
     float minView_;
 };
 
@@ -132,189 +132,189 @@ static const float SHADOW_MIN_QUANTIZE = 0.1f;
 static const float SHADOW_MIN_VIEW = 1.0f;
 static const float SHADOW_DEFAULT_NEARCLIP = 0.1f;
 
-/// Light component
+/// Light component.
 class Light : public Drawable
 {
     OBJECT(Light);
     
 public:
-    /// Construct
+    /// Construct.
     Light(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~Light();
-    /// Register object factory. Drawable must be registered first
+    /// Register object factory. Drawable must be registered first.
     static void RegisterObject(Context* context);
     
-    /// Calculate distance for rendering
+    /// Calculate distance for rendering.
     virtual void UpdateDistance(const FrameInfo& frame);
-    /// Add debug geometry to the debug graphics
+    /// Add debug geometry to the debug graphics.
     virtual void DrawDebugGeometry(DebugRenderer* debug, bool depthTest);
     
-    /// %Set light type
+    /// %Set light type.
     void SetLightType(LightType type);
-    /// %Set color
+    /// %Set color.
     void SetColor(const Color& color);
-    /// %Set specular intensity
+    /// %Set specular intensity.
     void SetSpecularIntensity(float intensity);
-    /// %Set range
+    /// %Set range.
     void SetRange(float range);
-    /// %Set spotlight field of view
+    /// %Set spotlight field of view.
     void SetFov(float fov);
-    /// %Set spotlight aspect ratio
+    /// %Set spotlight aspect ratio.
     void SetAspectRatio(float aspectRatio);
-    /// %Set fade out start distance
+    /// %Set fade out start distance.
     void SetFadeDistance(float distance);
-    /// %Set shadow fade out start distance. Only has effect if shadow distance is also non-zero
+    /// %Set shadow fade out start distance. Only has effect if shadow distance is also non-zero.
     void SetShadowFadeDistance(float distance);
-    /// %Set shadow depth bias parameters
+    /// %Set shadow depth bias parameters.
     void SetShadowBias(const BiasParameters& parameters);
-    /// %Set directional light cascaded shadow parameters
+    /// %Set directional light cascaded shadow parameters.
     void SetShadowCascade(const CascadeParameters& parameters);
-    /// %Set shadow map focusing parameters
+    /// %Set shadow map focusing parameters.
     void SetShadowFocus(const FocusParameters& parameters);
     /// %Set shadow intensity between 0.0 - 1.0. 0.0 (the default) gives fully dark shadows.
     void SetShadowIntensity(float intensity);
-    /// %Set shadow resolution between 0.25 - 1.0. Determines the shadow map to use
+    /// %Set shadow resolution between 0.25 - 1.0. Determines the shadow map to use.
     void SetShadowResolution(float resolution);
-    /// %Set shadow camera near/far clip distance ratio
+    /// %Set shadow camera near/far clip distance ratio.
     void SetShadowNearFarRatio(float nearFarRatio);
-    /// %Set range attenuation texture
+    /// %Set range attenuation texture.
     void SetRampTexture(Texture* texture);
-    /// %Set spotlight attenuation texture
+    /// %Set spotlight attenuation texture.
     void SetShapeTexture(Texture* texture);
     
-    /// Return light type
+    /// Return light type.
     LightType GetLightType() const { return lightType_; }
-    /// Return color
+    /// Return color.
     const Color& GetColor() const { return color_; }
-    /// Return specular intensity
+    /// Return specular intensity.
     float GetSpecularIntensity() const { return specularIntensity_; }
-    /// Return range
+    /// Return range.
     float GetRange() const { return range_; }
-    /// Return spotlight field of view
+    /// Return spotlight field of view.
     float GetFov() const { return fov_; }
-    /// Return spotlight aspect ratio
+    /// Return spotlight aspect ratio.
     float GetAspectRatio() const { return aspectRatio_; }
-    /// Return fade start distance
+    /// Return fade start distance.
     float GetFadeDistance() const { return fadeDistance_; }
-   /// Return shadow fade start distance
+   /// Return shadow fade start distance.
     float GetShadowFadeDistance() const { return shadowFadeDistance_; }
-    /// Return shadow depth bias parameters
+    /// Return shadow depth bias parameters.
     const BiasParameters& GetShadowBias() const { return shadowBias_; }
-    /// Return directional light cascaded shadow parameters
+    /// Return directional light cascaded shadow parameters.
     const CascadeParameters& GetShadowCascade() const { return shadowCascade_; }
-    /// Return shadow map focus parameters
+    /// Return shadow map focus parameters.
     const FocusParameters& GetShadowFocus() const { return shadowFocus_; }
-    /// Return shadow intensity
+    /// Return shadow intensity.
     float GetShadowIntensity() const { return shadowIntensity_; }
-    /// Return shadow resolution
+    /// Return shadow resolution.
     float GetShadowResolution() const { return shadowResolution_; }
-    /// Return shadow camera near/far clip distance ratio
+    /// Return shadow camera near/far clip distance ratio.
     float GetShadowNearFarRatio() const { return shadowNearFarRatio_; }
-    /// Return range attenuation texture
+    /// Return range attenuation texture.
     Texture* GetRampTexture() const { return rampTexture_; }
-    /// Return spotlight attenuation texture
+    /// Return spotlight attenuation texture.
     Texture* GetShapeTexture() const { return shapeTexture_; }
-    /// Return spotlight frustum
+    /// Return spotlight frustum.
     Frustum GetFrustum() const;
     
-    /// %Set near split distance for directional light
+    /// %Set near split distance for directional light.
     void SetNearSplit(float near);
-    /// %Set far split distance for directional light
+    /// %Set far split distance for directional light.
     void SetFarSplit(float far);
-    /// %Set near fade range for directional light
+    /// %Set near fade range for directional light.
     void SetNearFadeRange(float range);
-    /// %Set far fade range for directional light
+    /// %Set far fade range for directional light.
     void SetFarFadeRange(float range);
-    /// %Set shadow camera
+    /// %Set shadow camera.
     void SetShadowCamera(Camera* camera);
-    /// %Set shadow map depth texture
+    /// %Set shadow map depth texture.
     void SetShadowMap(Texture2D* shadowMap);
-    /// %Set sort value based on intensity at given world position
+    /// %Set sort value based on intensity at given world position.
     void SetIntensitySortValue(const Vector3& position);
-    /// Copy values from another light
+    /// Copy values from another light.
     void CopyFrom(Light* original);
-    /// Return near split distance
+    /// Return near split distance.
     float GetNearSplit() const { return nearSplit_; }
-    /// Return far split distance
+    /// Return far split distance.
     float GetFarSplit() const { return farSplit_; }
-    /// Return near fade range
+    /// Return near fade range.
     float GetNearFadeRange() const { return nearFadeRange_; }
-    /// Return far fade range
+    /// Return far fade range.
     float GetFarFadeRange() const { return farFadeRange_; }
-    /// Return shadow camera. Not safe to dereference outside rendering
+    /// Return shadow camera. Not safe to dereference outside rendering.
     Camera* GetShadowCamera() { return shadowCamera_; }
-    /// Return shadow map
+    /// Return shadow map.
     Texture2D* GetShadowMap() const { return shadowMap_; }
-    /// Return original light (split lights only)
+    /// Return original light (split lights only.)
     Light* GetOriginalLight() const { return originalLight_; }
-    /// Return volume safety extent of spot or point light
+    /// Return volume safety extent of spot or point light.
     float GetVolumeExtent() const;
-    /// Return directional light quad transform for either near or far split
+    /// Return directional light quad transform for either near or far split.
     Matrix3x4 GetDirLightTransform(Camera& camera, bool getNearQuad = false);
-    /// Return light volume model transform. For directional lights, the view transform must be overridden
+    /// Return light volume model transform. For directional lights, the view transform must be overridden.
     const Matrix3x4& GetVolumeTransform(Camera& camera);
     
-    /// %Set ramp texture attribute
+    /// %Set ramp texture attribute.
     void SetRampTextureAttr(ResourceRef value);
-    /// %Set shape texture attribute
+    /// %Set shape texture attribute.
     void SetShapeTextureAttr(ResourceRef value);
-    /// Return ramp texture attribute
+    /// Return ramp texture attribute.
     ResourceRef GetRampTextureAttr() const;
-    /// Return shape texture attribute
+    /// Return shape texture attribute.
     ResourceRef GetShapeTextureAttr() const;
     
 protected:
-    /// Update world-space bounding box
+    /// Update world-space bounding box.
     virtual void OnWorldBoundingBoxUpdate();
     
 private:
-    /// Light type
+    /// Light type.
     LightType lightType_;
-    /// Color
+    /// Color.
     Color color_;
-    /// Specular intensity
+    /// Specular intensity.
     float specularIntensity_;
-    /// Range
+    /// Range.
     float range_;
-    /// Spotlight field of view
+    /// Spotlight field of view.
     float fov_;
-    /// Spotlight aspect ratio
+    /// Spotlight aspect ratio.
     float aspectRatio_;
-    /// Fade start distance
+    /// Fade start distance.
     float fadeDistance_;
-    /// Shadow fade start distance
+    /// Shadow fade start distance.
     float shadowFadeDistance_;
-    /// Shadow depth bias parameters
+    /// Shadow depth bias parameters.
     BiasParameters shadowBias_;
-    /// Directional light cascaded shadow parameters
+    /// Directional light cascaded shadow parameters.
     CascadeParameters shadowCascade_;
-    /// Shadow map focus parameters
+    /// Shadow map focus parameters.
     FocusParameters shadowFocus_;
-    /// Custom world transform for the light volume
+    /// Custom world transform for the light volume.
     Matrix3x4 volumeTransform_;
-    /// Shadow intensity
+    /// Shadow intensity.
     float shadowIntensity_;
-    /// Shadow resolution
+    /// Shadow resolution.
     float shadowResolution_;
-    /// Shadow camera near/far clip distance ratio
+    /// Shadow camera near/far clip distance ratio.
     float shadowNearFarRatio_;
-    /// Directional light near split distance
+    /// Directional light near split distance.
     float nearSplit_;
-    /// Directional light far split distance
+    /// Directional light far split distance.
     float farSplit_;
-    /// Directional light near fade range
+    /// Directional light near fade range.
     float nearFadeRange_;
-    /// Directional light far fade range
+    /// Directional light far fade range.
     float farFadeRange_;
-    /// Range attenuation texture
+    /// Range attenuation texture.
     SharedPtr<Texture> rampTexture_;
-    /// Spotlight attenuation texture
+    /// Spotlight attenuation texture.
     SharedPtr<Texture> shapeTexture_;
-    /// Shadow camera
+    /// Shadow camera.
     Camera* shadowCamera_;
-    /// Shadow map
+    /// Shadow map.
     Texture2D* shadowMap_;
-    /// Original light for splitting
+    /// Original light for splitting.
     Light* originalLight_;
 };

+ 3 - 3
Engine/Graphics/Material.cpp

@@ -196,7 +196,7 @@ bool Material::Load(Deserializer& source)
     memoryUse += shaderParameters_.Size() * sizeof(MaterialShaderParameter);
     
     SetMemoryUse(memoryUse);
-    Update();
+    CheckOcclusion();
     return true;
 }
 
@@ -255,7 +255,7 @@ void Material::SetTechnique(unsigned index, Technique* technique, unsigned quali
         return;
     
     techniques_[index] = TechniqueEntry(technique, qualityLevel, lodDistance);
-    Update();
+    CheckOcclusion();
 }
 
 void Material::SetShaderParameter(const String& name, const Vector4& value)
@@ -380,7 +380,7 @@ const String& Material::GetTextureUnitName(TextureUnit unit)
     return textureUnitNames[unit];
 }
 
-void Material::Update()
+void Material::CheckOcclusion()
 {
     // Determine occlusion by checking the first pass of each technique
     occlusion_ = false;

+ 50 - 50
Engine/Graphics/Material.h

@@ -34,120 +34,120 @@ class Texture;
 class Texture2D;
 class TextureCube;
 
-/// Material's shader parameter definition
+/// Material's shader parameter definition.
 struct MaterialShaderParameter
 {
-    /// Name
+    /// Name.
     String name_;
-    /// Value
+    /// Value.
     Vector4 value_;
 };
 
-/// Material's technique list entry
+/// Material's technique list entry.
 struct TechniqueEntry
 {
-    /// Construct with defaults
+    /// Construct with defaults.
     TechniqueEntry();
-    /// Construct with parameters
+    /// Construct with parameters.
     TechniqueEntry(Technique* technique, unsigned qualityLevel, float lodDistance);
-    /// Destruct
+    /// Destruct.
     ~TechniqueEntry();
     
-    /// Technique
+    /// Technique.
     SharedPtr<Technique> technique_;
-    /// Quality level
+    /// Quality level.
     int qualityLevel_;
-    /// LOD distance
+    /// LOD distance.
     float lodDistance_;
 };
 
-/// Describes how to render 3D geometries
+/// Describes how to render 3D geometries.
 class Material : public Resource
 {
     OBJECT(Material);
     
 public:
-    /// Construct
+    /// Construct.
     Material(Context* context);
-    /// Destruct
+    /// Destruct.
     ~Material();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Load resource. Return true if successful
+    /// Load resource. Return true if successful.
     virtual bool Load(Deserializer& source);
-    /// Save resource. Return true if successful
+    /// Save resource. Return true if successful.
     virtual bool Save(Serializer& dest);
     
-    /// %Set number of techniques
+    /// %Set number of techniques.
     void SetNumTechniques(unsigned num);
-    /// %Set technique
+    /// %Set technique.
     void SetTechnique(unsigned index, Technique* technique, unsigned qualityLevel = 0, float lodDistance = 0.0f);
-    /// %Set shader parameter
+    /// %Set shader parameter.
     void SetShaderParameter(const String& name, const Vector4& value);
-    /// %Set texture
+    /// %Set texture.
     void SetTexture(TextureUnit unit, Texture* texture);
-    /// %Set texture coordinate transform
+    /// %Set texture coordinate transform.
     void SetUVTransform(const Vector2& offset, float rotation, const Vector2& repeat);
-    /// %Set texture coordinate transform
+    /// %Set texture coordinate transform.
     void SetUVTransform(const Vector2& offset, float rotation, float repeat);
-    /// %Set culling mode
+    /// %Set culling mode.
     void SetCullMode(CullMode mode);
-    /// %Set culling mode for shadows
+    /// %Set culling mode for shadows.
     void SetShadowCullMode(CullMode mode);
-    /// Remove a shader parameter
+    /// Remove a shader parameter.
     void RemoveShaderParameter(const String& name);
-    /// Reset all shader pointers
+    /// Reset all shader pointers.
     void ReleaseShaders();
-    /// Clone material
+    /// Clone material.
     SharedPtr<Material> Clone(const String& cloneName = String()) const;
-    /// Mark material for auxiliary view rendering
+    /// Mark material for auxiliary view rendering.
     void MarkForAuxView(unsigned frameNumber);
     
-    /// Return number of techniques
+    /// Return number of techniques.
     unsigned GetNumTechniques() const { return techniques_.Size(); }
-    /// Return all techniques
+    /// Return all techniques.
     const Vector<TechniqueEntry>& GetTechniques() const { return techniques_; }
-    /// Return technique entry by index
+    /// Return technique entry by index.
     const TechniqueEntry& GetTechniqueEntry(unsigned index) const;
-    /// Return technique by index
+    /// Return technique by index.
     Technique* GetTechnique(unsigned index) const;
-    /// Return pass by technique index and pass type
+    /// Return pass by technique index and pass type.
     Pass* GetPass(unsigned index, PassType pass) const;
-    /// Return all textures
+    /// Return all textures.
     const Vector<SharedPtr<Texture> >& GetTextures() const { return textures_; }
-    /// Return texture by unit
+    /// Return texture by unit.
     Texture* GetTexture(TextureUnit unit) const;
-    /// Return all shader parameters
+    /// Return all shader parameters.
     const HashMap<StringHash, MaterialShaderParameter>& GetShaderParameters() const { return shaderParameters_; }
-    /// Return normal culling mode
+    /// Return normal culling mode.
     CullMode GetCullMode() const { return cullMode_; }
-    /// Return culling mode for shadows
+    /// Return culling mode for shadows.
     CullMode GetShadowCullMode() const { return shadowCullMode_; }
-    /// Return last auxiliary view rendered frame number
+    /// Return last auxiliary view rendered frame number.
     unsigned GetAuxViewFrameNumber() const { return auxViewFrameNumber_; }
-    /// Return whether should render occlusion
+    /// Return whether should render occlusion.
     bool GetOcclusion() const { return occlusion_; }
     
-    /// Return name for texture unit
+    /// Return name for texture unit.
     static const String& GetTextureUnitName(TextureUnit unit);
     
 private:
-    /// Re-evaluate occlusion rendering
-    void Update();
+    /// Re-evaluate occlusion rendering.
+    void CheckOcclusion();
     
-    /// Techniques
+    /// Techniques.
     Vector<TechniqueEntry> techniques_;
-    /// Textures
+    /// Textures.
     Vector<SharedPtr<Texture> > textures_;
-    /// Shader parameters
+    /// Shader parameters.
     HashMap<StringHash, MaterialShaderParameter> shaderParameters_;
-    /// Normal culling mode
+    /// Normal culling mode.
     CullMode cullMode_;
-    /// Culling mode for shadow rendering
+    /// Culling mode for shadow rendering.
     CullMode shadowCullMode_;
-    /// Last auxiliary view rendered frame number
+    /// Last auxiliary view rendered frame number.
     unsigned auxViewFrameNumber_;
-    /// Render occlusion flag
+    /// Render occlusion flag.
     bool occlusion_;
 };

+ 54 - 22
Engine/Graphics/Model.cpp

@@ -86,6 +86,8 @@ bool Model::Load(Deserializer& source)
         return false;
     }
     
+    bool headless = GetSubsystem<Graphics>() == 0;
+    
     geometries_.Clear();
     geometryBoneMappings_.Clear();
     morphs_.Clear();
@@ -111,19 +113,43 @@ bool Model::Load(Deserializer& source)
         buffer->SetMorphRange(morphStart, morphCount);
         
         unsigned vertexSize = buffer->GetVertexSize();
-        unsigned char* data = (unsigned char*)buffer->Lock(0, vertexCount, LOCK_NORMAL);
-        if (data)
+        if (!headless)
         {
-            source.Read(data, vertexCount * vertexSize);
-            // If there is a morph range, make a copy of the data so that the morph range can be reset
-            if (morphCount)
+            unsigned char* data = (unsigned char*)buffer->Lock(0, vertexCount, LOCK_NORMAL);
+            if (data)
             {
-                SharedArrayPtr<unsigned char> morphResetData(new unsigned char[morphCount * vertexSize]);
-                memcpy(morphResetData.Get(), &data[morphStart * vertexSize], morphCount * vertexSize);
-                buffer->SetMorphRangeResetData(morphResetData);
+                source.Read(data, vertexCount * vertexSize);
+                // If there is a morph range, make a copy of the data so that the morph range can be reset
+                if (morphCount)
+                {
+                    SharedArrayPtr<unsigned char> morphResetData(new unsigned char[morphCount * vertexSize]);
+                    memcpy(morphResetData.Get(), &data[morphStart * vertexSize], morphCount * vertexSize);
+                    buffer->SetMorphRangeResetData(morphResetData);
+                }
+            
+                // Copy the raw position data for CPU-side operations
+                SharedArrayPtr<unsigned char> rawVertexData(new unsigned char[3 * sizeof(float) * vertexCount]);
+                float* rawDest = (float*)rawVertexData.Get();
+                for (unsigned i = 0; i < vertexCount; ++i)
+                {
+                    float* rawSrc = (float*)&data[i * vertexSize];
+                    *rawDest++ = *rawSrc++;
+                    *rawDest++ = *rawSrc++;
+                    *rawDest++ = *rawSrc++;
+                }
+                rawVertexDatas.Push(rawVertexData);
+                
+                buffer->Unlock();
             }
+            else
+                return false;
+        }
+        else
+        {
+            // In headless mode only store the raw position data for CPU operations
+            SharedArrayPtr<unsigned char> data(new unsigned char[vertexCount * vertexSize]);
+            source.Read(data.Get(), vertexCount * vertexSize);
             
-            // Copy the raw position data for CPU-side operations
             SharedArrayPtr<unsigned char> rawVertexData(new unsigned char[3 * sizeof(float) * vertexCount]);
             float* rawDest = (float*)rawVertexData.Get();
             for (unsigned i = 0; i < vertexCount; ++i)
@@ -134,11 +160,7 @@ bool Model::Load(Deserializer& source)
                 *rawDest++ = *rawSrc++;
             }
             rawVertexDatas.Push(rawVertexData);
-            
-            buffer->Unlock();
         }
-        else
-            return false;
         
         vertexBuffers_.Push(buffer);
     }
@@ -153,20 +175,30 @@ bool Model::Load(Deserializer& source)
         SharedPtr<IndexBuffer> buffer(new IndexBuffer(context_));
         buffer->SetSize(indexCount, indexSize > sizeof(unsigned short));
         
-        unsigned char* data = (unsigned char*)buffer->Lock(0, indexCount, LOCK_NORMAL);
-        if (data)
+        if (!headless)
         {
-            source.Read(data, indexCount * indexSize);
+            unsigned char* data = (unsigned char*)buffer->Lock(0, indexCount, LOCK_NORMAL);
+            if (data)
+            {
+                source.Read(data, indexCount * indexSize);
             
-            // Copy the raw index data for CPU-side operations
-            SharedArrayPtr<unsigned char> rawIndexData(new unsigned char[indexSize * indexCount]);
-            memcpy(rawIndexData.Get(), data, indexSize * indexCount);
-            rawIndexDatas.Push(rawIndexData);
+                // Copy the raw index data for CPU-side operations
+                SharedArrayPtr<unsigned char> rawIndexData(new unsigned char[indexSize * indexCount]);
+                memcpy(rawIndexData.Get(), data, indexSize * indexCount);
+                rawIndexDatas.Push(rawIndexData);
             
-            buffer->Unlock();
+                buffer->Unlock();
+            }
+            else
+                return false;
         }
         else
-            return false;
+        {
+            // In headless mode only store the raw index data for CPU operations
+            SharedArrayPtr<unsigned char> rawIndexData(new unsigned char[indexSize * indexCount]);
+            source.Read(rawIndexData.Get(), indexSize * indexCount);
+            rawIndexDatas.Push(rawIndexData);
+        }
         
         indexBuffers_.Push(buffer);
     }

+ 47 - 47
Engine/Graphics/Model.h

@@ -34,113 +34,113 @@ class IndexBuffer;
 class Graphics;
 class VertexBuffer;
 
-/// Vertex buffer morph data
+/// Vertex buffer morph data.
 struct VertexBufferMorph
 {
-    /// Vertex elements
+    /// Vertex elements.
     unsigned elementMask_;
-    /// Number of vertices
+    /// Number of vertices.
     unsigned vertexCount_;
-    /// Morphed vertices. Stored packed as <index, data> pairs
+    /// Morphed vertices. Stored packed as <index, data> pairs.
     SharedArrayPtr<unsigned char> morphData_;
 };
 
-/// Model vertex morph
+/// Definition of a model's vertex morph.
 struct ModelMorph
 {
-    /// Morph name
+    /// Morph name.
     String name_;
-    /// Morph name hash
+    /// Morph name hash.
     StringHash nameHash_;
-    /// Current morph weight
+    /// Current morph weight.
     float weight_;
-    /// Morph data per vertex buffer
+    /// Morph data per vertex buffer.
     Map<unsigned, VertexBufferMorph> buffers_;
 };
 
-/// Model resource
+/// Model resource.
 class Model : public Resource
 {
     OBJECT(Model);
     
 public:
-    /// Construct
+    /// Construct.
     Model(Context* context);
-    /// Destruct
+    /// Destruct.
     virtual ~Model();
-    /// Register object factory
+    /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Load resource. Return true if successful
+    /// Load resource. Return true if successful.
     virtual bool Load(Deserializer& source);
-    /// Save resource. Return true if successful
+    /// Save resource. Return true if successful.
     virtual bool Save(Serializer& dest);
     
-    /// %Set bounding box
+    /// %Set bounding box.
     void SetBoundingBox(const BoundingBox& box);
-    /// %Set number of geometries
+    /// %Set number of geometries.
     void SetNumGeometries(unsigned num);
-    /// %Set number of LOD levels in a geometry
+    /// %Set number of LOD levels in a geometry.
     bool SetNumGeometryLodLevels(unsigned index, unsigned num);
-    /// %Set geometry
+    /// %Set geometry.
     bool SetGeometry(unsigned index, unsigned lodLevel, Geometry* geometry);
-    /// %Set skeleton
+    /// %Set skeleton.
     void SetSkeleton(const Skeleton& skeleton);
-    /// %Set bone mappings when model has more bones than the skinning shader can handle
+    /// %Set bone mappings when model has more bones than the skinning shader can handle.
     void SetGeometryBoneMappings(const Vector<PODVector<unsigned> >& mappings);
-    /// %Set vertex morphs
+    /// %Set vertex morphs.
     void SetMorphs(const Vector<ModelMorph>& morphs);
     
-    /// Return bounding box
+    /// Return bounding box.
     const BoundingBox& GetBoundingBox() const { return boundingBox_; }
-    /// Return skeleton
+    /// Return skeleton.
     Skeleton& GetSkeleton() { return skeleton_; }
-    /// Return vertex buffers
+    /// Return vertex buffers.
     const Vector<SharedPtr<VertexBuffer> >& GetVertexBuffers() const { return vertexBuffers_; }
-    /// Return index buffers
+    /// Return index buffers.
     const Vector<SharedPtr<IndexBuffer> >& GetIndexBuffers() const { return indexBuffers_; }
-    /// Return number of geometries
+    /// Return number of geometries.
     unsigned GetNumGeometries() const { return geometries_.Size(); }
-    /// Return number of LOD levels in geometry
+    /// Return number of LOD levels in geometry.
     unsigned GetNumGeometryLodLevels(unsigned index) const;
-    /// Return geometry pointers
+    /// Return geometry pointers.
     const Vector<Vector<SharedPtr<Geometry> > >& GetGeometries() const { return geometries_; }
-    /// Return geometry by index and LOD level
+    /// Return geometry by index and LOD level.
     Geometry* GetGeometry(unsigned index, unsigned lodLevel) const;
-    /// Return geometery bone mappings
+    /// Return geometery bone mappings.
     const Vector<PODVector<unsigned> >& GetGeometryBoneMappings() const { return geometryBoneMappings_; }
-    /// Return vertex morphs
+    /// Return vertex morphs.
     const Vector<ModelMorph>& GetMorphs() const { return morphs_; }
-    /// Return number of vertex morphs
+    /// Return number of vertex morphs.
     unsigned GetNumMorphs() const { return morphs_.Size(); }
-    /// Return vertex morph by index
+    /// Return vertex morph by index.
     const ModelMorph* GetMorph(unsigned index) const;
-    /// Return vertex morph by name
+    /// Return vertex morph by name.
     const ModelMorph* GetMorph(const String& name) const;
-    /// Return vertex morph by name hash
+    /// Return vertex morph by name hash.
     const ModelMorph* GetMorph(StringHash nameHash) const;
-    /// Return CPU copy of vertices
+    /// Return CPU copy of vertices.
     const PODVector<Vector3>& GetVertices() const { return vertices_; }
-    /// Return CPU copy of indices
+    /// Return CPU copy of indices.
     const PODVector<unsigned>& GetIndices() const { return indices_; }
     
 private:
-    /// Bounding box
+    /// Bounding box.
     BoundingBox boundingBox_;
-    /// Skeleton
+    /// Skeleton.
     Skeleton skeleton_;
-    /// Vertex buffers
+    /// Vertex buffers.
     Vector<SharedPtr<VertexBuffer> > vertexBuffers_;
-    /// Index buffers
+    /// Index buffers.
     Vector<SharedPtr<IndexBuffer> > indexBuffers_;
-    /// Geometries
+    /// Geometries.
     Vector<Vector<SharedPtr<Geometry> > > geometries_;
-    /// Geometry bone mappings
+    /// Geometry bone mappings.
     Vector<PODVector<unsigned> > geometryBoneMappings_;
-    /// Vertex morphs
+    /// Vertex morphs.
     Vector<ModelMorph> morphs_;
-    /// CPU copy of vertex positions
+    /// CPU copy of vertex positions.
     PODVector<Vector3> vertices_;
-    /// CPU copy of indices
+    /// CPU copy of indices.
     PODVector<unsigned> indices_;
 };

Some files were not shown because too many files changed in this diff