Browse Source

Refactoring

Panagiotis Christopoulos Charitos 14 years ago
parent
commit
deea1ca22f

+ 3 - 2
src/Main.cpp

@@ -141,7 +141,8 @@ void init()
 	// camera
 	PerspectiveCamera* cam = new PerspectiveCamera(scene, SceneNode::SNF_NONE, NULL);
 	//cam->setAll(toRad(100.0), toRad(100.0) / r::MainRendererSingleton::get().getAspectRatio(), 0.5, 200.0);
-	cam->setAll(MainRendererSingleton::get().getAspectRatio()*Math::toRad(60.0), Math::toRad(60.0), 0.5, 200.0);
+	INFO(MainRendererSingleton::get().getAspectRatio());
+	cam->setAll(MainRendererSingleton::get().getAspectRatio()*Math::toRad(90.0), Math::toRad(90.0), 0.5, 200.0);
 	cam->moveLocalY(3.0);
 	cam->moveLocalZ(5.7);
 	cam->moveLocalX(-0.3);
@@ -295,7 +296,7 @@ void mainLoopExtra()
 	if(InputSingleton::get().getKey(SDL_SCANCODE_SPACE)) mover->moveLocalY(-dist);
 	if(InputSingleton::get().getKey(SDL_SCANCODE_W)) mover->moveLocalZ(-dist);
 	if(InputSingleton::get().getKey(SDL_SCANCODE_S)) mover->moveLocalZ(dist);
-	if(!InputSingleton::get().warpMouse())
+	if(!InputSingleton::get().getWarpMouse())
 	{
 		if(InputSingleton::get().getKey(SDL_SCANCODE_UP)) mover->rotateLocalX(ang);
 		if(InputSingleton::get().getKey(SDL_SCANCODE_DOWN)) mover->rotateLocalX(-ang);

+ 28 - 4
src/cln/LineSegment.h

@@ -3,7 +3,6 @@
 
 #include "CollisionShape.h"
 #include "m/Vec3.h"
-#include "util/Accessors.h"
 
 
 /// @addtogroup Collision
@@ -15,15 +14,40 @@ class LineSegment: public CollisionShape
 	public:
 		/// @name Constructors
 		/// @{
-		LineSegment(): CollisionShape(CST_LINE_SEG) {}
+		LineSegment()
+		:	CollisionShape(CST_LINE_SEG)
+		{}
 		LineSegment(const Vec3& origin, const Vec3& direction);
 		LineSegment(const LineSegment& b);
 		/// @}
 
 		/// @name Accessors
 		/// @{
-		GETTER_SETTER(Vec3, origin, getOrigin, setOrigin)
-		GETTER_SETTER(Vec3, dir, getDirection, setDirection)
+		const Vec3& getOrigin() const
+		{
+			return origin;
+		}
+		Vec3& getOrigin()
+		{
+			return origin;
+		}
+		void setOrigin(const Vec3& x)
+		{
+			origin = x;
+		}
+
+		const Vec3& getDirection() const
+		{
+			return dir;
+		}
+		Vec3& getDirection()
+		{
+			return dir;
+		}
+		void setDirection(const Vec3& x)
+		{
+			dir = x;
+		}
 		/// @}
 
 		LineSegment getTransformed(const Transform& transform) const;

+ 41 - 5
src/cln/Obb.h

@@ -3,7 +3,6 @@
 
 #include "CollisionShape.h"
 #include "m/Math.h"
-#include "util/Accessors.h"
 #include <boost/array.hpp>
 
 /// @addtogroup Collision
@@ -15,16 +14,53 @@ class Obb: public CollisionShape
 	public:
 		/// @name Constructors
 		/// @{
-		Obb(): CollisionShape(CST_OBB) {}
+		Obb()
+		:	CollisionShape(CST_OBB)
+		{}
 		Obb(const Obb& b);
 		Obb(const Vec3& center, const Mat3& rotation, const Vec3& extends);
 		/// @}
 
 		/// @name Accessors
 		/// @{
-		GETTER_SETTER(Vec3, center, getCenter, setCenter)
-		GETTER_SETTER(Mat3, rotation, getRotation, setRotation)
-		GETTER_SETTER(Vec3, extends, getExtend, setExtend)
+		const Vec3& getCenter() const
+		{
+			return center;
+		}
+		Vec3& getCenter()
+		{
+			return center;
+		}
+		void setCenter(const Vec3& x)
+		{
+			center = x;
+		}
+
+		const Mat3& getRotation() const
+		{
+			return rotation;
+		}
+		Mat3& getRotation()
+		{
+			return rotation;
+		}
+		void setRotation(const Mat3& x)
+		{
+			rotation = x;
+		}
+
+		const Vec3& getExtend() const
+		{
+			return extends;
+		}
+		Vec3& getExtend()
+		{
+			return extends;
+		}
+		void setExtend(const Vec3& x)
+		{
+			extends = x;
+		}
 		/// @}
 
 		Obb getTransformed(const Transform& transform) const;

+ 28 - 4
src/cln/Plane.h

@@ -3,7 +3,6 @@
 
 #include "CollisionShape.h"
 #include "m/Math.h"
-#include "util/Accessors.h"
 
 
 /// @addtogroup Collision
@@ -17,7 +16,9 @@ class Plane: public CollisionShape
 		/// @{
 
 		/// Default constructor
-		Plane(): CollisionShape(CST_PLANE) {}
+		Plane()
+		:	CollisionShape(CST_PLANE)
+		{}
 
 		/// Copy constructor
 		Plane(const Plane& b);
@@ -34,8 +35,31 @@ class Plane: public CollisionShape
 
 		/// @name Accessors
 		/// @{
-		GETTER_SETTER(Vec3, normal, getNormal, setNormal)
-		GETTER_SETTER_BY_VAL(float, offset, getOffset, setOffset)
+		const Vec3& getNormal() const
+		{
+			return normal;
+		}
+		Vec3& getNormal()
+		{
+			return normal;
+		}
+		void setNormal(const Vec3& x)
+		{
+			normal = x;
+		}
+
+		float getOffset() const
+		{
+			return offset;
+		}
+		float& getOffset()
+		{
+			return offset;
+		}
+		void setOffset(const float x)
+		{
+			offset = x;
+		}
 		/// @}
 
 		/// Return the transformed

+ 28 - 4
src/cln/Ray.h

@@ -3,7 +3,6 @@
 
 #include "CollisionShape.h"
 #include "m/Math.h"
-#include "util/Accessors.h"
 
 
 class Plane;
@@ -19,7 +18,9 @@ class Ray: public CollisionShape
 		/// @{
 
 		/// Default constructor
-		Ray(): CollisionShape(CST_RAY) {}
+		Ray()
+		:	CollisionShape(CST_RAY)
+		{}
 
 		/// Copy constructor
 		Ray(const Ray& other);
@@ -30,8 +31,31 @@ class Ray: public CollisionShape
 
 		/// @name Accessors
 		/// @{
-		GETTER_SETTER(Vec3, origin, getOrigin, setOrigin)
-		GETTER_SETTER(Vec3, dir, getDirection, setDirection)
+		const Vec3& getOrigin() const
+		{
+			return origin;
+		}
+		Vec3& getOrigin()
+		{
+			return origin;
+		}
+		void setOrigin(const Vec3& x)
+		{
+			origin = x;
+		}
+
+		const Vec3& getDirection() const
+		{
+			return dir;
+		}
+		Vec3& getDirection()
+		{
+			return dir;
+		}
+		void setDirection(const Vec3& x)
+		{
+			dir = x;
+		}
 		/// @}
 
 		Ray getTransformed(const Transform& transform) const;

+ 28 - 4
src/cln/Sphere.h

@@ -3,7 +3,6 @@
 
 #include "CollisionShape.h"
 #include "m/Math.h"
-#include "util/Accessors.h"
 
 
 class Plane;
@@ -20,7 +19,9 @@ class Sphere: public CollisionShape
 		/// @{
 
 		/// Default constructor
-		Sphere(): CollisionShape(CST_SPHERE) {}
+		Sphere()
+		:	CollisionShape(CST_SPHERE)
+		{}
 
 		/// Copy constructor
 		Sphere(const Sphere& other);
@@ -31,8 +32,31 @@ class Sphere: public CollisionShape
 
 		/// @name Accessors
 		/// @{
-		GETTER_SETTER(Vec3, center, getCenter, setCenter)
-		GETTER_SETTER_BY_VAL(float, radius, getRadius, setRadius)
+		const Vec3& getCenter() const
+		{
+			return center;
+		}
+		Vec3& getCenter()
+		{
+			return center;
+		}
+		void setCenter(const Vec3& x)
+		{
+			center = x;
+		}
+
+		float getRadius() const
+		{
+			return radius;
+		}
+		float& getRadius()
+		{
+			return radius;
+		}
+		void setRadius(const float x)
+		{
+			radius = x;
+		}
 		/// @}
 
 		Sphere getTransformed(const Transform& transform) const;

+ 41 - 12
src/core/App.h

@@ -4,7 +4,6 @@
 #include <SDL/SDL.h>
 #include <boost/filesystem.hpp>
 #include "util/StdTypes.h"
-#include "util/Accessors.h"
 #include "Logger.h"
 
 
@@ -50,17 +49,47 @@ class App
 
 		/// @name Accessors
 		/// @{
-		Camera* getActiveCam() {return activeCam;}
-		void setActiveCam(Camera* cam) {activeCam = cam;}
-
-		GETTER_SETTER(float, timerTick, getTimerTick, setTimerTick)
-		GETTER_R_BY_VAL(bool, terminalColoringEnabled,
-			isTerminalColoringEnabled)
-		GETTER_R_BY_VAL(uint, windowW, getWindowWidth)
-		GETTER_R(uint, windowH, getWindowHeight)
-		GETTER_R(boost::filesystem::path, settingsPath, getSettingsPath)
-		GETTER_R(boost::filesystem::path, cachePath, getCachePath)
-		GETTER_RW(SDL_WindowID, windowId, getWindowId)
+		Camera* getActiveCam()
+		{
+			return activeCam;
+		}
+		void setActiveCam(Camera* cam)
+		{
+			activeCam = cam;
+		}
+
+		float getTimerTick() const
+		{
+			return timerTick;
+		}
+		float& getTimerTick()
+		{
+			return timerTick;
+		}
+		void setTimerTick(const float x)
+		{
+			timerTick = x;
+		}
+
+		uint getWindowWidth() const
+		{
+			return windowW;
+		}
+
+		uint getWindowHeight() const
+		{
+			return windowH;
+		}
+
+		const boost::filesystem::path& getSettingsPath() const
+		{
+			return settingsPath;
+		}
+
+		const boost::filesystem::path& getCachePath() const
+		{
+			return cachePath;
+		}
 		/// @}
 
 	private:

+ 9 - 3
src/core/parallel/Job.h

@@ -2,7 +2,6 @@
 #define PARALLEL_JOB_H
 
 #include <boost/thread.hpp>
-#include "util/Accessors.h"
 
 
 namespace parallel {
@@ -30,8 +29,15 @@ class Job
 
 		/// @name Accessors
 		/// @{
-		GETTER_R(uint, id, getId)
-		GETTER_R(Manager, manager, getManager)
+		uint getId() const
+		{
+			return id;
+		}
+
+		const Manager& getManager() const
+		{
+			return manager;
+		}
 		/// @}
 
 		/// Assign new job to the thread

+ 15 - 4
src/event/Event.h

@@ -2,7 +2,6 @@
 #define EVENT_H
 
 #include "util/StdTypes.h"
-#include "util/Accessors.h"
 
 
 /// The event type enum
@@ -26,9 +25,21 @@ class Event
 
 		/// @name Accessors
 		/// @{
-		GETTER_R(float, startTime, getStartTime)
-		GETTER_R(float, duration, getDuration)
-		GETTER_R(EventType, type, getEventType)
+		float getStartTime() const
+		{
+			return startTime;
+		}
+
+		float getDuration() const
+		{
+			return duration;
+		}
+
+		EventType getEventType() const
+		{
+			return type;
+		}
+
 		bool isDead(float crntTime) const;
 		/// @}
 

+ 2 - 2
src/event/MainRendererPpsHdrEvent.cpp

@@ -21,7 +21,7 @@ MainRendererPpsHdrEvent::MainRendererPpsHdrEvent(float startTime,
 		MainRendererSingleton::get().getPps().getHdr();
 	originalData.exposure = hdr.getExposure();
 	originalData.blurringIterationsNum = hdr.getBlurringIterationsNum();
-	originalData.blurringDist = hdr.getBlurringDist();
+	originalData.blurringDist = hdr.getBlurringDistance();
 }
 
 
@@ -65,6 +65,6 @@ void MainRendererPpsHdrEvent::updateSp(float /*prevUpdateTime*/, float crntTime)
 		interpolate(originalData.blurringIterationsNum,
 		finalData.blurringIterationsNum, dp));
 
-	hdr.setBlurringDist(interpolate(originalData.blurringDist,
+	hdr.setBlurringDistance(interpolate(originalData.blurringDist,
 		finalData.blurringDist, dp));
 }

+ 22 - 4
src/i/Input.h

@@ -2,7 +2,6 @@
 #define INPUT_H
 
 #include "m/Math.h"
-#include "util/Accessors.h"
 #include <SDL/SDL_scancode.h>
 #include <boost/array.hpp>
 
@@ -15,9 +14,28 @@ class Input
 
 		/// @name Acessors
 		/// @{
-		short getKey(uint i) const {return keys[i];}
-		short getMouseBtn(uint i) const {return mouseBtns[i];}
-		GETTER_SETTER_BY_VAL(bool, warpMouseFlag, warpMouse, setWarpMouse)
+		short getKey(uint i) const
+		{
+			return keys[i];
+		}
+
+		short getMouseBtn(uint i) const
+		{
+			return mouseBtns[i];
+		}
+
+		bool getWarpMouse() const
+		{
+			return warpMouseFlag;
+		}
+		bool& getWarpMouse()
+		{
+			return warpMouseFlag;
+		}
+		void setWarpMouse(const bool x)
+		{
+			warpMouseFlag = x;
+		}
 		/// @}
 
 		void reset();

+ 2 - 2
src/r/Bl.cpp

@@ -7,8 +7,8 @@
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-Bl::Bl(Renderer& r_):
-	RenderingPass(r_)
+Bl::Bl(Renderer& r_)
+:	SwitchableRenderingPass(r_)
 {}
 
 

+ 27 - 8
src/r/Bl.h

@@ -2,7 +2,6 @@
 #define BL_H
 
 #include "RenderingPass.h"
-#include "util/Accessors.h"
 #include "rsrc/Texture.h"
 #include "rsrc/RsrcPtr.h"
 #include "gl/Fbo.h"
@@ -11,7 +10,8 @@
 class ShaderProgram;
 
 
-class Bl: private RenderingPass
+/// Blurring rendering pass
+class Bl: public SwitchableRenderingPass
 {
 	public:
 		Bl(Renderer& r_);
@@ -20,11 +20,31 @@ class Bl: private RenderingPass
 
 		/// @name Accessors
 		/// @{
-		GETTER_SETTER_BY_VAL(bool, enabled, isEnabled, setEnabled)
-		GETTER_SETTER_BY_VAL(uint, blurringIterationsNum,
-			getBlurringIterationsNum, setBlurringIterationsNum)
-		GETTER_SETTER_BY_VAL(float, sideBlurFactor, getSideBlurFactor,
-			setSideBlurFactor)
+		float getSideBlurFactor() const
+		{
+			return sideBlurFactor;
+		}
+		float& getSideBlurFactor()
+		{
+			return sideBlurFactor;
+		}
+		void setSideBlurFactor(const float x)
+		{
+			sideBlurFactor = x;
+		}
+
+		uint getBlurringIterationsNum() const
+		{
+			return blurringIterationsNum;
+		}
+		uint& getBlurringIterationsNum()
+		{
+			return blurringIterationsNum;
+		}
+		void setBlurringIterationsNum(const uint x)
+		{
+			blurringIterationsNum = x;
+		}
 		/// @}
 
 	private:
@@ -39,7 +59,6 @@ class Bl: private RenderingPass
 		Texture blurFai; ///< Temp FAI for blurring
 		RsrcPtr<Texture> sideBlurMap;
 
-		bool enabled;
 		uint blurringIterationsNum;
 		float sideBlurFactor;
 

+ 1 - 1
src/r/Dbg.cpp

@@ -16,7 +16,7 @@
 // Constructor                                                                 =
 //==============================================================================
 Dbg::Dbg(Renderer& r_):
-	RenderingPass(r_),
+	SwitchableRenderingPass(r_),
 	showAxisEnabled(false),
 	showLightsEnabled(true),
 	showSkeletonsEnabled(true),

+ 13 - 6
src/r/Dbg.h

@@ -12,11 +12,10 @@
 #include "gl/Vao.h"
 #include "SceneDbgDrawer.h"
 #include "CollisionDbgDrawer.h"
-#include "util/Accessors.h"
 
 
 /// Debugging stage
-class Dbg: public RenderingPass
+class Dbg: public SwitchableRenderingPass
 {
 	public:
 		Dbg(Renderer& r_);
@@ -30,9 +29,18 @@ class Dbg: public RenderingPass
 
 		/// @name Accessors
 		/// @{
-		GETTER_SETTER_BY_VAL(bool, enabled, isEnabled, setEnabled)
-		GETTER_SETTER_BY_VAL(bool, showSkeletonsEnabled,
-			isShowSkeletonsEnabled, setShowSkeletonsEnabled)
+		bool getShowSkeletonsEnabled() const
+		{
+			return showSkeletonsEnabled;
+		}
+		bool& getShowSkeletonsEnabled()
+		{
+			return showSkeletonsEnabled;
+		}
+		void setShowSkeletonsEnabled(const bool x)
+		{
+			showSkeletonsEnabled = x;
+		}
 		/// @todo add others
 		/// @}
 
@@ -49,7 +57,6 @@ class Dbg: public RenderingPass
 		/// @}
 
 	private:
-		bool enabled;
 		bool showAxisEnabled;
 		bool showLightsEnabled;
 		bool showSkeletonsEnabled;

+ 2 - 6
src/r/Ez.h

@@ -3,23 +3,19 @@
 
 #include "RenderingPass.h"
 #include "gl/Fbo.h"
-#include "util/Accessors.h"
 
 
 /// Material stage EarlyZ pass
-class Ez: public RenderingPass
+class Ez: public SwitchableRenderingPass
 {
 	public:
-		Ez(Renderer& r_): RenderingPass(r_) {}
-
-		GETTER_R_BY_VAL(bool, enabled, isEnabled)
+		Ez(Renderer& r_): SwitchableRenderingPass(r_) {}
 
 		void init(const RendererInitializer& initializer);
 		void run();
 
 	private:
 		Fbo fbo; ///< Writes to MS depth FAI
-		bool enabled;
 };
 
 

+ 1 - 1
src/r/Hdr.cpp

@@ -8,7 +8,7 @@
 // Constructor                                                                 =
 //==============================================================================
 Hdr::Hdr(Renderer& r_)
-	: RenderingPass(r_)
+:	SwitchableRenderingPass(r_)
 {}
 
 

+ 59 - 14
src/r/Hdr.h

@@ -5,14 +5,13 @@
 #include "gl/Fbo.h"
 #include "rsrc/Texture.h"
 #include "rsrc/RsrcPtr.h"
-#include "util/Accessors.h"
 
 
 class ShaderProgram;
 
 
 /// High dynamic range lighting pass
-class Hdr: private RenderingPass
+class Hdr: public SwitchableRenderingPass
 {
 	public:
 		Hdr(Renderer& r_);
@@ -22,21 +21,67 @@ class Hdr: private RenderingPass
 
 		/// @name Accessors
 		/// @{
-		GETTER_SETTER_BY_VAL(float, exposure, getExposure, setExposure)
-		GETTER_SETTER_BY_VAL(uint, blurringIterationsNum,
-			getBlurringIterationsNum, setBlurringIterationsNum)
-		GETTER_SETTER_BY_VAL(float, blurringDist, getBlurringDist,
-			setBlurringDist)
-
-		GETTER_R_BY_VAL(bool, enabled, isEnabled);
-		GETTER_R_BY_VAL(float, renderingQuality, getRenderingQuality)
-		GETTER_R(Texture, toneFai, getToneFai)
-		GETTER_R(Texture, hblurFai, getHblurFai)
-		GETTER_R(Texture, fai, getFai)
+		float getExposure() const
+		{
+			return exposure;
+		}
+		float& getExposure()
+		{
+			return exposure;
+		}
+		void setExposure(const float x)
+		{
+			exposure = x;
+		}
+
+		uint getBlurringIterationsNum() const
+		{
+			return blurringIterationsNum;
+		}
+		uint& getBlurringIterationsNum()
+		{
+			return blurringIterationsNum;
+		}
+		void setBlurringIterationsNum(const uint x)
+		{
+			blurringIterationsNum = x;
+		}
+
+		float getBlurringDistance() const
+		{
+			return blurringDist;
+		}
+		float& getBlurringDistance()
+		{
+			return blurringDist;
+		}
+		void setBlurringDistance(const float x)
+		{
+			blurringDist = x;
+		}
+
+		float getRenderingQuality() const
+		{
+			return renderingQuality;
+		}
+
+		const Texture& getToneFai() const
+		{
+			return toneFai;
+		}
+
+		const Texture& getHblurFai() const
+		{
+			return hblurFai;
+		}
+
+		const Texture& getFai() const
+		{
+			return fai;
+		}
 		/// @}
 
 	private:
-		bool enabled;
 		float exposure; ///< How bright is the HDR
 		uint blurringIterationsNum; ///< The blurring iterations of the tone map
 		float blurringDist; ///< Distance in blurring

+ 3 - 3
src/r/Is.cpp

@@ -209,7 +209,7 @@ void Is::spotLightPass(const SpotLight& light)
 	const Camera& cam = r.getCamera();
 
 	// shadow mapping
-	if(light.getCastShadow() && sm.isEnabled())
+	if(light.getCastShadow() && sm.getEnabled())
 	{
 		Vec3 zAxis = light.getWorldTransform().getRotation().getColumn(2);
 		LineSegment seg(light.getWorldTransform().getOrigin(),
@@ -242,7 +242,7 @@ void Is::spotLightPass(const SpotLight& light)
 	// shader prog
 	const ShaderProgram* shdr;
 
-	if(light.getCastShadow() && sm.isEnabled())
+	if(light.getCastShadow() && sm.getEnabled())
 	{
 		shdr = spotLightShadowSProg.get();
 	}
@@ -292,7 +292,7 @@ void Is::spotLightPass(const SpotLight& light)
 	shdr->getUniformVariableByName("texProjectionMat").set(&texProjectionMat);
 
 	// the shadowmap
-	if(light.getCastShadow() && sm.isEnabled())
+	if(light.getCastShadow() && sm.getEnabled())
 	{
 		shdr->getUniformVariableByName("shadowMap").set(sm.getShadowMap(), 5);
 		float smSize = sm.getShadowMap().getWidth();

+ 4 - 1
src/r/Is.h

@@ -27,7 +27,10 @@ class Is: private RenderingPass
 
 		/// @name Accessors
 		/// @{
-		const Texture& getFai() const {return fai;}
+		const Texture& getFai() const
+		{
+			return fai;
+		}
 		/// @}
 
 	private:

+ 1 - 1
src/r/MainRenderer.cpp

@@ -118,7 +118,7 @@ void MainRenderer::render(Camera& cam_)
 {
 	Renderer::render(cam_);
 
-	if(isStagesProfilingEnabled())
+	if(getStagesProfilingEnabled())
 	{
 		dbgTq->begin();
 		dbg.run();

+ 31 - 5
src/r/MainRenderer.h

@@ -19,11 +19,37 @@ class MainRenderer: public Renderer
 
 		/// @name Setters & getters
 		/// @{
-		GETTER_SETTER_BY_VAL(int, screenshotJpegQuality,
-			getScreenshotJpegQuality, setScreenshotJpegQuality)
-		GETTER_R_BY_VAL(float, renderingQuality, getRenderingQuality)
-		GETTER_RW(Dbg, dbg, getDbg)
-		GETTER_R_BY_VAL(double, dbgTime, getDbgTime)
+		int getSceenshotJpegQuality() const
+		{
+			return screenshotJpegQuality;
+		}
+		int& getSceenshotJpegQuality()
+		{
+			return screenshotJpegQuality;
+		}
+		void setSceenshotJpegQuality(const int x)
+		{
+			screenshotJpegQuality = x;
+		}
+
+		float getRenderingQuality() const
+		{
+			return renderingQuality;
+		}
+
+		const Dbg& getDbg() const
+		{
+			return dbg;
+		}
+		Dbg& getDbg()
+		{
+			return dbg;
+		}
+
+		double getDbgTime() const
+		{
+			return dbgTime;
+		}
 		/// @}
 
 		/// The same as Renderer::init but with additional initialization.

+ 4 - 4
src/r/Ms.cpp

@@ -84,14 +84,14 @@ void Ms::init(const RendererInitializer& initializer)
 //==============================================================================
 void Ms::run()
 {
-	if(ez.isEnabled())
+	if(ez.getEnabled())
 	{
 		ez.run();
 	}
 
 	fbo.bind();
 
-	if(!ez.isEnabled())
+	if(!ez.getEnabled())
 	{
 		glClear(GL_DEPTH_BUFFER_BIT);
 	}
@@ -104,7 +104,7 @@ void Ms::run()
 	//glDepthFunc(GL_LEQUAL);
 
 	// if ez then change the default depth test and disable depth writing
-	if(ez.isEnabled())
+	if(ez.getEnabled())
 	{
 		glDepthMask(false);
 		glDepthFunc(GL_EQUAL);
@@ -121,7 +121,7 @@ void Ms::run()
 	}
 
 	// restore depth
-	if(ez.isEnabled())
+	if(ez.getEnabled())
 	{
 		glDepthMask(true);
 		glDepthFunc(GL_LESS);

+ 19 - 4
src/r/Ms.h

@@ -17,10 +17,25 @@ class Ms: public RenderingPass
 
 		/// @name Accessors
 		/// @{
-		GETTER_R(Texture, normalFai, getNormalFai)
-		GETTER_R(Texture, diffuseFai, getDiffuseFai)
-		GETTER_R(Texture, specularFai, getSpecularFai)
-		GETTER_R(Texture, depthFai, getDepthFai)
+		const Texture& getNormalFai() const
+		{
+			return normalFai;
+		}
+
+		const Texture& getDiffuseFai() const
+		{
+			return diffuseFai;
+		}
+
+		const Texture& getSpecularFai() const
+		{
+			return specularFai;
+		}
+
+		const Texture& getDepthFai() const
+		{
+			return depthFai;
+		}
 		/// @}
 
 		void init(const RendererInitializer& initializer);

+ 6 - 6
src/r/Pps.cpp

@@ -56,7 +56,7 @@ void Pps::init(const RendererInitializer& initializer)
 
 	// SProg
 	std::string pps = "";
-	if(ssao.isEnabled())
+	if(ssao.getEnabled())
 	{
 		pps += "#define SSAO_ENABLED\n";
 	}
@@ -90,7 +90,7 @@ void Pps::init(const RendererInitializer& initializer)
 	// SProg
 	pps = "";
 
-	if(hdr.isEnabled())
+	if(hdr.getEnabled())
 	{
 		pps += "#define HDR_ENABLED\n";
 	}
@@ -110,7 +110,7 @@ void Pps::init(const RendererInitializer& initializer)
 //==============================================================================
 void Pps::runPrePass()
 {
-	if(ssao.isEnabled())
+	if(ssao.getEnabled())
 	{
 		ssao.run();
 	}
@@ -125,7 +125,7 @@ void Pps::runPrePass()
 	prePassSProg->bind();
 	prePassSProg->getUniformVariableByName("isFai").set(r.getIs().getFai(), 0);
 
-	if(ssao.isEnabled())
+	if(ssao.getEnabled())
 	{
 		prePassSProg->getUniformVariableByName("ppsSsaoFai").set(
 			ssao.getFai(), 1);
@@ -143,7 +143,7 @@ void Pps::runPostPass()
 	//
 	// The actual pass
 	//
-	if(hdr.isEnabled())
+	if(hdr.getEnabled())
 	{
 		hdr.run();
 	}
@@ -158,7 +158,7 @@ void Pps::runPostPass()
 	postPassSProg->bind();
 	postPassSProg->getUniformVariableByName("ppsPrePassFai").set(
 		prePassFai, 0);
-	if(hdr.isEnabled())
+	if(hdr.getEnabled())
 	{
 		postPassSProg->getUniformVariableByName("ppsHdrFai").set(
 			hdr.getFai(), 1);

+ 32 - 5
src/r/Pps.h

@@ -28,11 +28,38 @@ class Pps: private RenderingPass
 
 		/// @name Accessors
 		/// @{
-		GETTER_RW(Hdr, hdr, getHdr)
-		GETTER_RW(Ssao, ssao, getSsao)
-		GETTER_RW(Bl, bl, getBl)
-		GETTER_R(Texture, prePassFai, getPrePassFai)
-		GETTER_R(Texture, postPassFai, getPostPassFai)
+		const Hdr& getHdr() const
+		{
+			return hdr;
+		}
+		Hdr& getHdr()
+		{
+			return hdr;
+		}
+
+		const Ssao& getSsao() const
+		{
+			return ssao;
+		}
+
+		const Bl& getBl() const
+		{
+			return bl;
+		}
+		Bl& getBl()
+		{
+			return bl;
+		}
+
+		const Texture& getPrePassFai() const
+		{
+			return prePassFai;
+		}
+
+		const Texture& getPostPassFai() const
+		{
+			return postPassFai;
+		}
 		/// @}
 
 	private:

+ 0 - 2
src/r/Renderer.cpp

@@ -35,8 +35,6 @@ void Renderer::init(const RendererInitializer& initializer)
 	// set from the initializer
 	width = initializer.width;
 	height = initializer.height;
-
-	aspectRatio = float(width) / height;
 	framesNum = 0;
 
 	// a few sanity checks

+ 113 - 20
src/r/Renderer.h

@@ -46,25 +46,119 @@ class Renderer
 
 		/// @name Accessors
 		/// @{
-		GETTER_RW(Ms, ms, getMs)
-		GETTER_RW(Is, is, getIs)
-		GETTER_RW(Pps, pps, getPps)
-		GETTER_R_BY_VAL(uint, width, getWidth)
-		GETTER_R_BY_VAL(uint, height, getHeight)
-		GETTER_R_BY_VAL(float, aspectRatio, getAspectRatio)
-		GETTER_R_BY_VAL(uint, framesNum, getFramesNum)
-		GETTER_R(Mat4, viewProjectionMat, getViewProjectionMat)
-		const Camera& getCamera() const {return *cam;}
-		GETTER_RW(SceneDrawer, sceneDrawer, getSceneDrawer)
-		GETTER_R(Vec2, planes, getPlanes)
-		GETTER_R(Vec2, limitsOfNearPlane, getLimitsOfNearPlane)
-		GETTER_R(Vec2, limitsOfNearPlane2, getLimitsOfNearPlane2)
-		GETTER_R_BY_VAL(double, msTime, getMsTime)
-		GETTER_R_BY_VAL(double, isTime, getIsTime)
-		GETTER_R_BY_VAL(double, ppsTime, getPpsTime)
-		GETTER_R_BY_VAL(double, bsTime, getBsTime)
-		GETTER_SETTER_BY_VAL(bool, enableStagesProfilingFlag,
-			isStagesProfilingEnabled, setEnableStagesProfiling)
+		const Ms& getMs() const
+		{
+			return ms;
+		}
+		Ms& getMs()
+		{
+			return ms;
+		}
+
+		const Is& getIs() const
+		{
+			return is;
+		}
+		Is& getIs()
+		{
+			return is;
+		}
+
+		const Pps& getPps() const
+		{
+			return pps;
+		}
+		Pps& getPps()
+		{
+			return pps;
+		}
+
+		uint getWidth() const
+		{
+			return width;
+		}
+
+		uint getHeight() const
+		{
+			return height;
+		}
+
+		float getAspectRatio() const
+		{
+			return float(width) / height;
+		}
+
+		uint getFramesNum() const
+		{
+			return framesNum;
+		}
+
+		const Mat4& getViewProjectionMat() const
+		{
+			return viewProjectionMat;
+		}
+
+		const Camera& getCamera() const
+		{
+			return *cam;
+		}
+
+		const SceneDrawer& getSceneDrawer() const
+		{
+			return sceneDrawer;
+		}
+		SceneDrawer& getSceneDrawer()
+		{
+			return sceneDrawer;
+		}
+
+		const Vec2& getPlanes() const
+		{
+			return planes;
+		}
+
+		const Vec2& getLimitsOfNearPlane() const
+		{
+			return limitsOfNearPlane;
+		}
+
+		const Vec2& getLimitsOfNearPlane2() const
+		{
+			return limitsOfNearPlane2;
+		}
+
+		double getMsTime() const
+		{
+			return msTime;
+		}
+
+		double getIsTime() const
+		{
+			return isTime;
+		}
+
+		double getPpsTime() const
+		{
+			return ppsTime;
+		}
+
+		double getBsTime() const
+		{
+			return bsTime;
+		}
+
+		bool getStagesProfilingEnabled() const
+		{
+			return enableStagesProfilingFlag;
+		}
+		bool& getStagesProfilingEnabled()
+		{
+			return enableStagesProfilingFlag;
+		}
+		void setStagesProfilingEnabled(const bool x)
+		{
+			enableStagesProfilingFlag = x;
+		}
 		/// @}
 
 		/// Init the renderer given an initialization class
@@ -132,7 +226,6 @@ class Renderer
 		uint width;
 		/// Height of the rendering. Don't confuse with the window width
 		uint height;
-		float aspectRatio; ///< Just a precalculated value
 		const Camera* cam; ///< Current camera
 		/// Max color attachments an FBO can accept
 		static int maxColorAtachments;

+ 29 - 1
src/r/RenderingPass.h

@@ -10,7 +10,9 @@ struct RendererInitializer;
 class RenderingPass
 {
 	public:
-		RenderingPass(Renderer& r_): r(r_) {}
+		RenderingPass(Renderer& r_)
+		:	r(r_)
+		{}
 
 		/// All passes should have an init
 		virtual void init(const RendererInitializer& initializer) = 0;
@@ -20,4 +22,30 @@ class RenderingPass
 };
 
 
+/// Rendering pass that can be enabled or disabled
+class SwitchableRenderingPass: public RenderingPass
+{
+	public:
+		SwitchableRenderingPass(Renderer& r_)
+		:	RenderingPass(r_)
+		{}
+
+		bool getEnabled() const
+		{
+			return enabled;
+		}
+		bool& getEnabled()
+		{
+			return enabled;
+		}
+		void setEnabled(const bool x)
+		{
+			enabled = x;
+		}
+
+	protected:
+		bool enabled;
+};
+
+
 #endif

+ 4 - 3
src/r/SceneDbgDrawer.h

@@ -18,7 +18,9 @@ class SceneDbgDrawer
 {
 	public:
 		/// Constructor
-		SceneDbgDrawer(Dbg& dbg_): dbg(dbg_) {}
+		SceneDbgDrawer(Dbg& dbg_)
+		:	dbg(dbg_)
+		{}
 
 		/// Draw a Camera
 		virtual void drawCamera(const Camera& cam) const;
@@ -35,8 +37,7 @@ class SceneDbgDrawer
 	private:
 		Dbg& dbg; ///< The debug stage
 
-		virtual void drawPerspectiveCamera(const
-			PerspectiveCamera& cam) const;
+		virtual void drawPerspectiveCamera(const PerspectiveCamera& cam) const;
 		virtual void drawOrthographicCamera(
 			const OrthographicCamera& cam) const;
 };

+ 3 - 1
src/r/SceneDrawer.h

@@ -22,7 +22,9 @@ class SceneDrawer
 {
 	public:
 		/// The one and only constructor
-		SceneDrawer(const Renderer& r_): r(r_) {}
+		SceneDrawer(const Renderer& r_)
+		:	r(r_)
+		{}
 
 		void renderRenderableNode(const RenderableNode& renderable,
 			const Camera& cam, PassType passType) const;

+ 27 - 7
src/r/Sm.h

@@ -4,7 +4,6 @@
 #include "RenderingPass.h"
 #include "gl/Fbo.h"
 #include "rsrc/Texture.h"
-#include "util/Accessors.h"
 #include "scene/VisibilityTester.h"
 
 
@@ -15,15 +14,36 @@ class Light;
 class Sm: private RenderingPass
 {
 	public:
-		Sm(Renderer& r_): RenderingPass(r_) {}
+		Sm(Renderer& r_)
+		:	RenderingPass(r_)
+		{}
 
 		/// @name Accessors
 		/// @{
-		GETTER_R(Texture, crntLevel->shadowMap, getShadowMap)
-		GETTER_R_BY_VAL(bool, enabled, isEnabled)
-		GETTER_R_BY_VAL(bool, pcfEnabled, isPcfEnabled)
-		GETTER_R_BY_VAL(bool, bilinearEnabled, isBilinearEnabled)
-		GETTER_R_BY_VAL(int, resolution, getResolution)
+		const Texture& getShadowMap() const
+		{
+			return crntLevel->shadowMap;
+		}
+
+		bool getEnabled() const
+		{
+			return enabled;
+		}
+
+		bool isPcfEnabled() const
+		{
+			return pcfEnabled;
+		}
+
+		bool getBilinearEnabled() const
+		{
+			return bilinearEnabled;
+		}
+
+		int getResolution() const
+		{
+			return resolution;
+		}
 		/// @}
 
 		void init(const RendererInitializer& initializer);

+ 4 - 1
src/r/Smo.h

@@ -18,7 +18,10 @@ class SpotLight;
 class Smo: public RenderingPass
 {
 	public:
-		Smo(Renderer& r_): RenderingPass(r_) {}
+		Smo(Renderer& r_)
+		:	RenderingPass(r_)
+		{}
+
 		~Smo();
 		void init(const RendererInitializer& initializer);
 		void run(const PointLight& light);

+ 14 - 6
src/r/Ssao.h

@@ -16,25 +16,33 @@
 /// 1) Calc ssao factor
 /// 2) Blur vertically
 /// 3) Blur horizontally repeat 2, 3
-class Ssao: private RenderingPass
+class Ssao: public SwitchableRenderingPass
 {
 	public:
-		Ssao(Renderer& r_): RenderingPass(r_) {}
+		Ssao(Renderer& r_)
+		:	SwitchableRenderingPass(r_)
+		{}
+
 		void init(const RendererInitializer& initializer);
 		void run();
 
 		/// @name Accessors
 		/// @{
-		GETTER_R_BY_VAL(bool, enabled, isEnabled)
-		GETTER_R_BY_VAL(float, renderingQuality, getRenderingQuality)
-		GETTER_R(Texture, fai, getFai)
+		float getRenderingQuality() const
+		{
+			return renderingQuality;
+		}
+
+		const Texture& getFai() const
+		{
+			return fai;
+		}
 		/// @}
 
 	private:
 		Texture ssaoFai; ///< It contains the unblurred SSAO factor
 		Texture hblurFai;
 		Texture fai;  ///< AKA vblurFai The final FAI
-		bool enabled;
 		float renderingQuality;
 		float blurringIterationsNum;
 		Fbo ssaoFbo;

+ 24 - 8
src/scene/Camera.h

@@ -45,22 +45,38 @@ class Camera: public SceneNode, public VisibilityInfo
 
 		/// @name Accessors
 		/// @{
-		CameraType getCameraType() const {return type;}
+		CameraType getCameraType() const
+		{
+			return type;
+		}
 
-		float getZNear() const {return zNear;}
-		float& getZNear() {return zNear;}
+		float getZNear() const
+		{
+			return zNear;
+		}
 		void setZNear(float znear);
 
-		float getZFar() const {return zFar;}
-		float& getZFar() {return zFar;}
+		float getZFar() const
+		{
+			return zFar;
+		}
 		void setZFar(float zfar);
 
-		const Mat4& getProjectionMatrix() const {return projectionMat;}
+		const Mat4& getProjectionMatrix() const
+		{
+			return projectionMat;
+		}
 
-		const Mat4& getViewMatrix() const {return viewMat;}
+		const Mat4& getViewMatrix() const
+		{
+			return viewMat;
+		}
 
 		/// See the declaration of invProjectionMat for info
-		const Mat4& getInvProjectionMatrix() const {return invProjectionMat;}
+		const Mat4& getInvProjectionMatrix() const
+		{
+			return invProjectionMat;
+		}
 
 		const Plane& getWSpaceFrustumPlane(FrustrumPlanes id) const;
 		/// @}

+ 8 - 2
src/scene/PerspectiveCamera.h

@@ -14,10 +14,16 @@ class PerspectiveCamera: public Camera
 
 		/// @name Accessors
 		/// @{
-		float getFovX() const {return fovX;}
+		float getFovX() const
+		{
+			return fovX;
+		}
 		void setFovX(float fovx);
 
-		float getFovY() const {return fovY;}
+		float getFovY() const
+		{
+			return fovY;
+		}
 		void setFovY(float fovy);
 		/// @}
 

+ 106 - 13
src/scene/SkinNode.h

@@ -6,6 +6,7 @@
 #include "util/Vec.h"
 #include "m/Math.h"
 #include "util/Accessors.h"
+#include <boost/range/iterator_range.hpp>
 
 
 class Skin;
@@ -16,25 +17,117 @@ class SkelAnimModelNodeCtrl;
 class SkinNode: public SceneNode
 {
 	public:
-		SkelAnimModelNodeCtrl* skelAnimModelNodeCtrl; ///< @todo fix this crap
+		template<typename T>
+		class Types
+		{
+			public:
+				typedef Vec<T> Container;
+				typedef typename Container::iterator Iterator;
+				typedef typename Container::const_iterator ConstIterator;
+				typedef boost::iterator_range<Iterator> MutableRange;
+				typedef boost::iterator_range<ConstIterator> ConstRange;
+		};
 
 		SkinNode(Scene& scene, ulong flags, SceneNode* parent);
 		~SkinNode();
 
 		/// @name Accessors
 		/// @{
-		GETTER_RW(Vec<Vec3>, heads, getHeads)
-		GETTER_RW(Vec<Vec3>, tails, getTails)
-		GETTER_RW(Vec<Mat3>, boneRotations, getBoneRotations)
-		GETTER_RW(Vec<Vec3>, boneTranslations, getBoneTranslations)
-		GETTER_R(Skin, *skin, getSkin)
-		GETTER_R(Obb, visibilityShapeWSpace, getVisibilityShapeWSpace)
-		GETTER_R(Vec<SkinPatchNode*>, patches, getPatchNodes)
-
-		GETTER_SETTER_BY_VAL(float, step, getStep, setStep)
-		GETTER_SETTER_BY_VAL(float, frame, getFrame, setFrame)
-		void setAnimation(const SkelAnim& anim_) {anim = &anim_;}
-		const SkelAnim* getAnimation() const {return anim;}
+		Types<Vec3>::ConstRange getHeads() const
+		{
+			return Types<Vec3>::ConstRange(heads.begin(), heads.end());
+		}
+		Types<Vec3>::MutableRange getHeads()
+		{
+			return Types<Vec3>::MutableRange(heads.begin(), heads.end());
+		}
+
+		Types<Vec3>::ConstRange getTails() const
+		{
+			return Types<Vec3>::ConstRange(tails.begin(), tails.end());
+		}
+		Types<Vec3>::MutableRange getTails()
+		{
+			return Types<Vec3>::MutableRange(tails.begin(), tails.end());
+		}
+
+		Types<Mat3>::ConstRange getBoneRotations() const
+		{
+			return Types<Mat3>::ConstRange(boneRotations.begin(),
+				boneRotations.end());
+		}
+		Types<Mat3>::MutableRange getBoneRotations()
+		{
+			return Types<Mat3>::MutableRange(boneRotations.begin(),
+				boneRotations.end());
+		}
+
+		Types<Vec3>::ConstRange getBoneTranslations() const
+		{
+			return Types<Vec3>::ConstRange(boneTranslations.begin(),
+				boneTranslations.end());
+		}
+		Types<Vec3>::MutableRange getBoneTranslations()
+		{
+			return Types<Vec3>::MutableRange(boneTranslations.begin(),
+				boneTranslations.end());
+		}
+
+		Types<SkinPatchNode*>::ConstRange getPatchNodes() const
+		{
+			return Types<SkinPatchNode*>::ConstRange(patches.begin(),
+				patches.end());
+		}
+		Types<SkinPatchNode*>::MutableRange getPatchNodes()
+		{
+			return Types<SkinPatchNode*>::MutableRange(patches.begin(),
+				patches.end());
+		}
+
+		const Obb& getVisibilityShapeWSpace() const
+		{
+			return visibilityShapeWSpace;
+		}
+
+		const Skin& getSkin() const
+		{
+			return *skin;
+		}
+
+		float getStep() const
+		{
+			return step;
+		}
+		float& getStep()
+		{
+			return step;
+		}
+		void setStep(const float x)
+		{
+			step = x;
+		}
+
+		float getFrame() const
+		{
+			return frame;
+		}
+		float& getFrame()
+		{
+			return frame;
+		}
+		void setFrame(const float x)
+		{
+			frame = x;
+		}
+
+		void setAnimation(const SkelAnim& anim_)
+		{
+			anim = &anim_;
+		}
+		const SkelAnim* getAnimation() const
+		{
+			return anim;
+		}
 		/// @}
 
 		void init(const char* filename);

+ 1 - 0
src/script/ScriptManager.cpp

@@ -29,6 +29,7 @@ BOOST_PYTHON_MODULE(anki)
 	CALL_WRAP(ModelNode);
 	CALL_WRAP(Scene);
 
+	CALL_WRAP(SwitchableRenderingPass);
 	CALL_WRAP(Hdr);
 	CALL_WRAP(Bl);
 	CALL_WRAP(Pps);

+ 1 - 1
src/script/i/Input.cpp

@@ -5,7 +5,7 @@
 WRAP(Input)
 {
 	class_<Input, noncopyable>("Input", no_init)
-		.def("warpMouse", (bool (Input::*)() const)(&Input::warpMouse))
+		.def("getWarpMouse", (bool (Input::*)() const)(&Input::getWarpMouse))
 		.def("setWarpMouse", &Input::setWarpMouse)
 	;
 }

+ 1 - 1
src/script/r/Bl.cpp

@@ -5,7 +5,7 @@
 WRAP(Bl)
 {
 	class_<Bl, noncopyable>("Bl", no_init)
-		.def("isEnabled", (bool (Bl::*)() const)(&Bl::isEnabled))
+		.def("getEnabled", (bool (Bl::*)() const)(&Bl::getEnabled))
 		.def("setEnabled", &Bl::setEnabled)
 
 		.def("getBlurringIterationsNum", (uint (Bl::*)() const)(

+ 1 - 3
src/script/r/Dbg.cpp

@@ -4,8 +4,6 @@
 
 WRAP(Dbg)
 {
-	class_<Dbg, noncopyable>("Dbg", no_init)
-		.def("isEnabled", (bool (Dbg::*)() const)(&Dbg::isEnabled))
-		.def("setEnabled", &Dbg::setEnabled)
+	class_<Dbg, bases<SwitchableRenderingPass>, noncopyable>("Dbg", no_init)
 	;
 }

+ 3 - 3
src/script/r/Hdr.cpp

@@ -12,8 +12,8 @@ WRAP(Hdr)
 		.def("getExposure", (float (Hdr::*)() const)(&Hdr::getExposure))
 		.def("setExposure", &Hdr::setExposure)
 
-		.def("getBlurringDist", (float (Hdr::*)() const)(
-			&Hdr::getBlurringDist))
-		.def("setBlurringDist", &Hdr::setBlurringDist)
+		.def("getBlurringDistance", (float (Hdr::*)() const)(
+			&Hdr::getBlurringDistance))
+		.def("setBlurringDistance", &Hdr::setBlurringDistance)
 	;
 }

+ 3 - 3
src/script/r/Renderer.cpp

@@ -13,8 +13,8 @@ WRAP(Renderer)
 		.def("getIsTime", &Renderer::getIsTime)
 		.def("getPpsTime", &Renderer::getPpsTime)
 		.def("getBsTime", &Renderer::getBsTime)
-		.def("isStagesProfilingEnabled",
-			(bool (Renderer::*)() const)(&Renderer::isStagesProfilingEnabled))
-		.def("setEnableStagesProfiling", &Renderer::setEnableStagesProfiling)
+		.def("getStagesProfilingEnabled",
+			(bool (Renderer::*)() const)(&Renderer::getStagesProfilingEnabled))
+		.def("setStagesProfilingEnabled", &Renderer::setStagesProfilingEnabled)
 	;
 }

+ 13 - 0
src/script/r/RenderingPass.cpp

@@ -0,0 +1,13 @@
+#include "ScriptCommon.h"
+#include "r/RenderingPass.h"
+
+
+WRAP(SwitchableRenderingPass)
+{
+	class_<SwitchableRenderingPass, noncopyable>("SwitchableRenderingPass",
+		no_init)
+		.def("getEnabled", (bool (SwitchableRenderingPass::*)() const)(
+			&SwitchableRenderingPass::getEnabled))
+		.def("setEnabled", &SwitchableRenderingPass::setEnabled)
+	;
+}