Browse Source

Nothing important

Panagiotis Christopoulos Charitos 15 years ago
parent
commit
93ec720c7d

+ 14 - 44
src/Resources/Core/RsrcPtr.h

@@ -4,42 +4,32 @@
 #include "Common.h"
 #include "Common.h"
 
 
 
 
-/**
- * This is a special smart pointer that points to Resource derivatives. It looks like auto_ptr but the main difference
- * is that when its out of scope it tries to unload the resource.
- */
+/// This is a special smart pointer that points to Resource derivatives. It looks like auto_ptr but the main difference
+/// is that when its out of scope it tries to unload the resource.
 template<typename Type>
 template<typename Type>
 class RsrcPtr
 class RsrcPtr
 {
 {
 	public:
 	public:
-		RsrcPtr();
-
-		/**
-		 * It unloads the resource or it decreases its reference counter
-		 */
-		~RsrcPtr();
-
-		/**
-		 * Loads a resource and sets the RsrcPtr::p. The implementation of the function is different for every Resource (see
-		 * RsrcPtr.cpp)
-		 * @param filename
-		 * @return True on success
-		 */
+		RsrcPtr(): p(NULL) {}
+
+		/// It unloads the resource or it decreases its reference counter
+		~RsrcPtr() {unload();}
+
+		/// Loads a resource and sets the RsrcPtr::p. The implementation of the function is different for every Resource
+		/// (see RsrcPtr.cpp)
+		/// @param filename
+		/// @return True on success
 		bool loadRsrc(const char* filename);
 		bool loadRsrc(const char* filename);
 
 
 		Type& operator*() const;
 		Type& operator*() const;
 		Type* operator->() const;
 		Type* operator->() const;
-		Type* get() const;
+		Type* get() const {return p;}
 
 
 	private:
 	private:
-		/**
-		 * Non copyable
-		 */
+		/// Non copyable
 		RsrcPtr(const RsrcPtr& a);
 		RsrcPtr(const RsrcPtr& a);
 
 
-		/**
-		 * Unloads the resource @see loadRsrc
-		 */
+		/// Unloads the resource @see loadRsrc
 		void unload();
 		void unload();
 
 
 		Type* p; ///< Pointer to the Resource derivative
 		Type* p; ///< Pointer to the Resource derivative
@@ -50,19 +40,6 @@ class RsrcPtr
 // Inlines                                                                                                             =
 // Inlines                                                                                                             =
 //======================================================================================================================
 //======================================================================================================================
 
 
-template<typename Type>
-RsrcPtr<Type>::RsrcPtr():
-	p(NULL)
-{}
-
-
-template<typename Type>
-RsrcPtr<Type>::~RsrcPtr()
-{
-	unload();
-}
-
-
 template<typename Type>
 template<typename Type>
 Type& RsrcPtr<Type>::operator*() const
 Type& RsrcPtr<Type>::operator*() const
 {
 {
@@ -79,11 +56,4 @@ Type* RsrcPtr<Type>::operator->() const
 }
 }
 
 
 
 
-template<typename Type>
-Type* RsrcPtr<Type>::get() const
-{
-	return p;
-}
-
-
 #endif
 #endif

+ 1 - 21
src/Resources/LightProps.h

@@ -8,27 +8,6 @@
 #include "Texture.h"
 #include "Texture.h"
 
 
 
 
-/// Light data
-class LightData
-{
-	PROPERTY_R(Vec3, diffuseCol, getDiffuseColor)
-	PROPERTY_R(Vec3, specularCol, getSpecularColor)
-	PROPERTY_R(float, radius, getRadius) ///< For point lights
-	PROPERTY_R(bool, castsShadow_, castsShadow) ///< For spot lights
-	PROPERTY_R(float, distance, getDistance) ///< For spot lights. A.K.A.: camera's zFar
-	PROPERTY_R(float, fovX, getFovX) ///< For spot lights
-	PROPERTY_R(float, fovY, getFovY) ///< For spot lights
-
-	public:
-		LightData() {}
-		virtual ~LightData() {}
-		bool load(const char* filename);
-		const Texture* getTexture() const;
-
-	private:
-		RsrcPtr<Texture> texture; ///< For spot lights
-};
-
 /// Light properties Resource
 /// Light properties Resource
 class LightProps: public Resource
 class LightProps: public Resource
 {
 {
@@ -57,4 +36,5 @@ inline const Texture* LightProps::getTexture() const
 	return texture.get();
 	return texture.get();
 }
 }
 
 
+
 #endif
 #endif

+ 2 - 3
src/Resources/Mesh.h

@@ -71,9 +71,7 @@ class Mesh: public Resource
 		~Mesh() {}
 		~Mesh() {}
 		bool load(const char* filename);
 		bool load(const char* filename);
 
 
-		/**
-		 * The mesh is renderable when the material is loaded
-		 */
+		/// The mesh is renderable when the material is loaded
 		bool isRenderable() const;
 		bool isRenderable() const;
 
 
 	private:
 	private:
@@ -98,4 +96,5 @@ inline void Mesh::createAllNormals()
 	createVertNormals();
 	createVertNormals();
 }
 }
 
 
+
 #endif
 #endif

+ 22 - 16
src/Resources/ParticleEmitterProps.cpp

@@ -21,9 +21,7 @@ ParticleEmitterPropsStruct::ParticleEmitterPropsStruct():
 	gravityMargin(0.0),
 	gravityMargin(0.0),
 	startingPos(0.0),
 	startingPos(0.0),
 	startingPosMargin(0.0),
 	startingPosMargin(0.0),
-	size(0.0),
-	usingWorldGrav(true),
-	hasForce(false)
+	size(0.0)
 {}
 {}
 
 
 
 
@@ -42,13 +40,33 @@ ParticleEmitterPropsStruct::ParticleEmitterPropsStruct(const ParticleEmitterProp
 ParticleEmitterPropsStruct& ParticleEmitterPropsStruct::operator=(const ParticleEmitterPropsStruct& a)
 ParticleEmitterPropsStruct& ParticleEmitterPropsStruct::operator=(const ParticleEmitterPropsStruct& a)
 {
 {
 	memcpy(this, &(const_cast<ParticleEmitterPropsStruct&>(a)), sizeof(ParticleEmitterPropsStruct));
 	memcpy(this, &(const_cast<ParticleEmitterPropsStruct&>(a)), sizeof(ParticleEmitterPropsStruct));
+	return *this;
+}
+
+
+//======================================================================================================================
+// hasForce                                                                                                            =
+//======================================================================================================================
+bool ParticleEmitterPropsStruct::hasForce() const
+{
+	return (!M::isZero(forceDirection.getLengthSquared()) || !M::isZero(forceDirectionMargin.getLengthSquared())) &&
+	       (forceMagnitude != 0.0 || forceMagnitudeMargin != 0.0);
+}
+
+
+//======================================================================================================================
+// usingWorldGrav                                                                                                      =
+//======================================================================================================================
+bool ParticleEmitterPropsStruct::usingWorldGrav() const
+{
+	return M::isZero(gravity.getLengthSquared());
 }
 }
 
 
 
 
 //======================================================================================================================
 //======================================================================================================================
 // load                                                                                                                =
 // load                                                                                                                =
 //======================================================================================================================
 //======================================================================================================================
-bool ParticleEmitterProps::load(const char* filename)
+bool ParticleEmitterProps::load(const char* /*filename*/)
 {
 {
 	// dummy load
 	// dummy load
 	particleLife = 7.0;
 	particleLife = 7.0;
@@ -72,18 +90,6 @@ bool ParticleEmitterProps::load(const char* filename)
 	emittionPeriod = 1.5;
 	emittionPeriod = 1.5;
 	particlesPerEmittion = 2;
 	particlesPerEmittion = 2;
 
 
-	// set some values
-	if((M::isZero(forceDirection.getLength()) && M::isZero(forceDirectionMargin.getLength())) ||
-	   (forceMagnitude == 0.0 && forceMagnitudeMargin == 0.0))
-	{
-		hasForce = false;
-	}
-	else
-		hasForce = true;
-
-	usingWorldGrav = M::isZero(gravity.getLength());
-
-
 	// sanity checks
 	// sanity checks
 	if(particleLife <= 0.0)
 	if(particleLife <= 0.0)
 	{
 	{

+ 3 - 5
src/Resources/ParticleEmitterProps.h

@@ -16,7 +16,7 @@ class ParticleEmitterPropsStruct
 		float particleLife; ///< Required and > 0.0
 		float particleLife; ///< Required and > 0.0
 		float particleLifeMargin;
 		float particleLifeMargin;
 
 
-		Vec3 forceDirection; ///< Not-required, any value, If not set only the gravity applies
+		Vec3 forceDirection; ///< Not-required, any value, Default 0.0, If not set only the gravity applies
 		Vec3 forceDirectionMargin;
 		Vec3 forceDirectionMargin;
 		float forceMagnitude; ///< Default 0.0
 		float forceMagnitude; ///< Default 0.0
 		float forceMagnitudeMargin;
 		float forceMagnitudeMargin;
@@ -44,10 +44,8 @@ class ParticleEmitterPropsStruct
 		ParticleEmitterPropsStruct(const ParticleEmitterPropsStruct& a);
 		ParticleEmitterPropsStruct(const ParticleEmitterPropsStruct& a);
 		ParticleEmitterPropsStruct& operator=(const ParticleEmitterPropsStruct& a);
 		ParticleEmitterPropsStruct& operator=(const ParticleEmitterPropsStruct& a);
 		~ParticleEmitterPropsStruct() {}
 		~ParticleEmitterPropsStruct() {}
-
-	protected:
-		bool usingWorldGrav; ///< This flag indicates if we should use the default world gravity or to override it
-		bool hasForce; ///< False if all force stuff are zero
+		bool hasForce() const; ///< Dont call it offten. Its slow
+		bool usingWorldGrav() const; ///< @return True if gravity is derived
 };
 };
 
 
 
 

+ 1 - 3
src/Resources/Script.h

@@ -5,9 +5,7 @@
 #include "Resource.h"
 #include "Resource.h"
 
 
 
 
-/**
- * Python script resource
- */
+/// Python script resource
 class Script: public Resource
 class Script: public Resource
 {
 {
 	public:
 	public:

+ 6 - 3
src/Scene/ParticleEmitter.cpp

@@ -92,6 +92,9 @@ void ParticleEmitter::update()
 		}
 		}
 	}
 	}
 
 
+	// pre calculate
+	bool forceFlag = hasForce();
+	bool worldGravFlag = usingWorldGrav();
 
 
 	if((crntTime - timeOfPrevEmittion) > emittionPeriod)
 	if((crntTime - timeOfPrevEmittion) > emittionPeriod)
 	{
 	{
@@ -122,7 +125,7 @@ void ParticleEmitter::update()
 			//cout << p.body->internalGetDeltaAngularVelocity() << endl;
 			//cout << p.body->internalGetDeltaAngularVelocity() << endl;
 
 
 			// force
 			// force
-			if(hasForce)
+			if(forceFlag)
 			{
 			{
 				Vec3 forceDir;
 				Vec3 forceDir;
 				if(forceDirectionMargin != Vec3(0.0))
 				if(forceDirectionMargin != Vec3(0.0))
@@ -154,10 +157,10 @@ void ParticleEmitter::update()
 			}
 			}
 
 
 			// gravity
 			// gravity
-			if(!usingWorldGrav)
+			if(!worldGravFlag)
 			{
 			{
 				Vec3 grav;
 				Vec3 grav;
-				if(gravityMargin != Vec3(0.0, 0.0, 0.0))
+				if(gravityMargin != Vec3(0.0))
 				{
 				{
 					for(int i=0; i<3; i++)
 					for(int i=0; i<3; i++)
 					{
 					{