Browse Source

refactoring tiler & IS

Panagiotis Christopoulos Charitos 12 years ago
parent
commit
4f95c29c5d
54 changed files with 357 additions and 272 deletions
  1. 3 2
      include/anki/Collision.h
  2. 16 0
      include/anki/Config.h.cmake
  3. 2 2
      include/anki/Math.h
  4. 1 1
      include/anki/collision/CollisionShape.h
  5. 1 1
      include/anki/collision/Frustum.h
  6. 1 1
      include/anki/collision/Obb.h
  7. 1 1
      include/anki/collision/Plane.h
  8. 1 1
      include/anki/collision/Ray.h
  9. 1 1
      include/anki/collision/Sphere.h
  10. 1 1
      include/anki/event/Event.h
  11. 1 1
      include/anki/event/EventManager.h
  12. 1 1
      include/anki/event/LightEvent.h
  13. 1 1
      include/anki/event/MovableEvent.h
  14. 1 1
      include/anki/event/SceneAmbientColorEvent.h
  15. 1 1
      include/anki/gl/GlState.h
  16. 3 0
      include/anki/gl/Ubo.h
  17. 1 1
      include/anki/input/Input.h
  18. 1 1
      include/anki/physics/Character.h
  19. 1 1
      include/anki/physics/Converters.h
  20. 1 1
      include/anki/physics/RigidBody.h
  21. 1 1
      include/anki/renderer/DebugDrawer.h
  22. 14 6
      include/anki/renderer/Is.h
  23. 1 1
      include/anki/renderer/Renderer.h
  24. 3 12
      include/anki/renderer/Tiler.h
  25. 1 1
      include/anki/resource/Material.h
  26. 1 1
      include/anki/resource/Mesh.h
  27. 1 1
      include/anki/resource/MeshLoader.h
  28. 1 1
      include/anki/resource/ParticleEmitterResource.h
  29. 1 1
      include/anki/resource/Path.h
  30. 1 1
      include/anki/resource/SkelAnim.h
  31. 1 1
      include/anki/resource/Skeleton.h
  32. 1 1
      include/anki/scene/Grid.h
  33. 1 1
      include/anki/scene/Movable.h
  34. 2 2
      include/anki/scene/Property.h
  35. 1 1
      include/anki/scene/SceneGraph.h
  36. 1 1
      include/anki/scene/Sector.h
  37. 1 1
      include/anki/scene/SkinNode.h
  38. 1 1
      include/anki/scene/Spatial.h
  39. 1 1
      include/anki/ui/UiCommon.h
  40. 1 1
      include/anki/ui/UiFont.h
  41. 1 1
      include/anki/ui/UiFtFontLoader.h
  42. 1 1
      include/anki/ui/UiPainterDevice.h
  43. 27 8
      shaders/IsBinLightTemplate.glsl
  44. 29 9
      shaders/IsCommon.glsl
  45. 9 3
      shaders/IsUpdateTiles.glsl
  46. 2 2
      src/collision/CollisionAlgorithms.cpp
  47. 1 1
      src/collision/CollisionShape.cpp
  48. 1 1
      src/gl/ShaderProgram.cpp
  49. 1 1
      src/renderer/DebugDrawer.cpp
  50. 185 171
      src/renderer/Is.cpp
  51. 21 14
      src/renderer/Tiler.cpp
  52. 1 1
      src/script/math/Vec2.cpp
  53. 1 1
      src/script/math/Vec3.cpp
  54. 1 1
      src/script/math/Vec4.cpp

+ 3 - 2
include/anki/collision/Collision.h → include/anki/Collision.h

@@ -1,5 +1,5 @@
-#ifndef ANKI_COLLISION_COLLISION_H
-#define ANKI_COLLISION_COLLISION_H
+#ifndef ANKI_COLLISION_H
+#define ANKI_COLLISION_H
 
 /// @defgroup Collision Collision detection module
 
@@ -10,6 +10,7 @@
 #include "anki/collision/LineSegment.h"
 #include "anki/collision/Frustum.h"
 #include "anki/collision/Aabb.h"
+#include "anki/collision/CollisionPoint.h"
 
 #include "anki/collision/Functions.h"
 

+ 16 - 0
include/anki/Config.h.cmake

@@ -126,4 +126,20 @@ inline int stoi(const string& str)
 } // end namespace std
 #endif
 
+/// @addtogroup config
+/// @{
+
+#define ANKI_RENDERER_MAX_POINT_LIGHTS (512 - 16)
+#define ANKI_RENDERER_MAX_SPOT_LIGHTS 8
+#define ANKI_RENDERER_MAX_SPOT_TEX_LIGHTS 8
+
+#define ANKI_RENDERER_MAX_POINT_LIGHTS_PER_TILE 24
+#define ANKI_RENDERER_MAX_SPOT_LIGHTS_PER_TILE 4
+#define ANKI_RENDERER_MAX_SPOT_TEX_LIGHTS_PER_TILE 4
+
+#define ANKI_RENDERER_TILES_X_COUNT 16
+#define ANKI_RENDERER_TILES_Y_COUNT 16
+
+/// @}
+
 #endif

+ 2 - 2
include/anki/math/Math.h → include/anki/Math.h

@@ -1,5 +1,5 @@
-#ifndef ANKI_MATH_MATH_H
-#define ANKI_MATH_MATH_H
+#ifndef ANKI_MATH_H
+#define ANKI_MATH_H
 
 #include "anki/math/CommonIncludes.h"
 #include "anki/math/CommonSrc.h"

+ 1 - 1
include/anki/collision/CollisionShape.h

@@ -25,7 +25,7 @@ public:
 		CST_SPHERE,
 		CST_AABB,
 		CST_OBB,
-		CST_FRUSTUM
+		CST_FRUSTUM,
 	};
 
 	/// Generic mutable visitor

+ 1 - 1
include/anki/collision/Frustum.h

@@ -4,7 +4,7 @@
 #include "anki/collision/CollisionShape.h"
 #include "anki/collision/Plane.h"
 #include "anki/collision/Obb.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include <array>
 
 namespace anki {

+ 1 - 1
include/anki/collision/Obb.h

@@ -2,7 +2,7 @@
 #define ANKI_COLLISION_OBB_H
 
 #include "anki/collision/CollisionShape.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include <array>
 
 namespace anki {

+ 1 - 1
include/anki/collision/Plane.h

@@ -2,7 +2,7 @@
 #define ANKI_COLLISION_PLANE_H
 
 #include "anki/collision/CollisionShape.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/collision/Ray.h

@@ -2,7 +2,7 @@
 #define ANKI_COLLISION_RAY_H
 
 #include "anki/collision/CollisionShape.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/collision/Sphere.h

@@ -2,7 +2,7 @@
 #define ANKI_COLLISION_SPHERE_H
 
 #include "anki/collision/CollisionShape.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/event/Event.h

@@ -3,7 +3,7 @@
 
 #include "anki/scene/Common.h"
 #include "anki/util/Bitset.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/event/EventManager.h

@@ -5,7 +5,7 @@
 #include "anki/util/Vector.h"
 #include "anki/util/StdTypes.h"
 #include "anki/scene/Common.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/event/LightEvent.h

@@ -2,7 +2,7 @@
 #define ANKI_EVENT_LIGHT_EVENT_H
 
 #include "anki/event/Event.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/event/MovableEvent.h

@@ -2,7 +2,7 @@
 #define ANKI_EVENT_MOVABLE_EVENT_H
 
 #include "anki/event/Event.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/event/SceneAmbientColorEvent.h

@@ -2,7 +2,7 @@
 #define ANKI_EVENT_SCENE_AMBIENT_COLOR_EVENT_H
 
 #include "anki/event/Event.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/gl/GlState.h

@@ -6,7 +6,7 @@
 #include "anki/util/Assert.h"
 #include "anki/util/StdTypes.h"
 #include "anki/util/Array.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 3 - 0
include/anki/gl/Ubo.h

@@ -15,6 +15,9 @@ class Ubo: public BufferObject
 public:
 	void create(PtrSize size, void* data)
 	{
+		// XXX GL_MAX_UNIFORM_BLOCK_SIZE
+		GLint64 maxBufferSize;
+		glGetInteger64v(GL_MAX_UNIFORM_BLOCK_SIZE, &maxBufferSize);
 		BufferObject::create(GL_UNIFORM_BUFFER, size, data, GL_DYNAMIC_DRAW);
 	}
 };

+ 1 - 1
include/anki/input/Input.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_INPUT_INPUT_H
 #define ANKI_INPUT_INPUT_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/util/Singleton.h"
 #include "anki/util/Array.h"
 #include "anki/util/StdTypes.h"

+ 1 - 1
include/anki/physics/Character.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_PHYSICS_CHARACTER_H
 #define ANKI_PHYSICS_CHARACTER_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include <memory>
 
 class btPairCachingGhostObject;

+ 1 - 1
include/anki/physics/Converters.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_PHYSICS_CONVERTORS_H
 #define ANKI_PHYSICS_CONVERTORS_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include <btBulletCollisionCommon.h>
 #include <btBulletDynamicsCommon.h>
 

+ 1 - 1
include/anki/physics/RigidBody.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_PHYSICS_RIGID_BODY_H
 #define ANKI_PHYSICS_RIGID_BODY_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/physics/MotionState.h"
 #include <btBulletDynamicsCommon.h>
 #include <btBulletCollisionCommon.h>

+ 1 - 1
include/anki/renderer/DebugDrawer.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_RENDERER_DEBUG_DRAWER_H
 #define ANKI_RENDERER_DEBUG_DRAWER_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/gl/Vbo.h"
 #include "anki/gl/Vao.h"
 #include "anki/resource/Resource.h"

+ 14 - 6
include/anki/renderer/Is.h

@@ -6,7 +6,7 @@
 #include "anki/resource/Resource.h"
 #include "anki/resource/ShaderProgramResource.h"
 #include "anki/gl/Gl.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/renderer/Sm.h"
 #include "anki/util/StdTypes.h"
 #include "anki/util/Array.h"
@@ -29,10 +29,15 @@ class Is: private RenderingPass
 	friend struct UpdateTilesJob;
 
 public:
-	static const U MAX_LIGHTS_PER_TILE = 32;
+	static const U MAX_POINT_LIGHTS_PER_TILE = 24;
+	static const U MAX_SPOT_LIGHTS_PER_TILE = 4;
+	static const U MAX_SPOT_TEX_LIGHTS_PER_TILE = 4;
 
-	static const U MAX_POINT_LIGHTS = 512;
+	static const U MAX_POINT_LIGHTS = 512 - 16;
 	static const U MAX_SPOT_LIGHTS = 8;
+	static const U MAX_SPOT_TEX_LIGHTS = 8;
+	static const U MAX_LIGHTS = MAX_POINT_LIGHTS + MAX_SPOT_LIGHTS 
+		+ MAX_SPOT_TEX_LIGHTS;
 
 	Is(Renderer* r);
 	~Is();
@@ -60,21 +65,24 @@ private:
 	/// The IS FBO
 	Fbo fbo;
 
+	/// @name GPU buffers
+	/// @{
+
 	/// Contains common data for all shader programs
 	Ubo commonUbo;
 
 	/// Track the updates of commonUbo
 	U32 commonUboUpdateTimestamp = Timestamp::getTimestamp();
 
-	/// Contains info of for lights
-	Ubo pointLightsUbo;
-	Ubo spotLightsUbo;
+	/// Contains info of lights
+	Ubo lightsUbo;
 
 	/// Contains the indices of lights per tile
 	Ubo tilesUbo;
 
 	/// XXX
 	BufferObject tilegridBuffer;
+	/// @}
 
 	/// Light shaders
 	ShaderProgramResourcePointer lightPassProg;

+ 1 - 1
include/anki/renderer/Renderer.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_RENDERER_RENDERER_H
 #define ANKI_RENDERER_RENDERER_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/resource/TextureResource.h"
 #include "anki/resource/ShaderProgramResource.h"
 #include "anki/resource/Resource.h"

+ 3 - 12
include/anki/renderer/Tiler.h

@@ -2,7 +2,7 @@
 #define ANKI_RENDERER_TILER_H
 
 #include "anki/util/StdTypes.h"
-#include "anki/collision/Collision.h"
+#include "anki/Collision.h"
 #include "anki/gl/Gl.h"
 #include "anki/resource/Resource.h"
 #include "anki/core/Timestamp.h"
@@ -23,13 +23,7 @@ class Tiler
 	friend struct UpdatePlanesPerspectiveCameraJob;
 
 public:
-	// Config. These values affect the size of the uniform blocks and keep in
-	// mind that there are size limitations in uniform blocks.
-	static const U TILES_X_COUNT = 16;
-	static const U TILES_Y_COUNT = 16;
-	static const U TILES_COUNT = TILES_X_COUNT * TILES_Y_COUNT;
-
-	typedef std::bitset<TILES_COUNT> Bitset;
+	typedef std::bitset<ANKI_RENDERER_TILES_COUNT> Bitset;
 
 	Tiler();
 	~Tiler();
@@ -43,9 +37,8 @@ public:
 	void updateTiles(Camera& cam);
 
 	/// Test against all tiles
-	Bool test2(
+	Bool test(
 		const CollisionShape& cs,
-		const Aabb& aabb,
 		Bool nearPlane,
 		Bitset* mask) const;
 
@@ -59,8 +52,6 @@ private:
 	Plane* nearPlanesW = nullptr;
 	Plane* farPlanesW = nullptr;
 
-	typedef F32 PixelArray[TILES_Y_COUNT][TILES_X_COUNT][2];
-
 	/// The timestamp of the 4 planes update
 	U32 planes4UpdateTimestamp = Timestamp::getTimestamp();
 

+ 1 - 1
include/anki/resource/Material.h

@@ -5,7 +5,7 @@
 #include "anki/resource/Resource.h"
 #include "anki/util/ConstCharPtrHashMap.h"
 #include "anki/util/StringList.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/util/Visitor.h"
 #include "anki/util/NonCopyable.h"
 #include "anki/gl/Ogl.h"

+ 1 - 1
include/anki/resource/Mesh.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_RESOURCE_MESH_H
 #define ANKI_RESOURCE_MESH_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/gl/Vbo.h"
 #include "anki/collision/Obb.h"
 #include "anki/util/Vector.h"

+ 1 - 1
include/anki/resource/MeshLoader.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_RESOURCE_MESH_LOADER_H
 #define ANKI_RESOURCE_MESH_LOADER_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/util/Vector.h"
 #include "anki/util/Array.h"
 #include <string>

+ 1 - 1
include/anki/resource/ParticleEmitterResource.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_RESOURCE_PARTICLE_EMITTER_RSRC_H
 #define ANKI_RESOURCE_PARTICLE_EMITTER_RSRC_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/resource/Resource.h"
 
 namespace anki {

+ 1 - 1
include/anki/resource/Path.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_RESOURCE_PATH_H
 #define ANKI_RESOURCE_PATH_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 
 namespace anki {

+ 1 - 1
include/anki/resource/SkelAnim.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_RESOURCE_SKEL_ANIM_H
 #define ANKI_RESOURCE_SKEL_ANIM_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/util/Vector.h"
 
 

+ 1 - 1
include/anki/resource/Skeleton.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_RESOURCE_SKELETON_H
 #define ANKI_RESOURCE_SKELETON_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/util/Vector.h"
 #include <array>
 

+ 1 - 1
include/anki/scene/Grid.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_SCENE_GRID_H
 #define ANKI_SCENE_GRID_H
 
-#include "anki/collision/Collision.h"
+#include "anki/Collision.h"
 #include "anki/scene/Common.h"
 
 namespace anki {

+ 1 - 1
include/anki/scene/Movable.h

@@ -3,7 +3,7 @@
 
 #include "anki/util/Object.h"
 #include "anki/util/Bitset.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/core/Timestamp.h"
 #include "anki/scene/Common.h"
 #include <algorithm> // For std::find

+ 2 - 2
include/anki/scene/Property.h

@@ -6,10 +6,10 @@
 #include "anki/util/Assert.h"
 #include "anki/util/NonCopyable.h"
 #include "anki/util/Visitor.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/resource/Resource.h"
 #include "anki/resource/TextureResource.h"
-#include "anki/collision/Collision.h"
+#include "anki/Collision.h"
 #include "anki/util/ConstCharPtrHashMap.h"
 
 namespace anki {

+ 1 - 1
include/anki/scene/SceneGraph.h

@@ -5,7 +5,7 @@
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/Visibility.h"
 #include "anki/core/Timestamp.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/util/Singleton.h"
 #include "anki/util/HighRezTimer.h"
 

+ 1 - 1
include/anki/scene/Sector.h

@@ -2,7 +2,7 @@
 #define ANKI_SCENE_SECTOR_H
 
 #include "anki/scene/Octree.h"
-#include "anki/collision/Collision.h"
+#include "anki/Collision.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/scene/SkinNode.h

@@ -6,7 +6,7 @@
 #include "anki/scene/Movable.h"
 #include "anki/scene/Spatial.h"
 #include "anki/resource/Model.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/scene/Spatial.h

@@ -2,7 +2,7 @@
 #define ANKI_SCENE_SPATIAL_H
 
 #include "anki/scene/Common.h"
-#include "anki/collision/Collision.h"
+#include "anki/Collision.h"
 #include "anki/util/Bitset.h"
 #include "anki/core/Timestamp.h"
 #include <bitset>

+ 1 - 1
include/anki/ui/UiCommon.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_UI_UI_COMMON_H
 #define ANKI_UI_UI_COMMON_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/util/Allocator.h"
 
 namespace anki {

+ 1 - 1
include/anki/ui/UiFont.h

@@ -2,7 +2,7 @@
 #define ANKI_UI_UI_FONT_H
 
 #include <boost/ptr_container/ptr_vector.hpp>
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
include/anki/ui/UiFtFontLoader.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_UI_UI_FT_FONT_LOADER_H
 #define ANKI_UI_UI_FT_FONT_LOADER_H
 
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/util/Vector.h"
 #include <boost/range/iterator_range.hpp>
 #include <ft2build.h>

+ 1 - 1
include/anki/ui/UiPainterDevice.h

@@ -2,7 +2,7 @@
 #define ANKI_UI_UI_PAINTER_DEVICE_H
 
 #include "anki/gl/Fbo.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 27 - 8
shaders/IsBinLightTemplate.glsl

@@ -1,31 +1,50 @@
 // Template function that is used to bin lights to a tile
 
-#if !defined(LIGHT_TYPE) || !defined(PLANE_TEST_FUNC) || !defined(COUNTER)
+#if !defined(TYPE) || !defined(NAME)
 #	error See file
 #endif
 
-#define FUNC_NAME bin ## LIGHT_TYPE ## COUNTER
+#define CONCAT(x, y) x##y
 
-void FUNC_NAME(uint lightIndex)
+void CONCAT(bin, TYPE)(uint lightIndex)
 {
-	LIGHT_TYPE light = lights.
+	LIGHT_TYPE light = lights. CONCAT(NAME, Lights) [lightIndex];
 
 	uvec2 from = uvec2(0, 0);
 	uvec2 to = uvec2(TILES_X_COUNT, TILES_Y_COUNT);
 
 	while(1)
 	{
-		uvec2 m = (to - from) / uvec2(2);
+		uvec2 m = (to - from) / uvec2(2); // Middle dist
 
 		// Handle final
 		if(m.x == 0 || m.y == 0)
 		{
-			if(PLANE_TEST_FUNC(light, tilegrid.planesFar[tileY][tileX])
-				&& PLANE_TEST_FUNC(light, tilegrid.planesNear[tileY][tileX]))
+			if(CONCAT(NAME, LightInsidePlane)(
+				light, tilegrid.planesFar[tileY][tileX])
+				&& CONCAT(NAME, LightInsidePlane)(
+				light, tilegrid.planesNear[tileY][tileX]))
 			{
 				// It's inside tile
-				uint pos = atomicCounterIncrement(COUNTER);
+				uint pos = 
+					atomicCounterIncrement(CONCAT(NAME, LightsCounter));
+
+				// Bin it
+				tiles.tile[tileY][tileX]. CONCAT(NAME, LightIndices) [pos] = 
+					lightIndex;
 			}
+
+			break;
+		}
+
+		// do the plane checks
+		bool inside[2][2];
+
+		// Top looking plane check
+		if(CONCAT(NAME, LightInsidePlane)(
+			light, tilegrid.planesY[from.y + m.y - 1]))
+		{
+			inside[][]
 		}
 	}
 }

+ 29 - 9
shaders/IsCommon.glsl

@@ -1,10 +1,12 @@
 // Contains common structures for IS
 
+// Plane
 struct Plane
 {
 	vec4 normalOffset;
 };
 
+// Contains the plane grid
 struct Tilegrid
 {
 	Plane planesX[TILES_X_COUNT - 1];
@@ -13,41 +15,59 @@ struct Tilegrid
 	Plane planesFar[TILES_Y_COUNT][TILES_X_COUNT];
 };
 
+// Representation of a tile
 struct Tile
 {
 	uvec4 lightsCount;
-#if __VERSION__ == 430
+#if __VERSION__ > 430
 	uint pointLightIndices[MAX_POINT_LIGHTS_PER_TILE];
 	uint spotLightIndices[MAX_SPOT_LIGHTS_PER_TILE];
-	uint spotLightTexIndices[MAX_SPOT_LIGHTS_TEX_PER_TILE];
+	uint spotTexLightndices[MAX_SPOT_TEX_LIGHTS_PER_TILE];
 #else
 	uvec4 pointLightIndices[MAX_POINT_LIGHTS_PER_TILE / 4];
 	uvec4 spotLightIndices[MAX_SPOT_LIGHTS_PER_TILE / 4];
-	uvec4 spotLightTexIndices[MAX_SPOT_LIGHTS_TEX_PER_TILE / 4];
+	uvec4 spotTexLightIndices[MAX_SPOT_TEX_LIGHTS_PER_TILE / 4];
 #endif
 };
 
+// A container of tiles
+struct Tiles
+{
+	Tile tiles[TILES_Y_COUNT][TILES_X_COUNT];
+};
+
+// The base of all lights
 struct Light
 {
 	vec4 posRadius; // xyz: Light pos in eye space. w: The radius
-	vec4 diffuseColorShadowmapId;
-	vec4 specularColorTexId;
+	vec4 diffuseColorShadowmapId; // xyz: diff color, w: shadowmap tex ID
+	vec4 specularColorTexId; // xyz: spec color, w: diffuse tex ID
 };
 
+// Point light
 #define PointLight Light
 
+// Spot light
 struct SpotLight
 {
-	Light light;
-	vec4 lightDirection;
+	Light lightBase;
+	vec4 lightDir;
 	vec4 outerCosInnerCos;
+	vec4 extendPoints[4]; // The positions of the 4 camera points
+};
+
+// Spot light with texture
+struct SpotTexLight
+{
+	SpotLight spotLightbase;
 	mat4 texProjectionMat;
-	vec4 extendPoints[4];
 };
 
+// A container of many lights
 struct Lights
 {
-	uvec4 count;
+	uvec4 count; // x: points, z: 
 	PointLight pointLights[MAX_POINT_LIGHTS];
 	SpotLight spotLights[MAX_SPOT_LIGHTS];
+	SpotTexLight spotTexLights[MAX_SPOT_TEX_LIGHTS];
 };

+ 9 - 3
shaders/IsUpdateTiles.glsl

@@ -38,9 +38,9 @@ layout(std430, binding = 2) buffer spotLightsCountBuffer
 {
 	atomic_uint spotLightsCount[TILES_Y_COUNT][TILES_X_COUNT];
 };
-layout(std430, binding = 3) buffer spotLightsTexCountBuffer
+layout(std430, binding = 3) buffer spotTexLightsCountBuffer
 {
-	atomic_uint spotLightsTexCount[TILES_Y_COUNT][TILES_X_COUNT];
+	atomic_uint spotTexLightsCount[TILES_Y_COUNT][TILES_X_COUNT];
 };
 
 //
@@ -60,7 +60,7 @@ bool pointLightInsidePlane(in PointLight light, in Plane plane)
 // Spot light inside plane
 bool spotLightInsidePlane(in SpotLight light, in Plane plane)
 {
-	if(pointLightInsidePlane(light.light, plane))
+	if(pointLightInsidePlane(light.lightBase, plane))
 	{
 		return true;
 	}
@@ -78,6 +78,12 @@ bool spotLightInsidePlane(in SpotLight light, in Plane plane)
 	return false;
 }
 
+// Spot tex light inside plane
+bool spotTexLightInsidePlane(in SpotTexLight light, in Plane plane)
+{
+	return pointLightInsidePlane(light.spotLightBase, plane);
+}
+
 // main
 void main()
 {

+ 2 - 2
src/collision/CollisionAlgorithms.cpp

@@ -1,7 +1,7 @@
 #include "anki/collision/CollisionAlgorithms.h"
-#include "anki/collision/Collision.h"
+#include "anki/Collision.h"
 #include "anki/util/Assert.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include <limits>
 
 namespace anki {

+ 1 - 1
src/collision/CollisionShape.cpp

@@ -1,5 +1,5 @@
 #include "anki/collision/CollisionShape.h"
-#include "anki/collision/Collision.h"
+#include "anki/Collision.h"
 
 namespace anki {
 

+ 1 - 1
src/gl/ShaderProgram.cpp

@@ -1,7 +1,7 @@
 #include "anki/gl/ShaderProgram.h"
 #include "anki/gl/GlException.h"
 #include "anki/gl/GlState.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 #include "anki/util/Exception.h"
 #include "anki/gl/Texture.h"
 #include "anki/core/Logger.h"

+ 1 - 1
src/renderer/DebugDrawer.cpp

@@ -1,7 +1,7 @@
 #include "anki/renderer/DebugDrawer.h"
 #include "anki/resource/ShaderProgramResource.h"
 #include "anki/physics/Converters.h"
-#include "anki/collision/Collision.h"
+#include "anki/Collision.h"
 #include "anki/scene/Scene.h"
 #include "anki/resource/TextureResource.h"
 #include "anki/renderer/Renderer.h"

+ 185 - 171
src/renderer/Is.cpp

@@ -7,6 +7,8 @@
 
 namespace anki {
 
+//==============================================================================
+
 //==============================================================================
 static Bool groundVectorsEqual(const Vec3& prev, const Vec3& crnt)
 {
@@ -24,72 +26,72 @@ static Bool groundVectorsEqual(const Vec3& prev, const Vec3& crnt)
 
 // Shader structs and block representations. All positions and directions in
 // viewspace
+// For documentation see the shaders
 
 namespace shader {
 
-struct Light
+struct Plane
 {
-	/// xyz: Light pos in eye space. w: The radius. In viewspace
-	Vec4 posRadius;
-	Vec4 diffuseColorShadowmapId;
-	Vec4 specularColorTexId;
+	Vec3 normal;
+	F32 offset;
 };
 
-struct PointLight: Light
-{};
-
-struct SpotLight: Light
+struct Tilegrid
 {
-	Vec4 lightDir; ///< xyz: Dir vector
-	Vec4 outerCosInnerCos; ///< x: outer angle cos, y: inner
-	Mat4 texProjectionMat; ///< Texture projection matrix
-	Vec4 extendPoints[4]; ///< The positions of the 4 camera points
+	Plane planesX[Is::TILES_X_COUNT - 1];
+	Plane planesY[Is::TILES_Y_COUNT - 1];
+	Plane planesNear[Is::TILES_Y_COUNT][Is::TILES_X_COUNT];
+	Plane planesFar[Is::TILES_Y_COUNT][Is::TILES_X_COUNT];
 };
 
-struct PointLights
+struct Tile
 {
-	PointLight lights[Is::MAX_POINT_LIGHTS];
+	U32 lightsCount[4]; 
+	U32 pointLightIndices[Is::MAX_POINT_LIGHTS_PER_TILE];
+	U32 spotLightIndices[Is::MAX_SPOT_LIGHTS_PER_TILE];
+	U32 spotTexLightndices[Is::MAX_SPOT_TEX_LIGHTS_PER_TILE];
 };
 
-struct SpotLights
+struct Tiles
 {
-	SpotLight lights[Is::MAX_SPOT_LIGHTS];
+	Tile tiles[Is::TILES_Y_COUNT][Is::TILES_X_COUNT];
 };
 
-struct Tile
+struct Light
 {
-	U32 lightsCount[3]; ///< 0: Point lights number, 1: Spot lights number
-	U32 padding[1];
-	// When change this change the writeTilesUbo as well
-	Array<U32, Is::MAX_LIGHTS_PER_TILE> lightIndices;
+	Vec4 posRadius;
+	Vec4 diffuseColorShadowmapId;
+	Vec4 specularColorTexId;
 };
 
-struct Tiles
+struct PointLight: Light
+{};
+
+struct SpotLight: Light
 {
-	Array<Tile, Tiler::TILES_X_COUNT * Tiler::TILES_Y_COUNT> tiles;
+	Vec4 lightDir;
+	Vec4 outerCosInnerCos;
+	Vec4 extendPoints[4]; 
 };
 
-struct CommonUniforms
+struct SpotTexLight: SpotLight
 {
-	Vec4 planes;
-	Vec4 sceneAmbientColor;
-	Vec4 groundLightDir;
+	Mat4 texProjectionMat; ///< Texture projection matrix
 };
 
-const U tilegridPlanesCount = 
-	(Tiler::TILES_X_COUNT - 1) * 2 // planes J
-	+ (Tiler::TILES_Y_COUNT - 1) * 2  // planes I
-	+ (Tiler::TILES_COUNT * 2); // near far planes
-
-struct Plane
+struct Lights
 {
-	Vec3 normal;
-	F32 offset;
+	U32 count[4];
+	PointLight pointLights[Is::MAX_POINT_LIGHTS];
+	SpotLight spotLights[Is::MAX_SPOT_LIGHTS];
+	SpotTexLight spotTexLights[Is::MAX_SPOT_TEX_LIGHTS];
 };
 
-struct Tilegrid
+struct CommonUniforms
 {
-	Array<Plane, tilegridPlanesCount> planes;
+	Vec4 planes;
+	Vec4 sceneAmbientColor;
+	Vec4 groundLightDir;
 };
 
 } // end namespace shader
@@ -98,79 +100,82 @@ struct Tilegrid
 
 // Threading jobs
 
-/// Job to update point lights
-struct WritePointLightsUbo: ThreadJob
+/// Write the lights to a client buffer
+struct WriteLights: ThreadJob
 {
-	shader::PointLight* shaderLights = nullptr; ///< Mapped UBO
-	PointLight** visibleLights = nullptr;
-	U32 visibleLightsCount = 0;
+	shader::Lights* gpuLights;
+	SceneVector<Light*>::iterator lightsBegin; // XXX Make them const
+	SceneVector<Light*>::iterator lightsEnd;
 	Is* is = nullptr;
 
+	std::atomic<U32>* pointLightsCount = nullptr;
+	std::atomic<U32>* spotLightsCount = nullptr;
+	std::atomic<U32>* spotTexLightsCount = nullptr;
+
 	void operator()(U threadId, U threadsCount)
 	{
+		U ligthsCount = lightsEnd - lightsBegin;
+
+		// Count job bounds
 		U64 start, end;
-		choseStartEnd(threadId, threadsCount, visibleLightsCount, start, end);
-		
-		const Camera* cam = is->cam;
+		choseStartEnd(threadId, threadsCount, ligthsCount, start, end);
 
+		// Run all lights
 		for(U64 i = start; i < end; i++)
 		{
-			ANKI_ASSERT(i < Is::MAX_POINT_LIGHTS);
-			ANKI_ASSERT(i < visibleLightsCount);
-
-			shader::PointLight& pl = shaderLights[i];
-			const PointLight& light = *visibleLights[i];
-
-			Vec3 pos = light.getWorldTransform().getOrigin().getTransformed(
-				cam->getViewMatrix());
+			Light* light = lightsBegin + i;
 
-			pl.posRadius = Vec4(pos, light.getRadius());
-			pl.diffuseColorShadowmapId = light.getDiffuseColor();
-			pl.specularColorTexId = light.getSpecularColor();
+			switch(light->getLightType())
+			{
+			case Light::LT_POINT:
+				doLight(*static_cast<PointLight*>(light));
+				break;
+			case Light::LT_SPOT:
+				doLight(*static_cast<SpotLight*>(light));
+				break;
+			}
 		}
 	}
-};
 
-/// Job to update spot lights
-struct WriteSpotLightsUbo: ThreadJob
-{
-	shader::SpotLight* shaderLights = nullptr; ///< Mapped UBO
-	SpotLight** visibleLights = nullptr;
-	U32 visibleLightsCount = 0;
-	Is* is = nullptr;
-
-	void operator()(U threadId, U threadsCount)
+	/// Copy CPU light to GPU buffer
+	void doLight(PointLight& light)
 	{
-		U64 start, end;
-		choseStartEnd(threadId, threadsCount, visibleLightsCount, start, end);
+		// Get GPU light
+		U32 pos = pointLightsCount->fetch_add(1);
+		// Use % to avoid overflows
+		pos = pos % Is::MAX_POINT_LIGHTS;
 
-		const Camera* cam = is->cam;
-
-		for(U64 i = start; i < end; i++)
-		{
-			ANKI_ASSERT(i < Is::MAX_SPOT_LIGHTS);
-			ANKI_ASSERT(i < visibleLightsCount);
+		shader::PointLight& slight = gpuLights->pointLights[pos];
 
-			shader::SpotLight& slight = shaderLights[i];
-			const SpotLight& light = *visibleLights[i];
+		const Camera* cam = is->cam;
+		ANKI_ASSERT(cam);
+	
+		Vec3 pos = light.getWorldTransform().getOrigin().getTransformed(
+			cam->getViewMatrix());
 
-			Vec3 pos = light.getWorldTransform().getOrigin().getTransformed(
-				cam->getViewMatrix());
+		slight.posRadius = Vec4(pos, light.getRadius());
+		slight.diffuseColorShadowmapId = light.getDiffuseColor();
+		slight.specularColorTexId = light.getSpecularColor();
+	}
 
-			slight.posRadius = Vec4(pos, light.getDistance());
+	/// Copy CPU spot light to GPU buffer
+	void doLight(SpotLight& light)
+	{
+		Bool isTexLight = light.getShadowEnabled();
 
-			slight.diffuseColorShadowmapId = 
-				Vec4(light.getDiffuseColor().xyz(), 0);
+		U32 pos;
+		shader::SpotLight* baseslight = nullptr;
+		if(isTexLight)
+		{
+			// Spot tex light
 
-			slight.specularColorTexId = light.getSpecularColor();
+			pos = spotTexLightsCount->fetch_add(1);
+			pos = pos % Is::MAX_SPOT_TEX_LIGHTS;
 
-			Vec3 lightDir = -light.getWorldTransform().getRotation().getZAxis();
-			lightDir = cam->getViewMatrix().getRotationPart() * lightDir;
-			slight.lightDir = Vec4(lightDir, 0.0);
-			
-			slight.outerCosInnerCos = Vec4(light.getOuterAngleCos(),
-				light.getInnerAngleCos(), 1.0, 1.0);
+			shader::SpotTexLight& slight = gpuLights->spotTexLights[pos];
+			baseslight = &slight;
 
+			// Write matrix
 			static const Mat4 biasMat4(
 				0.5, 0.0, 0.0, 0.5, 
 				0.0, 0.5, 0.0, 0.5, 
@@ -184,113 +189,122 @@ struct WriteSpotLightsUbo: ThreadJob
 			// Transpose because of driver bug
 			slight.texProjectionMat.transpose();
 
-			// extend points
-			const PerspectiveFrustum& frustum = light.getFrustum();
+			// Write tex IDs
+			slight.diffuseColorShadowmapId.w() = pos;
+		}
+		else
+		{
+			// Spot light
 
-			for(U i = 0; i < 4; i++)
-			{
-				Vec3 dir = light.getWorldTransform().getOrigin() 
-					+ frustum.getDirections()[i];
-				dir.transform(cam->getViewMatrix());
-				slight.extendPoints[i] = Vec4(dir, 1.0);
-			}
+			pos = spotLightsCount->fetch_add(1);
+			pos = pos % Is::MAX_SPOT_LIGHTS;
+
+			shader::SpotLight& slight = gpuLights->spotLights[pos];
+			baseslight = &slight;
+		}
+
+		// Write common stuff
+		ANKI_ASSERT(baseslight);
+
+		// Pos & dist
+		Vec3 pos = light.getWorldTransform().getOrigin().getTransformed(
+				cam->getViewMatrix());
+		baseslight->posRadius = Vec4(pos, light.getDistance());
+
+		// Diff color
+		baseslight->diffuseColorShadowmapId = Vec4(
+			light.getDiffuseColor().xyz(), 
+			slight.diffuseColorShadowmapId.w());
+
+		// Spec color
+		slight.specularColorTexId = light.getSpecularColor();
+
+		// Light dir
+		Vec3 lightDir = -light.getWorldTransform().getRotation().getZAxis();
+		lightDir = cam->getViewMatrix().getRotationPart() * lightDir;
+		baseslight->lightDir = Vec4(lightDir, 0.0);
+		
+		// Angles
+		slight.outerCosInnerCos = Vec4(light.getOuterAngleCos(),
+			light.getInnerAngleCos(), 1.0, 1.0);
+
+		// extend points
+		const PerspectiveFrustum& frustum = light.getFrustum();
+
+		for(U i = 0; i < 4; i++)
+		{
+			Vec3 dir = light.getWorldTransform().getOrigin() 
+				+ frustum.getDirections()[i];
+			dir.transform(cam->getViewMatrix());
+			baseslight->extendPoints[i] = Vec4(dir, 1.0);
 		}
 	}
 };
 
 /// A job to write the tiles UBO
-struct WriteTilesUboJob: ThreadJob
+struct UpdateTilesJob: ThreadJob
 {
-	PointLight** visiblePointLights = nullptr;
-	U32 visiblePointLightsCount = 0;
-	
-	SpotLight** visibleSpotLights = nullptr;
-	U32 visibleSpotLightsCount = 0; ///< Both shadow and not
-
-	shader::Tile* shaderTiles = nullptr; ///< Mapped UBO
-	U32 maxLightsPerTile = 0;
+	Tiles* tiles = nullptr;
+	Lights* lights = nullptr;
 	Is* is = nullptr;
+	Tiler* tiler = nullptr;
+
+	std::atomic<U32> (*pointLightsCount)[Is::TILES_Y_COUNT][Is::TILES_X_COUNT];
+	std::atomic<U32> (*spotLightsCount)[Is::TILES_Y_COUNT][Is::TILES_X_COUNT];
+	std::atomic<U32> 
+		(*spotTexLightsCount)[Is::TILES_Y_COUNT][Is::TILES_X_COUNT];
 
 	void operator()(U threadId, U threadsCount)
 	{
-		U64 start, end;
-		choseStartEnd(threadId, threadsCount, 
-			Tiler::TILES_X_COUNT * Tiler::TILES_Y_COUNT, start, end);
+		U pointLightsCount = lights->count[0];
+		U spotLightsCount = lights->count[2];
+		U spotTexLightsCount = lights->count[3];
 
-		for(U32 i = start; i < end; i++)
-		{
-			shader::Tile& stile = shaderTiles[i];
+		U lightsCount = pointLightsCount + spotLightsCount + spotTexLightsCount;
+		ANKI_ASSERT(lightsCount <= Is::MAX_LIGHTS);
 
-			doTile(i, stile);
-		}
-	}
+		U64 start, end;
+		choseStartEnd(threadId, threadsCount, lightsCount, start, end);
 
-	/// Do a tile
-	void doTile(U tileId, shader::Tile& stile)
-	{
-		auto& lightIndices = stile.lightIndices;
+		const Tiler& tiler = is->r.getTiler();
 
-		// Point lights
-		//
-		U pointLightsInTileCount = 0;
-		for(U i = 0; i < visiblePointLightsCount; i++)
+		for(U32 i = start; i < end; i++)
 		{
-			const PointLight& light = *visiblePointLights[i];
-
-			if(light.getTilerBitset().test(tileId))
+			if(i < pointLightsCount)
 			{
-				// Use % to avoid overflows
-				const U id = pointLightsInTileCount % Is::MAX_LIGHTS_PER_TILE;
-				lightIndices[id] = i;
-				++pointLightsInTileCount;
-			}
-		}
+				Sphere s(light.posRadius.xyz(), light.posRadius.w());
+				Tiler::Bitset bitset;
+				tiler->test(s, true, &bitset);
 
-		stile.lightsCount[0] = pointLightsInTileCount;
-
-		// Spot lights
-		//
-
-		U spotLightsInTileCount = 0;
-		U spotLightsShadowInTileCount = 0;
-		for(U i = 0; i < visibleSpotLightsCount; i++)
-		{
-			const SpotLight& light = *visibleSpotLights[i];
+				// For all tiles
+				for(U t = 0; t < Tiler::TILES_COUNT; t++)
+				{
+					// If not in tile bye
+					if(!bitset.test(t))
+					{
+						continue;
+					}
 
-			if(light.getTilerBitset().test(tileId))
-			{
-				const U id = (pointLightsInTileCount + spotLightsInTileCount 
-					+ spotLightsShadowInTileCount) 
-					% Is::MAX_LIGHTS_PER_TILE;
+					U x = t % Tiler::TILES_X_COUNT;
+					U y = t / Tiler::TILES_X_COUNT;
 
-				// Use % to avoid overflows
-				lightIndices[id] = i;
+					U pos = (*pointLightsCount)[y][x].fetch_add(1);
 
-				if(light.getShadowEnabled())
-				{
-					++spotLightsShadowInTileCount;
-				}
-				else
-				{
-					++spotLightsInTileCount;
+					if(pos < Is::MAX_POINT_LIGHTS_PER_TILE)
+					{
+						tiles->tiles[y][x].pointLightIndices[pos] = i;
+					}
 				}
 			}
-		}
-
-		stile.lightsCount[1] = spotLightsInTileCount;
-		stile.lightsCount[2] = spotLightsShadowInTileCount;
-
-#if 0
-		U totalLightsInTileCount = std::min(
-			pointLightsInTileCount + spotLightsInTileCount 
-			+ spotLightsShadowInTileCount,
-			Is::MAX_LIGHTS_PER_TILE);
+			else if(i < pointLightsCount + spotLightsCount)
+			{
 
-		if(pointLightsInTileCount + spotLightsInTileCount > maxLightsPerTile)
-		{
-			ANKI_LOGW("Too many lights per tile: " << lightsInTileCount);
+			}
+			else
+			{
+				ANKI_ASSERT(i < lightsCount);
+			}
 		}
-#endif
 	}
 };
 

+ 21 - 14
src/renderer/Tiler.cpp

@@ -10,6 +10,14 @@
 
 namespace anki {
 
+//==============================================================================
+static const U TILES_X_COUNT = ANKI_RENDERER_TILES_X_COUNT;
+static const U TILES_Y_COUNT = ANKI_RENDERER_TILES_Y_COUNT;
+static const U TILES_COUNT = TILES_X_COUNT * TILES_Y_COUNT;
+
+typedef F32 
+	PixelArray[ANKI_RENDERER_TILES_Y_COUNT][ANKI_RENDERER_TILES_X_COUNT][2];
+
 //==============================================================================
 #define CHECK_PLANE_PTR(p_) \
 	ANKI_ASSERT(p_ < &tiler->allPlanes[tiler->allPlanes.size()]);
@@ -21,7 +29,7 @@ struct UpdatePlanesPerspectiveCameraJob: ThreadJob
 	PerspectiveCamera* cam = nullptr;
 	Bool frustumChanged;
 #if ANKI_TILER_ENABLE_GPU
-	const Tiler::PixelArray* pixels = nullptr;
+	const PixelArray* pixels = nullptr;
 #endif
 
 	void operator()(U threadId, U threadsCount)
@@ -40,13 +48,13 @@ struct UpdatePlanesPerspectiveCameraJob: ThreadJob
 			const F32 n = cam->getNear();
 
 			F32 l = 2.0 * n * tan(fx / 2.0);
-			F32 l6 = l / Tiler::TILES_X_COUNT;
+			F32 l6 = l / TILES_X_COUNT;
 			F32 o = 2.0 * n * tan(fy / 2.0);
-			F32 o6 = o / Tiler::TILES_Y_COUNT;
+			F32 o6 = o / TILES_Y_COUNT;
 
 			// First the top looking planes
 			choseStartEnd(
-				threadId, threadsCount, Tiler::TILES_Y_COUNT - 1, start, end);
+				threadId, threadsCount, TILES_Y_COUNT - 1, start, end);
 
 			for(U i = start; i < end; i++)
 			{
@@ -59,7 +67,7 @@ struct UpdatePlanesPerspectiveCameraJob: ThreadJob
 
 			// Then the right looking planes
 			choseStartEnd(
-				threadId, threadsCount, Tiler::TILES_X_COUNT - 1, start, end);
+				threadId, threadsCount, TILES_X_COUNT - 1, start, end);
 
 			for(U j = start; j < end; j++)
 			{
@@ -76,7 +84,7 @@ struct UpdatePlanesPerspectiveCameraJob: ThreadJob
 
 			// First the top looking planes
 			choseStartEnd(
-				threadId, threadsCount, Tiler::TILES_Y_COUNT - 1, start, end);
+				threadId, threadsCount, TILES_Y_COUNT - 1, start, end);
 
 			for(U i = start; i < end; i++)
 			{
@@ -87,7 +95,7 @@ struct UpdatePlanesPerspectiveCameraJob: ThreadJob
 
 			// Then the right looking planes
 			choseStartEnd(
-				threadId, threadsCount, Tiler::TILES_X_COUNT - 1, start, end);
+				threadId, threadsCount, TILES_X_COUNT - 1, start, end);
 
 			for(U j = start; j < end; j++)
 			{
@@ -103,14 +111,14 @@ struct UpdatePlanesPerspectiveCameraJob: ThreadJob
 		Renderer::calcPlanes(Vec2(cam->getNear(), cam->getFar()), rplanes);
 
 		choseStartEnd(
-			threadId, threadsCount, Tiler::TILES_COUNT, start, end);
+			threadId, threadsCount, TILES_COUNT, start, end);
 
 		Plane* nearPlanesW = tiler->nearPlanesW + start;
 		Plane* farPlanesW = tiler->farPlanesW + start;
 		for(U k = start; k < end; ++k)
 		{
-			U j = k % Tiler::TILES_X_COUNT;
-			U i = k / Tiler::TILES_X_COUNT;
+			U j = k % TILES_X_COUNT;
+			U i = k / TILES_X_COUNT;
 
 			// Calculate depth as you do it for the vertex position inside
 			// the shaders
@@ -142,7 +150,7 @@ struct UpdatePlanesPerspectiveCameraJob: ThreadJob
 		Plane& plane = tiler->planesI[i];
 		CHECK_PLANE_PTR(&plane);
 
-		a = Vec3(0.0, (I(i + 1) - I(Tiler::TILES_Y_COUNT) / 2) * o6, -n);
+		a = Vec3(0.0, (I(i + 1) - I(TILES_Y_COUNT) / 2) * o6, -n);
 		b = Vec3(1.0, 0.0, 0.0).cross(a);
 		b.normalize();
 
@@ -157,7 +165,7 @@ struct UpdatePlanesPerspectiveCameraJob: ThreadJob
 		Plane& plane = tiler->planesJ[j];
 		CHECK_PLANE_PTR(&plane);
 
-		a = Vec3((I(j + 1) - I(Tiler::TILES_X_COUNT) / 2) * l6, 0.0, -n);
+		a = Vec3((I(j + 1) - I(TILES_X_COUNT) / 2) * l6, 0.0, -n);
 		b = a.cross(Vec3(0.0, 1.0, 0.0));
 		b.normalize();
 
@@ -324,9 +332,8 @@ void Tiler::updateTiles(Camera& cam)
 }
 
 //==============================================================================
-Bool Tiler::test2(
+Bool Tiler::test(
 	const CollisionShape& cs, 
-	const Aabb& aabb, 
 	Bool nearPlane,
 	Bitset* outBitset) const
 {

+ 1 - 1
src/script/math/Vec2.cpp

@@ -1,5 +1,5 @@
 #include "anki/script/MathCommon.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
src/script/math/Vec3.cpp

@@ -1,5 +1,5 @@
 #include "anki/script/MathCommon.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {
 

+ 1 - 1
src/script/math/Vec4.cpp

@@ -1,5 +1,5 @@
 #include "anki/script/MathCommon.h"
-#include "anki/math/Math.h"
+#include "anki/Math.h"
 
 namespace anki {