2
0
Panagiotis Christopoulos Charitos 13 жил өмнө
parent
commit
1fc7a96952

+ 3 - 2
include/anki/renderer/Drawer.h

@@ -8,8 +8,9 @@ namespace anki {
 class PassLevelKey;
 class Renderer;
 class Frustumable;
-class Renderable;
+class SceneNode;
 class ShaderProgram;
+class Renderable;
 
 /// It includes all the functions to render a Renderable
 class RenderableDrawer
@@ -32,7 +33,7 @@ public:
 	{}
 
 	void render(Frustumable& fr,
-		RenderingStage stage, U32 pass, Renderable& renderable);
+		RenderingStage stage, U32 pass, SceneNode& renderableSceneNode);
 
 private:
 	Renderer* r;

+ 0 - 6
include/anki/scene/ModelNode.h

@@ -85,12 +85,6 @@ public:
 	{
 		return &getWorldTransform();
 	}
-
-	/// Overrides Renderable::getRenderableOrigin
-	Vec3 getRenderableOrigin() const
-	{
-		return getWorldTransform().getOrigin();
-	}
 	/// @}
 
 	/// @name Spatial virtuals

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

@@ -16,7 +16,7 @@ class PropertyMap;
 
 /// Interface for movable scene nodes
 class Movable: public Object<Movable, SceneAllocator<Movable>>,
-	public Flags<U32>
+	public Flags<U8>
 {
 public:
 	typedef Object<Movable, SceneAllocator<Movable>> Base;

+ 4 - 3
include/anki/scene/Octree.h

@@ -144,8 +144,8 @@ public:
 	void placeSceneNode(SceneNode* sn);
 
 	/// Do the visibility tests
-	void doVisibilityTests(const Frustumable& fr, VisibilityTest test,
-		VisibilityTestResults& visibles);
+	void doVisibilityTests(SceneNode& frustumableSceneNode,
+		VisibilityTest test, VisibilityTestResults& visibles);
 
 private:
 	Sector* sector;
@@ -162,7 +162,8 @@ private:
 	OctreeNode* place(const Aabb& aabb);
 
 	/// Recursive method
-	void doVisibilityTestsInternal(const Frustumable& fr, 
+	void doVisibilityTestsInternal(
+		SceneNode& frustumableSceneNode,
 		VisibilityTest test,
 		VisibilityTestResults& visibles,
 		OctreeNode& node);

+ 0 - 6
include/anki/scene/ParticleEmitter.h

@@ -226,12 +226,6 @@ public:
 	{
 		return instancesCount;
 	}
-
-	/// Overrides Renderable::getRenderableOrigin
-	Vec3 getRenderableOrigin() const
-	{
-		return getWorldTransform().getOrigin();
-	}
 	/// @}
 
 	/// @name Movable virtuals

+ 0 - 3
include/anki/scene/Renderable.h

@@ -171,9 +171,6 @@ public:
 		return 1;
 	}
 
-	/// Get the center of the renderable. Used in sorting
-	virtual Vec3 getRenderableOrigin() const = 0;
-
 	/// @name Accessors
 	/// @{
 	RenderableVariables::iterator getVariablesBegin()

+ 13 - 2
include/anki/scene/Scene.h

@@ -1,15 +1,15 @@
 #ifndef ANKI_SCENE_SCENE_H
 #define ANKI_SCENE_SCENE_H
 
+#include "anki/scene/Common.h"
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/VisibilityTester.h"
+#include "anki/scene/Sector.h"
 #include "anki/math/Math.h"
 #include "anki/util/Singleton.h"
-#include "anki/scene/Sector.h"
 #include "anki/util/Vector.h"
 #include "anki/core/Timestamp.h"
 #include "anki/physics/PhysWorld.h"
-#include "anki/scene/Common.h"
 
 namespace anki {
 
@@ -119,6 +119,15 @@ public:
 	{
 		return physics;
 	}
+
+	SectorGroup& getSectorGroup()
+	{
+		return sectorGroup;
+	}
+	const SectorGroup& getSectorGroup() const
+	{
+		return sectorGroup;
+	}
 	/// @}
 
 	void update(F32 prevUpdateTime, F32 crntTime, Renderer& renderer);
@@ -143,6 +152,8 @@ private:
 	VisibilityTester vtester;
 	PhysWorld physics;
 
+	SectorGroup sectorGroup;
+
 	void doVisibilityTests(Camera& cam, Renderer& r);
 
 	/// Put a node in the appropriate containers

+ 0 - 6
include/anki/scene/SkinNode.h

@@ -196,12 +196,6 @@ public:
 	{
 		return &getWorldTransform();
 	}
-
-	/// Overrides Renderable::getRenderableOrigin
-	Vec3 getRenderableOrigin() const
-	{
-		return getWorldTransform().getOrigin();
-	}
 	/// @}
 
 	/// @name Spatial virtuals

+ 4 - 7
include/anki/scene/Spatial.h

@@ -17,10 +17,11 @@ class SceneNode;
 /// Spatial "interface" for scene nodes. It indicates scene nodes that need to 
 /// be placed in the scene's octree and they participate in the visibility 
 /// tests
-class Spatial: public Flags<U32>
+class Spatial: public Flags<U8>
 {
 	friend class OctreeNode;
 	friend class Grid;
+	friend class SceneNode;
 
 public:
 	/// Spatial flags
@@ -34,8 +35,8 @@ public:
 	};
 
 	/// Pass the collision shape here so we can avoid the virtuals
-	Spatial(SceneNode* sceneNode_, CollisionShape* cs)
-		: spatialCs(cs), sceneNode(sceneNode_)
+	Spatial(CollisionShape* cs)
+		: spatialCs(cs)
 	{}
 
 	// Remove from current OctreeNode
@@ -91,7 +92,6 @@ public:
 	{
 		timestamp = Timestamp::getTimestamp();
 		spatialCs->toAabb(aabb);
-		origin = (aabb.getMin() + aabb.getMax()) * 0.5;
 	}
 
 protected:
@@ -100,10 +100,7 @@ protected:
 private:
 	U32 timestamp = Timestamp::getTimestamp();
 	OctreeNode* octreeNode = nullptr; ///< What octree node includes this
-	Grid* grid = nullptr;
 	Aabb aabb; ///< A faster shape
-	SceneNode* sceneNode; ///< Know your father
-	Vec3 origin;
 };
 /// @}
 

+ 3 - 4
include/anki/scene/VisibilityTestResults.h

@@ -22,11 +22,10 @@ enum VisibilityTest
 /// Its actually a container for visible entities. It should be per frame
 struct VisibilityTestResults
 {
-	typedef SceneVector<SceneNode*> Renderables;
-	typedef SceneVector<SceneNode*> Lights;
+	typedef SceneVector<SceneNode*> Container;
 
-	Renderables renderables;
-	Lights lights;
+	Container renderables;
+	Container lights;
 
 	VisibilityTestResults(const SceneAllocator<U8>& frameAlloc)
 		: renderables(frameAlloc), lights(frameAlloc)

+ 1 - 1
src/renderer/Bs.cpp

@@ -31,7 +31,7 @@ void Bs::run()
 		--it)
 	{
 		drawer.render(scene.getActiveCamera(), RenderableDrawer::RS_BLEND,
-			0, *((*it)->getRenderable()));
+			0, *(*it));
 	}
 
 	GlStateSingleton::get().setDepthMaskEnabled(true);

+ 0 - 4
src/renderer/DebugDrawer.cpp

@@ -504,10 +504,6 @@ void SceneDebugDrawer::draw(Frustumable& fr) const
 //==============================================================================
 void SceneDebugDrawer::draw(Spatial& x) const
 {
-	/*const CollisionShape& cs = x.getSpatialCollisionShape();
-
-	CollisionDebugDrawer coldraw(dbg);
-	cs.accept(coldraw);*/
 	CollisionDebugDrawer coldraw(dbg);
 	x.getAabb().accept(coldraw);
 }

+ 9 - 6
src/renderer/Drawer.cpp

@@ -212,10 +212,13 @@ void RenderableDrawer::setupShaderProg(const PassLevelKey& key_,
 
 //==============================================================================
 void RenderableDrawer::render(Frustumable& fr, RenderingStage stage,
-	U32 pass, Renderable& renderable)
+	U32 pass, SceneNode& rsn)
 {
+	Renderable* renderable = rsn.getRenderable();
+	ANKI_ASSERT(renderable);
+
 	/* Instancing */
-	U32 instancesCount = renderable.getRenderableInstancesCount();
+	U32 instancesCount = renderable->getRenderableInstancesCount();
 
 	if(instancesCount < 1)
 	{
@@ -223,7 +226,7 @@ void RenderableDrawer::render(Frustumable& fr, RenderingStage stage,
 	}
 
 	/* Blending */
-	const Material& mtl = renderable.getRenderableMaterial();
+	const Material& mtl = renderable->getRenderableMaterial();
 
 	Bool blending = mtl.isBlendingEnabled();
 
@@ -250,7 +253,7 @@ void RenderableDrawer::render(Frustumable& fr, RenderingStage stage,
 	// Calculate the LOD
 	Vec3 camPos = fr.getFrustumableOrigin();
 
-	F32 dist = (renderable.getRenderableOrigin() - camPos).getLength();
+	F32 dist = (rsn.getSpatial()->getSpatialOrigin() - camPos).getLength();
 	U8 lod = r->calculateLod(dist);
 
 	PassLevelKey key(pass, lod);
@@ -260,11 +263,11 @@ void RenderableDrawer::render(Frustumable& fr, RenderingStage stage,
 	const Vao* vao;
 	U32 indicesCount;
 
-	renderable.getRenderableModelPatchBase().getRenderingData(
+	renderable->getRenderableModelPatchBase().getRenderingData(
 		key, vao, prog, indicesCount);
 
 	// Setup shader
-	setupShaderProg(key, fr, *prog, renderable);
+	setupShaderProg(key, fr, *prog, *renderable);
 
 	// Render
 	ANKI_ASSERT(vao->getAttachmentsCount() > 1);

+ 1 - 1
src/renderer/Ez.cpp

@@ -34,7 +34,7 @@ void Ez::run()
 		it != vi.getRenderablesEnd() && count < maxObjectsToDraw; ++it)
 	{
 		r->getSceneDrawer().render(cam, RenderableDrawer::RS_MATERIAL,
-			0, *((*it)->getRenderable()));
+			0, *(*it));
 		++count;
 	}
 

+ 1 - 1
src/renderer/MainRenderer.cpp

@@ -186,7 +186,7 @@ void MainRenderer::takeScreenshotJpeg(const char* filename)
 
 	if(!outfile)
 	{
-		throw ANKI_EXCEPTION("Cannot open file \"" + filename + "\"");
+		throw ANKI_EXCEPTION("Cannot open file: " + filename);
 	}
 
 	// set jpg params

+ 1 - 1
src/renderer/Ms.cpp

@@ -78,7 +78,7 @@ void Ms::run()
 	for(auto it = vi.getRenderablesBegin(); it != vi.getRenderablesEnd(); ++it)
 	{
 		r->getSceneDrawer().render(r->getScene().getActiveCamera(),
-			RenderableDrawer::RS_MATERIAL, 0, *((*it)->getRenderable()));
+			RenderableDrawer::RS_MATERIAL, 0, *(*it));
 	}
 
 	// restore depth

+ 1 - 1
src/renderer/Sm.cpp

@@ -206,7 +206,7 @@ Sm::Shadowmap* Sm::doLight(Light& light)
 	for(auto it = vi.getRenderablesBegin(); it != vi.getRenderablesEnd(); ++it)
 	{
 		r->getSceneDrawer().render(*fr, RenderableDrawer::RS_MATERIAL,
-			1, *((*it)->getRenderable()));
+			1, *(*it));
 	}
 
 	return &sm;

+ 1 - 1
src/resource/MeshLoader.cpp

@@ -16,7 +16,7 @@ void MeshLoader::load(const char* filename)
 
 		if(!file.is_open())
 		{
-			throw ANKI_EXCEPTION("Cannot open file :" + filename);
+			throw ANKI_EXCEPTION("Cannot open file:" + filename);
 		}
 
 		BinaryStream bs(file.rdbuf());

+ 1 - 1
src/scene/Camera.cpp

@@ -13,7 +13,7 @@ Camera::Camera(CameraType type_,
 	Frustum* frustum) // Spatial & Frustumable
 	:	SceneNode(name, scene),
 		Movable(movableFlags, movParent, *this, getSceneAllocator()),
-		Spatial(this, frustum),
+		Spatial(frustum),
 		Frustumable(frustum),
 		type(type_)
 {}

+ 3 - 3
src/scene/Grid.cpp

@@ -36,13 +36,13 @@ void Grid::removeSceneNode(SceneNode* sn)
 	ANKI_ASSERT(it != sceneNodes.end());
 	sceneNodes.erase(it);
 
-	(*it)->getSpatial()->grid = nullptr;
+	//(*it)->getSpatial()->grid = nullptr;
 }
 
 //==============================================================================
 Bool Grid::placeSceneNode(SceneNode* sn)
 {
-	Spatial* sp = sn->getSpatial();
+	/*Spatial* sp = sn->getSpatial();
 	ANKI_ASSERT(sp);
 
 	if(sp->grid == this)
@@ -54,7 +54,7 @@ Bool Grid::placeSceneNode(SceneNode* sn)
 		sp->grid->removeSceneNode(sn);
 		sp->grid = this;
 		sceneNodes.push_back(sn);
-	}
+	}*/
 
 	return true;
 }

+ 2 - 1
src/scene/Light.cpp

@@ -13,7 +13,8 @@ Light::Light(LightType t, // Light
 	CollisionShape* cs) // Spatial
 	: SceneNode(name, scene),
 		Movable(movableFlags, movParent, *this, getSceneAllocator()),
-		Spatial(this, cs), type(t)
+		Spatial(cs),
+		type(t)
 {
 	addNewProperty(new ReadWritePointerProperty<Vec4>("color", &color));
 

+ 2 - 2
src/scene/ModelNode.cpp

@@ -12,10 +12,10 @@ namespace anki {
 ModelPatchNode::ModelPatchNode(const ModelPatch* modelPatch_,
 	const char* name, Scene* scene,
 	U32 movableFlags, Movable* movParent)
-	: 	SceneNode(name, scene),
+	: SceneNode(name, scene),
 		Movable(movableFlags, movParent, *this, getSceneAllocator()),
 		Renderable(getSceneAllocator()),
-		Spatial(this, &obb), modelPatch(modelPatch_)
+		Spatial(&obb), modelPatch(modelPatch_)
 {
 	Renderable::init(*this);
 }

+ 11 - 8
src/scene/Octree.cpp

@@ -261,18 +261,21 @@ void Octree::calcAabb(U i, U j, U k, const Aabb& paabb, Aabb& out) const
 }
 
 //==============================================================================
-void Octree::doVisibilityTests(const Frustumable& fr, VisibilityTest test,
+void Octree::doVisibilityTests(SceneNode& fsn, VisibilityTest test,
 	VisibilityTestResults& visibles)
 {
-	ANKI_ASSERT(fr.insideFrustum(root.getAabb()));
-	doVisibilityTestsInternal(fr, test, visibles, root);
+	ANKI_ASSERT(fsn.getFrustumable());
+	ANKI_ASSERT(fsn.getFrustumable()->insideFrustum(root.getAabb()));
+	doVisibilityTestsInternal(fsn, test, visibles, root);
 }
 
 //==============================================================================
-void Octree::doVisibilityTestsInternal(const Frustumable& fr, 
+void Octree::doVisibilityTestsInternal(SceneNode& fsn,
 	VisibilityTest test, VisibilityTestResults& visible, OctreeNode& node)
 {
-	// Put my scene nodes
+	const Frustumable& fr = *fsn.getFrustumable();
+
+	// Put node's scene nodes
 	for(SceneNode* sn : node.sceneNodes)
 	{
 		Spatial* sp = sn->getSpatial();
@@ -283,8 +286,8 @@ void Octree::doVisibilityTestsInternal(const Frustumable& fr,
 			Renderable* r = sn->getRenderable();
 			if(r != nullptr && (test & VT_RENDERABLES))
 			{
-				if((test & VT_ONLY_SHADOW_CASTERS) == false
-					|| r->getRenderableMaterial().getShadow())
+				if(!((test & VT_ONLY_SHADOW_CASTERS) == true
+					&& !r->getRenderableMaterial().getShadow()))
 				{
 					visible.renderables.push_back(sn);
 				}
@@ -303,7 +306,7 @@ void Octree::doVisibilityTestsInternal(const Frustumable& fr,
 	{
 		if(onode != nullptr && fr.insideFrustum(onode->getAabb()))
 		{
-			doVisibilityTestsInternal(fr, test, visible, *onode);
+			doVisibilityTestsInternal(fsn, test, visible, *onode);
 		}
 	}
 }

+ 3 - 2
src/scene/ParticleEmitter.cpp

@@ -224,7 +224,7 @@ ParticleEmitter::ParticleEmitter(
 	// Movable
 	U32 movableFlags, Movable* movParent)
 	:	SceneNode(name, scene),
-		Spatial(this, &aabb),
+		Spatial(&aabb),
 		Movable(movableFlags, movParent, *this, getSceneAllocator()),
 		Renderable(getSceneAllocator())
 {
@@ -343,7 +343,8 @@ void ParticleEmitter::frameUpdate(F32 prevUpdateTime, F32 crntTime, I frame)
 	// - Calc the instancing stuff
 	//
 	Vec3 aabbmin(std::numeric_limits<F32>::max());
-	Vec3 aabbmax(std::numeric_limits<F32>::min());
+	Vec3 aabbmax(-std::numeric_limits<F32>::max());
+
 	instancingTransformations.clear();
 	Vector<F32> alpha;
 	for(ParticleBase* p : particles)

+ 4 - 1
src/scene/Scene.cpp

@@ -39,7 +39,10 @@ struct UpdateMovablesJob: ThreadJob
 
 //==============================================================================
 Scene::Scene()
-	: alloc(ALLOCATOR_SIZE), frameAlloc(ALLOCATOR_SIZE), nodes(alloc)
+	: alloc(ALLOCATOR_SIZE),
+		frameAlloc(ALLOCATOR_SIZE),
+		nodes(alloc),
+		sectorGroup(this)
 {
 	ambientCol = Vec3(0.1, 0.05, 0.05) * 2;
 }

+ 5 - 0
src/scene/SceneNode.cpp

@@ -21,6 +21,11 @@ SceneNode::SceneNode(const char* name_, Scene* scene_)
 SceneNode::~SceneNode()
 {
 	scene->unregisterNode(this);
+
+	if(getSpatial() && getSpatial()->octreeNode)
+	{
+		getSpatial()->octreeNode->removeSceneNode(this);
+	}
 }
 
 //==============================================================================

+ 92 - 3
src/scene/Sector.cpp

@@ -1,15 +1,79 @@
 #include "anki/scene/Sector.h"
 #include "anki/scene/Spatial.h"
 #include "anki/scene/SceneNode.h"
+#include "anki/scene/Renderable.h"
 #include "anki/scene/Light.h"
 #include "anki/scene/VisibilityTestResults.h"
 #include "anki/scene/Frustumable.h"
 #include "anki/scene/Scene.h"
 #include "anki/core/Logger.h"
 #include "anki/renderer/Renderer.h"
+#include "anki/core/ThreadPool.h"
 
 namespace anki {
 
+//==============================================================================
+// Misc                                                                        =
+//==============================================================================
+
+//==============================================================================
+struct DistanceSortFunctor
+{
+	Vec3 origin;
+
+	Bool operator()(SceneNode* a, SceneNode* b)
+	{
+		ANKI_ASSERT(a->getSpatial() != nullptr && b->getSpatial() != nullptr);
+
+		F32 dist0 = origin.getDistanceSquared(
+			a->getSpatial()->getSpatialOrigin());
+		F32 dist1 = origin.getDistanceSquared(
+			b->getSpatial()->getSpatialOrigin());
+
+		return dist0 < dist1;
+	}
+};
+
+//==============================================================================
+struct MaterialSortFunctor
+{
+	Bool operator()(SceneNode* a, SceneNode* b)
+	{
+		ANKI_ASSERT(a->getRenderable() != nullptr
+			&& b->getRenderable() != nullptr);
+
+		return a->getRenderable()->getRenderableMaterial()
+			< b->getRenderable()->getRenderableMaterial();
+	}
+};
+
+//==============================================================================
+struct DistanceSortJob: ThreadJob
+{
+	U nodesCount;
+	VisibilityTestResults::Container::iterator nodes;
+	Vec3 origin;
+
+	void operator()(U threadId, U threadsCount)
+	{
+		DistanceSortFunctor comp;
+		comp.origin = origin;
+		std::sort(nodes, nodes + nodesCount, comp);
+	}
+};
+
+//==============================================================================
+struct MaterialSortJob: ThreadJob
+{
+	U nodesCount;
+	VisibilityTestResults::Container::iterator nodes;
+
+	void operator()(U threadId, U threadsCount)
+	{
+		std::sort(nodes, nodes + nodesCount, MaterialSortFunctor());
+	}
+};
+
 //==============================================================================
 // Portal                                                                      =
 //==============================================================================
@@ -211,7 +275,7 @@ void SectorGroup::doVisibilityTests(SceneNode& sn, VisibilityTest test,
 	{
 		Sector* sector = visibleSectors[i];
 
-		sector->octree.doVisibilityTests(*fr, test, testResults[i]);
+		sector->octree.doVisibilityTests(sn, test, testResults[i]);
 
 		renderablesCount += testResults[i].renderables.size();
 		lightsCount += testResults[i].lights.size();
@@ -280,6 +344,32 @@ void SectorGroup::doVisibilityTests(SceneNode& sn, VisibilityTest test,
 	// The given frustumable is finished
 	fr->visible = visible;
 
+	//
+	// Sort
+	//
+
+	ThreadPool& threadPool = ThreadPoolSingleton::get();
+
+	// Sort the renderables in a another thread
+	DistanceSortJob dsjob;
+	dsjob.nodes = visible->renderables.begin();
+	dsjob.nodesCount = visible->renderables.size();
+	dsjob.origin = sp->getSpatialOrigin();
+	threadPool.assignNewJob(0, &dsjob);
+
+	// The rest of the jobs are dummy
+	Array<ThreadJobDummy, ThreadPool::MAX_THREADS>  dummyjobs;
+	for(U i = 1; i < threadPool.getThreadsCount(); i++)
+	{
+		threadPool.assignNewJob(i, &dummyjobs[i]);
+	}
+
+	// Sort the lights in the main thread
+	std::sort(visible->lights.begin(),
+		visible->lights.end(), DistanceSortFunctor{sp->getSpatialOrigin()});
+
+	threadPool.waitForAllJobsToFinish();
+
 	//
 	// Continue with testing the lights
 	//
@@ -291,8 +381,7 @@ void SectorGroup::doVisibilityTests(SceneNode& sn, VisibilityTest test,
 
 		if(l->getShadowEnabled())
 		{
-			Frustumable* lfr = lsn->getFrustumable();
-			ANKI_ASSERT(lfr != nullptr);
+			ANKI_ASSERT(lsn->getFrustumable() != nullptr);
 
 			doVisibilityTests(*lsn, 
 				(VisibilityTest)(VT_RENDERABLES | VT_ONLY_SHADOW_CASTERS),

+ 1 - 1
src/scene/SkinNode.cpp

@@ -131,7 +131,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch* modelPatch_,
 	: 	SceneNode(name, scene),
 		Movable(movableFlags, movParent, *this, getSceneAllocator()),
 		Renderable(getSceneAllocator()),
-		Spatial(this, spatialCs)
+		Spatial(spatialCs)
 {
 	skinModelPatch.reset(new SkinModelPatch(modelPatch_, getSceneAllocator()));
 	Renderable::init(*this);

+ 1 - 6
src/scene/Spatial.cpp

@@ -5,11 +5,6 @@ namespace anki {
 
 //==============================================================================
 Spatial::~Spatial()
-{
-	if(octreeNode)
-	{
-		octreeNode->removeSceneNode(sceneNode);
-	}
-}
+{}
 
 } // end namespace anki

+ 19 - 32
testapp/Main.cpp

@@ -139,23 +139,13 @@ void init()
 	cam->setAll(
 		MainRendererSingleton::get().getAspectRatio() * toRad(ang),
 		toRad(ang), 0.5, 500.0);
-	cam->setLocalTransform(Transform(Vec3(82.0, 5.0, 8.0),
+	cam->setLocalTransform(Transform(Vec3(40.0, 5.0, 8.0),
 		Mat3(Euler(toRad(-10.0), toRad(90.0), toRad(0.0))),
 		1.0));
 	scene.setActiveCamera(cam);
 
-	// camera 2
-	PerspectiveCamera* pcam = new PerspectiveCamera("camera1", &scene,
-		Movable::MF_NONE, nullptr);
-	pcam->setAll(
-		MainRendererSingleton::get().getAspectRatio() * toRad(ang),
-		toRad(ang), 0.5, 200.0);
-	pcam->setLocalTransform(Transform(Vec3(100.0, 3.0, 8.0),
-		Mat3(Axisang(toRad(90.0), Vec3(0, 1, 0))),
-		1.0));
-
 	// lights
-#if 1
+#if 0
 	Vec3 lpos(-90.0, 1.2, -32.0);
 	for(int i = 0; i < 50; i++)
 	{
@@ -205,16 +195,19 @@ void init()
 	spot->setShadowEnabled(true);
 #endif
 
+#if 1
 	// Vase point lights
 	Array<Vec3, 4> vaseLightPos = {{Vec3(32.6, 9, -13.2), Vec3(32.6, 9, 10),
 		Vec3(-37.6001, 9, 10), Vec3(-37.6001, 9, -13.2)}};
 	for(U i = 0; i < vaseLightPos.getSize(); i++)
 	{
+		Vec3 lightPos = vaseLightPos[i] * 0.25;
+
 		PointLight* point =
 			new PointLight(("vase_plight" + std::to_string(i)).c_str(),
 			&scene, Movable::MF_NONE, nullptr);
-		point->setRadius(3.5);
-		point->setLocalTranslation(vaseLightPos[i]);
+		point->setRadius(2.0);
+		point->setLocalTranslation(lightPos);
 		point->setDiffuseColor(Vec4(3.0, 0.0, 0.0, 0.0));
 		point->setSpecularColor(Vec4(1.0, 1.0, 0.0, 0.0));
 
@@ -222,14 +215,15 @@ void init()
 			"data/particles/smoke.particles",
 			("pe" + std::to_string(i)).c_str(), &scene,
 			Movable::MF_NONE, nullptr);
-		pe->setLocalTranslation(vaseLightPos[i]);
+		pe->setLocalTranslation(lightPos);
 
 		pe = new ParticleEmitter(
 			"data/particles/fire.particles",
 			("pef" + std::to_string(i)).c_str(), &scene,
 			Movable::MF_NONE, nullptr);
-		pe->setLocalTranslation(vaseLightPos[i]);
+		pe->setLocalTranslation(lightPos);
 	}
+#endif
 
 	/*PointLight* point1 = new PointLight("point1", &scene, Movable::MF_NONE,
 		nullptr);
@@ -244,20 +238,6 @@ void init()
 	horse->setLocalTransform(Transform(Vec3(-2, 0, 0), Mat3::getIdentity(),
 		1.0));
 
-#if 0
-	// Sponza
-	ModelNode* sponzaModel = new ModelNode(
-		"maps/sponza-crytek/sponza_crytek.mdl",
-		"sponza", &scene, Movable::MF_NONE, nullptr);
-
-	sponzaModel->setLocalScale(0.1);
-
-	// Sectors
-	Aabb sectorAabb;
-	sponzaModel->getModel().getVisibilityShape().toAabb(sectorAabb);
-	scene.sectors.push_back(new Sector(sectorAabb));
-#endif
-
 #if 1
 	ModelNode* sponzaModel = new ModelNode(
 		"data/maps/sponza/sponza.mdl",
@@ -266,7 +246,9 @@ void init()
 	(void)sponzaModel;
 #endif
 
-	initPhysics();
+	(void)sponzaModel;
+
+	//initPhysics();
 
 	/*ParticleEmitter* pe = new ParticleEmitter("todo", "pe", &scene,
 		Movable::MF_NONE, nullptr);
@@ -334,6 +316,11 @@ void mainLoopExtra()
 	{
 		mover = SceneSingleton::get().findSceneNode("vase_plight0").getMovable();
 	}
+	if(in.getKey(KC_7))
+	{
+		mover = SceneSingleton::get().findSceneNode("sponza").getMovable();
+		std::cout << mover->getWorldTransform() << std::endl;
+	}
 
 	if(in.getKey(KC_L) == 1)
 	{
@@ -486,7 +473,7 @@ void initSubsystems(int argc, char* argv[])
 	// Main renderer
 	RendererInitializer initializer;
 	initializer.ms.ez.enabled = true;
-	initializer.dbg.enabled = false;
+	initializer.dbg.enabled = true;
 	initializer.is.sm.bilinearEnabled = true;
 	initializer.is.groundLightEnabled = false;
 	initializer.is.sm.enabled = true;