Panagiotis Christopoulos Charitos 14 rokov pred
rodič
commit
6c4eeac223

+ 6 - 6
shaders/MaterialFragmentFunctions.glsl

@@ -15,7 +15,7 @@
 vec3 getNormalFromTexture(in vec3 normal, in vec3 tangent, in float tangentW,
 vec3 getNormalFromTexture(in vec3 normal, in vec3 tangent, in float tangentW,
 	in sampler2D map, in vec2 texCoords)
 	in sampler2D map, in vec2 texCoords)
 {
 {
-#if !defined(DEPTH_PASS)
+#if defined(COLOR_PASS)
 	vec3 n = normalize(normal);
 	vec3 n = normalize(normal);
 	vec3 t = normalize(tangent);
 	vec3 t = normalize(tangent);
 	vec3 b = cross(n, t) * tangentW;
 	vec3 b = cross(n, t) * tangentW;
@@ -37,7 +37,7 @@ vec3 getNormalFromTexture(in vec3 normal, in vec3 tangent, in float tangentW,
 /// Just normalize
 /// Just normalize
 vec3 getNormalSimple(in vec3 normal)
 vec3 getNormalSimple(in vec3 normal)
 {
 {
-#if !defined(DEPTH_PASS)
+#if defined(COLOR_PASS)
 	return normalize(normal);
 	return normalize(normal);
 #else
 #else
 	return vec3(0.0);
 	return vec3(0.0);
@@ -56,7 +56,7 @@ vec3 getNormalSimple(in vec3 normal)
 vec3 getEnvironmentColor(in vec3 vertPosViewSpace, in vec3 normal,
 vec3 getEnvironmentColor(in vec3 vertPosViewSpace, in vec3 normal,
 	in sampler2D map)
 	in sampler2D map)
 {
 {
-#if !defined(DEPTH_PASS)
+#if defined(COLOR_PASS)
 	// In case of normal mapping I could play with vertex's normal but this 
 	// In case of normal mapping I could play with vertex's normal but this 
 	// gives better results and its allready computed
 	// gives better results and its allready computed
 	
 	
@@ -88,7 +88,7 @@ vec3 getDiffuseColorAndDoAlphaTesting(
 	in vec2 texCoords,
 	in vec2 texCoords,
 	in float tolerance)
 	in float tolerance)
 {
 {
-#if !defined(DEPTH_PASS)
+#if defined(COLOR_PASS)
 	vec4 col = texture2D(map, texCoords);
 	vec4 col = texture2D(map, texCoords);
 	if(col.a < tolerance)
 	if(col.a < tolerance)
 	{
 	{
@@ -112,7 +112,7 @@ vec3 getDiffuseColorAndDoAlphaTesting(
 /// Just read the RGB color from texture
 /// Just read the RGB color from texture
 vec3 readColor3FromTexture(in sampler2D tex, in vec2 texCoords)
 vec3 readColor3FromTexture(in sampler2D tex, in vec2 texCoords)
 {
 {
-#if !defined(DEPTH_PASS)
+#if defined(COLOR_PASS)
 	return texture2D(tex, texCoords).rgb;
 	return texture2D(tex, texCoords).rgb;
 #else
 #else
 	return vec3(0.0);
 	return vec3(0.0);
@@ -127,7 +127,7 @@ vec3 readColor3FromTexture(in sampler2D tex, in vec2 texCoords)
 void writeFais(in vec3 diffCol, in vec3 normal, in vec3 specularCol,
 void writeFais(in vec3 diffCol, in vec3 normal, in vec3 specularCol,
 	in float shininess, in float blurring)
 	in float shininess, in float blurring)
 {
 {
-#if !defined(DEPTH_PASS)
+#if defined(COLOR_PASS)
 	fMsNormalFai = vec3(packNormal(normal), blurring);
 	fMsNormalFai = vec3(packNormal(normal), blurring);
 	fMsDiffuseFai = diffCol;
 	fMsDiffuseFai = diffCol;
 	fMsSpecularFai = vec4(specularCol, shininess / MAX_SHININESS);
 	fMsSpecularFai = vec4(specularCol, shininess / MAX_SHININESS);

+ 1 - 1
shaders/MaterialFragmentVariables.glsl

@@ -1,6 +1,6 @@
 /// @name Fragment out
 /// @name Fragment out
 /// @{
 /// @{
-#if !defined(DEPTH_PASS)
+#if defined(COLOR_PASS)
 layout(location = 0) out vec3 fMsNormalFai;
 layout(location = 0) out vec3 fMsNormalFai;
 layout(location = 1) out vec3 fMsDiffuseFai;
 layout(location = 1) out vec3 fMsDiffuseFai;
 layout(location = 2) out vec4 fMsSpecularFai;
 layout(location = 2) out vec4 fMsSpecularFai;

+ 17 - 19
shaders/MaterialVertex.glsl

@@ -4,17 +4,16 @@
 /// @name Attributes
 /// @name Attributes
 /// @{
 /// @{
 in vec3 position;
 in vec3 position;
-
 #if defined(USING_TEX_COORDS_ATTRIB)
 #if defined(USING_TEX_COORDS_ATTRIB)
 in vec2 texCoords;
 in vec2 texCoords;
 #endif
 #endif
-
-#if defined(USING_NORMAL_ATTRIB)
+#if defined(COLOR_PASS)
+#	if defined(USING_NORMAL_ATTRIB)
 in vec3 normal;
 in vec3 normal;
-#endif
-
-#if defined(USING_TANGENT_ATTRIB)
+#	endif
+#	if defined(USING_TANGENT_ATTRIB)
 in vec4 tangent;
 in vec4 tangent;
+#	endif
 #endif
 #endif
 /// @}
 /// @}
 
 
@@ -30,17 +29,16 @@ uniform mat4 modelViewMat;
 #if defined(USING_TEX_COORDS_ATTRIB)
 #if defined(USING_TEX_COORDS_ATTRIB)
 out vec2 vTexCoords;
 out vec2 vTexCoords;
 #endif
 #endif
-
-#if defined(USING_NORMAL_ATTRIB)
+#if defined(COLOR_PASS)
+#	if defined(USING_NORMAL_ATTRIB)
 out vec3 vNormal;
 out vec3 vNormal;
-#endif
-
-#if defined(USING_TANGENT_ATTRIB)
+#	endif
+#	if defined(USING_TANGENT_ATTRIB)
 out vec3 vTangent;
 out vec3 vTangent;
 out float vTangentW;
 out float vTangentW;
-#endif
-
+#	endif
 out vec3 vVertPosViewSpace; ///< For env mapping. AKA view vector
 out vec3 vVertPosViewSpace; ///< For env mapping. AKA view vector
+#endif
 /// @}
 /// @}
 
 
 
 
@@ -50,16 +48,16 @@ out vec3 vVertPosViewSpace; ///< For env mapping. AKA view vector
 //==============================================================================
 //==============================================================================
 void main()
 void main()
 {
 {
-#if defined(USING_NORMAL_ATTRIB)
+#if defined(COLOR_PASS)
+#	if defined(USING_NORMAL_ATTRIB)
 	vNormal = normalMat * normal;
 	vNormal = normalMat * normal;
-#endif
-
-#if defined(USING_TANGENT_ATTRIB)
+#	endif
+#	if defined(USING_TANGENT_ATTRIB)
 	vTangent = normalMat * vec3(tangent);
 	vTangent = normalMat * vec3(tangent);
 	vTangentW = tangent.w;
 	vTangentW = tangent.w;
-#endif
-	
+#	endif
 	vVertPosViewSpace = vec3(modelViewMat * vec4(position, 1.0));
 	vVertPosViewSpace = vec3(modelViewMat * vec4(position, 1.0));
+#endif
 
 
 #if defined(USING_TEX_COORDS_ATTRIB)
 #if defined(USING_TEX_COORDS_ATTRIB)
 	vTexCoords = texCoords;
 	vTexCoords = texCoords;

+ 15 - 0
src/Renderer/Hdr.cpp

@@ -7,6 +7,21 @@
 namespace R {
 namespace R {
 
 
 
 
+//==============================================================================
+// Constructor                                                                 =
+//==============================================================================
+Hdr::Hdr(Renderer& r_)
+	: RenderingPass(r_)
+{}
+
+
+//==============================================================================
+// Destructor                                                                  =
+//==============================================================================
+Hdr::~Hdr()
+{}
+
+
 //==============================================================================
 //==============================================================================
 // initFbo                                                                    =
 // initFbo                                                                    =
 //==============================================================================
 //==============================================================================

+ 2 - 1
src/Renderer/Hdr.h

@@ -18,7 +18,8 @@ namespace R {
 class Hdr: private RenderingPass
 class Hdr: private RenderingPass
 {
 {
 	public:
 	public:
-		Hdr(Renderer& r_): RenderingPass(r_) {}
+		Hdr(Renderer& r_);
+		~Hdr();
 		void init(const RendererInitializer& initializer);
 		void init(const RendererInitializer& initializer);
 		void run();
 		void run();
 
 

+ 6 - 1
src/Renderer/Smo.cpp

@@ -19,8 +19,13 @@ const float THRESHOLD = 0.2;
 
 
 
 
 //==============================================================================
 //==============================================================================
-// Destructor                                                                  =
+// Geom                                                                        =
 //==============================================================================
 //==============================================================================
+
+Smo::Geom::Geom()
+{}
+
+
 Smo::Geom::~Geom()
 Smo::Geom::~Geom()
 {}
 {}
 
 

+ 1 - 1
src/Renderer/Smo.h

@@ -31,7 +31,7 @@ class Smo: public RenderingPass
 		/// @todo
 		/// @todo
 		struct Geom
 		struct Geom
 		{
 		{
-			Geom() {}
+			Geom();
 			~Geom();
 			~Geom();
 
 
 			RsrcPtr<Mesh> mesh;
 			RsrcPtr<Mesh> mesh;

+ 2 - 2
src/Resources/Material2.cpp

@@ -168,8 +168,8 @@ void Material2::parseMaterialTag(const boost::property_tree::ptree& pt)
 	//
 	//
 	MaterialShaderProgramCreator mspc(pt.get_child("shaderProgram"));
 	MaterialShaderProgramCreator mspc(pt.get_child("shaderProgram"));
 
 
-	const std::string& cpSrc = mspc.getShaderProgramSource();
-	std::string dpSrc = "#define DEPTH_PASS\n" + cpSrc;
+	std::string cpSrc = "#define COLOR_PASS\n" + mspc.getShaderProgramSource();
+	std::string dpSrc = "#define DEPTH_PASS\n" + mspc.getShaderProgramSource();
 
 
 	std::string cfile = createShaderProgSourceToCache(cpSrc);
 	std::string cfile = createShaderProgSourceToCache(cpSrc);
 	std::string dfile = createShaderProgSourceToCache(dpSrc);
 	std::string dfile = createShaderProgSourceToCache(dpSrc);

+ 12 - 0
src/Resources/ModelPatch.cpp

@@ -3,6 +3,18 @@
 #include "Resources/Material.h"
 #include "Resources/Material.h"
 
 
 
 
+//==============================================================================
+// Constructors & Destructors                                                  =
+//==============================================================================
+
+ModelPatch::ModelPatch()
+{}
+
+
+ModelPatch::~ModelPatch()
+{}
+
+
 //==============================================================================
 //==============================================================================
 // supportsHardwareSkinning                                                    =
 // supportsHardwareSkinning                                                    =
 //==============================================================================
 //==============================================================================

+ 3 - 0
src/Resources/ModelPatch.h

@@ -12,6 +12,9 @@ class Material;
 class ModelPatch
 class ModelPatch
 {
 {
 	public:
 	public:
+		ModelPatch();
+		~ModelPatch();
+
 		/// Load the resources
 		/// Load the resources
 		void load(const char* meshFName, const char* mtlFName,
 		void load(const char* meshFName, const char* mtlFName,
 			const char* dpMtlFName);
 			const char* dpMtlFName);

+ 3 - 0
src/Resources/ResourceManager.inl.h

@@ -87,6 +87,9 @@ typename ResourceManager::Types<Type>::Hook& ResourceManager::load(
 template<typename Type>
 template<typename Type>
 void ResourceManager::unload(const typename Types<Type>::Hook& hook)
 void ResourceManager::unload(const typename Types<Type>::Hook& hook)
 {
 {
+	typedef char TypeMustBeComplete[sizeof(Type) ? 1 : -1];
+    (void) sizeof(TypeMustBeComplete);
+
 	// Chose container
 	// Chose container
 	typename Types<Type>::Container& c = choseContainer<Type>();
 	typename Types<Type>::Container& c = choseContainer<Type>();
 
 

+ 1 - 1
src/Resources/RsrcPtr.h

@@ -17,7 +17,7 @@ class RsrcPtr
 		/// Copy constructor
 		/// Copy constructor
 		RsrcPtr(const RsrcPtr<Type>& a);
 		RsrcPtr(const RsrcPtr<Type>& a);
 
 
-		~RsrcPtr() {unload();}
+		~RsrcPtr();
 
 
 		/// Loads a resource and sets the RsrcPtr::p. The implementation of the
 		/// Loads a resource and sets the RsrcPtr::p. The implementation of the
 		/// function is different for every Resource (see RsrcPtr.cpp)
 		/// function is different for every Resource (see RsrcPtr.cpp)

+ 11 - 0
src/Resources/RsrcPtr.inl.h

@@ -1,6 +1,7 @@
 #include "RsrcPtr.h"
 #include "RsrcPtr.h"
 #include "Util/Exception.h"
 #include "Util/Exception.h"
 #include "Util/Assert.h"
 #include "Util/Assert.h"
+#include <boost/checked_delete.hpp>
 
 
 
 
 //==============================================================================
 //==============================================================================
@@ -17,6 +18,16 @@ RsrcPtr<Type>::RsrcPtr(const RsrcPtr& a):
 }
 }
 
 
 
 
+//==============================================================================
+// Constructor                                                                 =
+//==============================================================================
+template<typename Type>
+RsrcPtr<Type>::~RsrcPtr()
+{
+	unload();
+}
+
+
 //==============================================================================
 //==============================================================================
 // operator*                                                                   =
 // operator*                                                                   =
 //==============================================================================
 //==============================================================================

+ 12 - 0
src/Resources/Skin.cpp

@@ -9,6 +9,18 @@
 #include "ModelPatch.h"
 #include "ModelPatch.h"
 
 
 
 
+//==============================================================================
+// Constructors & Destructors                                                  =
+//==============================================================================
+
+Skin::Skin()
+{}
+
+
+Skin::~Skin()
+{}
+
+
 //==============================================================================
 //==============================================================================
 // load                                                                        =
 // load                                                                        =
 //==============================================================================
 //==============================================================================

+ 3 - 0
src/Resources/Skin.h

@@ -24,6 +24,9 @@ class SkelAnim;
 class Skin
 class Skin
 {
 {
 	public:
 	public:
+		Skin();
+		~Skin();
+
 		/// Implements Resource::load
 		/// Implements Resource::load
 		void load(const char*);
 		void load(const char*);
 
 

+ 8 - 0
src/Scene/ModelNode.cpp

@@ -4,6 +4,14 @@
 #include "Resources/Skeleton.h"
 #include "Resources/Skeleton.h"
 
 
 
 
+//==============================================================================
+// Constructor                                                                 =
+//==============================================================================
+ModelNode::ModelNode(bool inheritParentTrfFlag, SceneNode* parent)
+:	SceneNode(SNT_MODEL, inheritParentTrfFlag, parent)
+{}
+
+
 //==============================================================================
 //==============================================================================
 // Destructor                                                                  =
 // Destructor                                                                  =
 //==============================================================================
 //==============================================================================

+ 0 - 5
src/Scene/ModelNode.h

@@ -43,9 +43,4 @@ class ModelNode: public SceneNode
 };
 };
 
 
 
 
-inline ModelNode::ModelNode(bool inheritParentTrfFlag, SceneNode* parent)
-:	SceneNode(SNT_MODEL, inheritParentTrfFlag, parent)
-{}
-
-
 #endif
 #endif

+ 15 - 0
src/Scene/SkinNode.cpp

@@ -5,6 +5,21 @@
 #include "Resources/Skeleton.h"
 #include "Resources/Skeleton.h"
 
 
 
 
+//==============================================================================
+// Constructor                                                                 =
+//==============================================================================
+SkinNode::SkinNode(bool inheritParentTrfFlag, SceneNode* parent)
+:	SceneNode(SNT_SKIN, inheritParentTrfFlag, parent)
+{}
+
+
+//==============================================================================
+// Destructor                                                                  =
+//==============================================================================
+SkinNode::~SkinNode()
+{}
+
+
 //==============================================================================
 //==============================================================================
 // init                                                                        =
 // init                                                                        =
 //==============================================================================
 //==============================================================================

+ 1 - 5
src/Scene/SkinNode.h

@@ -19,6 +19,7 @@ class SkinNode: public SceneNode
 		SkelAnimModelNodeCtrl* skelAnimModelNodeCtrl; ///< @todo fix this crap
 		SkelAnimModelNodeCtrl* skelAnimModelNodeCtrl; ///< @todo fix this crap
 
 
 		SkinNode(bool inheritParentTrfFlag, SceneNode* parent);
 		SkinNode(bool inheritParentTrfFlag, SceneNode* parent);
+		~SkinNode();
 
 
 		/// @name Accessors
 		/// @name Accessors
 		/// @{
 		/// @{
@@ -52,9 +53,4 @@ class SkinNode: public SceneNode
 };
 };
 
 
 
 
-inline SkinNode::SkinNode(bool inheritParentTrfFlag, SceneNode* parent)
-:	SceneNode(SNT_SKIN, inheritParentTrfFlag, parent)
-{}
-
-
 #endif
 #endif