Components Folder
- Created a header file for each component inside a Components folder - Fixed entt::entity's default value being entt::entity() to entt::null - Minor tidying for DebugTrap
This commit is contained in:
		
							parent
							
								
									9033ceffa1
								
							
						
					
					
						commit
						931a3a168c
					
				
					 5 changed files with 61 additions and 46 deletions
				
			
		| 
						 | 
				
			
			@ -69,34 +69,34 @@
 | 
			
		|||
	#else
 | 
			
		||||
		#include <signal.h>
 | 
			
		||||
 | 
			
		||||
	#if defined(SIGTRAP)
 | 
			
		||||
		#define LT_DEBUG_TRAP() raise(SIGTRAP)
 | 
			
		||||
		#if defined(SIGTRAP)
 | 
			
		||||
			#define LT_DEBUG_TRAP() raise(SIGTRAP)
 | 
			
		||||
 | 
			
		||||
	#else
 | 
			
		||||
		#define LT_DEBUG_TRAP() raise(SIGABRT)
 | 
			
		||||
		#else
 | 
			
		||||
			#define LT_DEBUG_TRAP() raise(SIGABRT)
 | 
			
		||||
 | 
			
		||||
	#endif
 | 
			
		||||
		#endif
 | 
			
		||||
	#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !defined(LT_DEBUG_TRAP)
 | 
			
		||||
	#define LT_BERAK LT_ENGINE_ERROR("Unable to break!, LT_BREAK macro is undefined")
 | 
			
		||||
	#if !defined(LIGHT_IGNORE_UNDEFINED_DEBUG_BREAK)
 | 
			
		||||
		#error "failed to define LT_BREAK, define LIGHT_IGNORE_UNDEFINED_DEBUG_BREAK to disable this error"
 | 
			
		||||
	#elif !defined(LIGHT_DIST)
 | 
			
		||||
 | 
			
		||||
	#elif defined(LIGHT_DIST)
 | 
			
		||||
		#ifdef _MSC_VER
 | 
			
		||||
		#define LT_DEBUG_TRAP() LT_FILE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", __FUNCSIG__, __FILE__, __LINE__) // or __FUNCSIG__
 | 
			
		||||
			#define LT_DEBUG_TRAP() LT_FILE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", __FUNCSIG__, __FILE__, __LINE__) // or __FUNCSIG__
 | 
			
		||||
	
 | 
			
		||||
		#else
 | 
			
		||||
		#define LT_DEBUG_TRAP() LT_FILE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}",	__PRETTY_FUNCTION__ )
 | 
			
		||||
			#define LT_DEBUG_TRAP() LT_FILE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}",	__PRETTY_FUNCTION__ )
 | 
			
		||||
	
 | 
			
		||||
		#endif
 | 
			
		||||
	#else
 | 
			
		||||
	#else /* !defined(LIGHT_DIST) */
 | 
			
		||||
		#ifdef _MSC_VER
 | 
			
		||||
		#define LT_DEBUG_TRAP() LT_ENGINE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", __FUNCSIG__, __FILE__, __LINE__) // or __FUNCSIG__
 | 
			
		||||
			#define LT_DEBUG_TRAP() LT_ENGINE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", __FUNCSIG__, __FILE__, __LINE__) // or __FUNCSIG__
 | 
			
		||||
	
 | 
			
		||||
		#else
 | 
			
		||||
	#define LT_DEBUG_TRAP() LT_ENGINE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}",	__PRETTY_FUNCTION__ )
 | 
			
		||||
			#define LT_DEBUG_TRAP() LT_ENGINE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}",	__PRETTY_FUNCTION__ )
 | 
			
		||||
	
 | 
			
		||||
	#endif
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,36 +2,6 @@
 | 
			
		|||
 | 
			
		||||
#include "Base/Base.h"
 | 
			
		||||
 | 
			
		||||
#include <glm/glm.hpp>
 | 
			
		||||
 | 
			
		||||
namespace Light {
 | 
			
		||||
 | 
			
		||||
	class Texture;
 | 
			
		||||
 | 
			
		||||
	// #todo: store a mat4 for transform
 | 
			
		||||
	struct TransformComponent
 | 
			
		||||
	{
 | 
			
		||||
		glm::vec2 position, size;
 | 
			
		||||
 | 
			
		||||
		// glm::mat4 transform{ 1.0f };
 | 
			
		||||
 | 
			
		||||
		TransformComponent() = default;
 | 
			
		||||
		TransformComponent(const TransformComponent&) = default;
 | 
			
		||||
		TransformComponent(const glm::vec2& _position, const glm::vec2& _size) : position(_position), size(_size) {}
 | 
			
		||||
 | 
			
		||||
		// operator glm::mat4&() { return transform; }
 | 
			
		||||
		// operator const glm::mat4& () const { return transform; }
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	struct SpriteRendererComponent
 | 
			
		||||
	{
 | 
			
		||||
		Ref<Texture> texture;
 | 
			
		||||
 | 
			
		||||
		SpriteRendererComponent() = default;
 | 
			
		||||
		SpriteRendererComponent(const SpriteRendererComponent&) = default;
 | 
			
		||||
		SpriteRendererComponent(Ref<Texture> _texture) : texture(_texture) {}
 | 
			
		||||
 | 
			
		||||
		operator Ref<Texture>() { return texture; }
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
#include "Components/TransformComponent.h"
 | 
			
		||||
#include "Components/SpriteRendererComponent.h"
 | 
			
		||||
#include "Components/CameraComponent.h"
 | 
			
		||||
							
								
								
									
										22
									
								
								Engine/src/Engine/Scene/Components/SpriteRendererComponent.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								Engine/src/Engine/Scene/Components/SpriteRendererComponent.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,22 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "Base/Base.h"
 | 
			
		||||
 | 
			
		||||
#include <glm/glm.hpp>
 | 
			
		||||
 | 
			
		||||
namespace Light {
 | 
			
		||||
 | 
			
		||||
	class Texture;
 | 
			
		||||
 | 
			
		||||
	struct SpriteRendererComponent
 | 
			
		||||
	{
 | 
			
		||||
		Ref<Texture> texture;
 | 
			
		||||
 | 
			
		||||
		SpriteRendererComponent() = default;
 | 
			
		||||
		SpriteRendererComponent(const SpriteRendererComponent&) = default;
 | 
			
		||||
		SpriteRendererComponent(Ref<Texture> _texture) : texture(_texture) {}
 | 
			
		||||
 | 
			
		||||
		operator Ref<Texture>() { return texture; }
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								Engine/src/Engine/Scene/Components/TransformComponent.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Engine/src/Engine/Scene/Components/TransformComponent.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "Base/Base.h"
 | 
			
		||||
 | 
			
		||||
#include <glm/glm.hpp>
 | 
			
		||||
 | 
			
		||||
namespace Light {
 | 
			
		||||
 | 
			
		||||
	struct TransformComponent
 | 
			
		||||
	{
 | 
			
		||||
		glm::vec2 position, size;
 | 
			
		||||
 | 
			
		||||
		// glm::mat4 transform{ 1.0f };
 | 
			
		||||
 | 
			
		||||
		TransformComponent() = default;
 | 
			
		||||
		TransformComponent(const TransformComponent&) = default;
 | 
			
		||||
		TransformComponent(const glm::vec2& _position, const glm::vec2& _size) : position(_position), size(_size) {}
 | 
			
		||||
 | 
			
		||||
		// operator glm::mat4&() { return transform; }
 | 
			
		||||
		// operator const glm::mat4& () const { return transform; }
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -15,7 +15,7 @@ namespace Light {
 | 
			
		|||
		Scene* m_Scene;
 | 
			
		||||
 | 
			
		||||
	public:
 | 
			
		||||
		Entity(entt::entity handle = entt::entity(), Scene* registry = nullptr);
 | 
			
		||||
		Entity(entt::entity handle = entt::null, Scene* registry = nullptr);
 | 
			
		||||
		~Entity();
 | 
			
		||||
 | 
			
		||||
		template<typename T, typename... Args>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue