Formatted EVERYTHING
This commit is contained in:
@@ -3,38 +3,23 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Actor::Actor(PScene scene)
|
||||
: Entity(scene)
|
||||
{
|
||||
attachComponent<Component::Transform>();
|
||||
}
|
||||
Actor::Actor(PScene scene) : Entity(scene) { attachComponent<Component::Transform>(); }
|
||||
|
||||
Actor::~Actor()
|
||||
{
|
||||
Actor::~Actor() {}
|
||||
|
||||
}
|
||||
|
||||
void Actor::setParent(PActor newParent)
|
||||
{
|
||||
if(parent != nullptr)
|
||||
{
|
||||
void Actor::setParent(PActor newParent) {
|
||||
if (parent != nullptr) {
|
||||
parent->removeChild(this);
|
||||
}
|
||||
parent = newParent;
|
||||
}
|
||||
void Actor::addChild(PActor child)
|
||||
{
|
||||
void Actor::addChild(PActor child) {
|
||||
children.add(child);
|
||||
child->setParent(this);
|
||||
}
|
||||
void Actor::removeChild(PActor child)
|
||||
{
|
||||
void Actor::removeChild(PActor child) {
|
||||
children.remove(children.find(child), false);
|
||||
child->setParent(nullptr);
|
||||
}
|
||||
|
||||
Component::Transform& Actor::getTransform()
|
||||
{
|
||||
return accessComponent<Component::Transform>();
|
||||
}
|
||||
|
||||
Component::Transform& Actor::getTransform() { return accessComponent<Component::Transform>(); }
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
#pragma once
|
||||
#include "Entity.h"
|
||||
#include "Component/Transform.h"
|
||||
#include "Entity.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
|
||||
namespace Seele {
|
||||
DECLARE_REF(Actor)
|
||||
// Actors are entities that are part of the scene hierarchy
|
||||
// In order for that hierarchy to make sense it requires at least a transform component
|
||||
class Actor : public Entity
|
||||
{
|
||||
public:
|
||||
class Actor : public Entity {
|
||||
public:
|
||||
Actor(PScene scene);
|
||||
virtual ~Actor();
|
||||
|
||||
@@ -17,11 +16,11 @@ public:
|
||||
void addChild(PActor child);
|
||||
void removeChild(PActor child);
|
||||
Array<PActor> getChildren();
|
||||
|
||||
|
||||
Component::Transform& getTransform();
|
||||
|
||||
protected:
|
||||
//Component::Transform& getTransform();
|
||||
protected:
|
||||
// Component::Transform& getTransform();
|
||||
void setParent(PActor parent);
|
||||
PActor parent;
|
||||
Array<PActor> children;
|
||||
|
||||
@@ -3,23 +3,13 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
CameraActor::CameraActor(PScene scene)
|
||||
: Actor(scene)
|
||||
{
|
||||
CameraActor::CameraActor(PScene scene) : Actor(scene) {
|
||||
attachComponent<Component::Camera>();
|
||||
accessComponent<Component::Transform>().setPosition(Vector(10, 5, 14));
|
||||
}
|
||||
|
||||
CameraActor::~CameraActor()
|
||||
{
|
||||
}
|
||||
CameraActor::~CameraActor() {}
|
||||
|
||||
Component::Camera& CameraActor::getCameraComponent()
|
||||
{
|
||||
return accessComponent<Component::Camera>();
|
||||
}
|
||||
Component::Camera& CameraActor::getCameraComponent() { return accessComponent<Component::Camera>(); }
|
||||
|
||||
const Component::Camera& CameraActor::getCameraComponent() const
|
||||
{
|
||||
return accessComponent<Component::Camera>();
|
||||
}
|
||||
const Component::Camera& CameraActor::getCameraComponent() const { return accessComponent<Component::Camera>(); }
|
||||
@@ -2,16 +2,15 @@
|
||||
#include "Actor.h"
|
||||
#include "Component/Camera.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class CameraActor : public Actor
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
class CameraActor : public Actor {
|
||||
public:
|
||||
CameraActor(PScene scene);
|
||||
virtual ~CameraActor();
|
||||
Component::Camera& getCameraComponent();
|
||||
const Component::Camera& getCameraComponent() const;
|
||||
private:
|
||||
|
||||
private:
|
||||
};
|
||||
DEFINE_REF(CameraActor)
|
||||
} // namespace Seele
|
||||
|
||||
@@ -2,29 +2,18 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
DirectionalLightActor::DirectionalLightActor(PScene scene)
|
||||
: Actor(scene)
|
||||
{
|
||||
attachComponent<Component::DirectionalLight>();
|
||||
}
|
||||
DirectionalLightActor::DirectionalLightActor(PScene scene) : Actor(scene) { attachComponent<Component::DirectionalLight>(); }
|
||||
|
||||
DirectionalLightActor::DirectionalLightActor(PScene scene, Vector color, Vector direction)
|
||||
: Actor(scene)
|
||||
{
|
||||
DirectionalLightActor::DirectionalLightActor(PScene scene, Vector color, Vector direction) : Actor(scene) {
|
||||
attachComponent<Component::DirectionalLight>(Vector4(color, 0), Vector4(direction, 0));
|
||||
}
|
||||
|
||||
DirectionalLightActor::~DirectionalLightActor()
|
||||
{
|
||||
|
||||
}
|
||||
DirectionalLightActor::~DirectionalLightActor() {}
|
||||
|
||||
Component::DirectionalLight& DirectionalLightActor::getDirectionalLightComponent()
|
||||
{
|
||||
Component::DirectionalLight& DirectionalLightActor::getDirectionalLightComponent() {
|
||||
return accessComponent<Component::DirectionalLight>();
|
||||
}
|
||||
|
||||
const Component::DirectionalLight& DirectionalLightActor::getDirectionalLightComponent() const
|
||||
{
|
||||
const Component::DirectionalLight& DirectionalLightActor::getDirectionalLightComponent() const {
|
||||
return accessComponent<Component::DirectionalLight>();
|
||||
}
|
||||
@@ -2,17 +2,16 @@
|
||||
#include "Actor.h"
|
||||
#include "Component/DirectionalLight.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class DirectionalLightActor : public Actor
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
class DirectionalLightActor : public Actor {
|
||||
public:
|
||||
DirectionalLightActor(PScene scene);
|
||||
DirectionalLightActor(PScene scene, Vector color, Vector direction);
|
||||
virtual ~DirectionalLightActor();
|
||||
Component::DirectionalLight& getDirectionalLightComponent();
|
||||
const Component::DirectionalLight& getDirectionalLightComponent() const;
|
||||
private:
|
||||
|
||||
private:
|
||||
};
|
||||
DEFINE_REF(DirectionalLightActor)
|
||||
} // namespace Seele
|
||||
|
||||
@@ -2,14 +2,6 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Entity::Entity(PScene scene)
|
||||
: scene(scene)
|
||||
, identifier(scene->createEntity())
|
||||
{
|
||||
}
|
||||
Entity::Entity(PScene scene) : scene(scene), identifier(scene->createEntity()) {}
|
||||
|
||||
|
||||
Entity::~Entity()
|
||||
{
|
||||
scene->destroyEntity(identifier);
|
||||
}
|
||||
Entity::~Entity() { scene->destroyEntity(identifier); }
|
||||
+10
-20
@@ -1,33 +1,23 @@
|
||||
#pragma once
|
||||
#include <entt/entt.hpp>
|
||||
#include "MinimalEngine.h"
|
||||
#include "Scene/Scene.h"
|
||||
namespace Seele
|
||||
{
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
namespace Seele {
|
||||
// An entity describes a part of a scene
|
||||
// It is just a wrapper the ID of a registry
|
||||
class Entity
|
||||
{
|
||||
public:
|
||||
class Entity {
|
||||
public:
|
||||
Entity(PScene scene);
|
||||
virtual ~Entity();
|
||||
|
||||
template<typename Component, typename... Args>
|
||||
Component& attachComponent(Args&&... args)
|
||||
{
|
||||
template <typename Component, typename... Args> Component& attachComponent(Args&&... args) {
|
||||
return scene->attachComponent<Component>(identifier, std::forward<Args>(args)...);
|
||||
}
|
||||
template<typename Component>
|
||||
Component& accessComponent()
|
||||
{
|
||||
return scene->accessComponent<Component>(identifier);
|
||||
}
|
||||
template<typename Component>
|
||||
const Component& accessComponent() const
|
||||
{
|
||||
return scene->accessComponent<Component>(identifier);
|
||||
}
|
||||
protected:
|
||||
template <typename Component> Component& accessComponent() { return scene->accessComponent<Component>(identifier); }
|
||||
template <typename Component> const Component& accessComponent() const { return scene->accessComponent<Component>(identifier); }
|
||||
|
||||
protected:
|
||||
PScene scene;
|
||||
entt::entity identifier;
|
||||
};
|
||||
|
||||
@@ -2,29 +2,14 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
PointLightActor::PointLightActor(PScene scene)
|
||||
: Actor(scene)
|
||||
{
|
||||
attachComponent<Component::PointLight>();
|
||||
}
|
||||
PointLightActor::PointLightActor(PScene scene) : Actor(scene) { attachComponent<Component::PointLight>(); }
|
||||
|
||||
PointLightActor::PointLightActor(PScene scene, Vector position, Vector color, float attenuation)
|
||||
: Actor(scene)
|
||||
{
|
||||
PointLightActor::PointLightActor(PScene scene, Vector position, Vector color, float attenuation) : Actor(scene) {
|
||||
attachComponent<Component::PointLight>(Vector4(position, 1), Vector4(color, attenuation));
|
||||
}
|
||||
|
||||
PointLightActor::~PointLightActor()
|
||||
{
|
||||
|
||||
}
|
||||
PointLightActor::~PointLightActor() {}
|
||||
|
||||
Component::PointLight& PointLightActor::getPointLightComponent()
|
||||
{
|
||||
return accessComponent<Component::PointLight>();
|
||||
}
|
||||
Component::PointLight& PointLightActor::getPointLightComponent() { return accessComponent<Component::PointLight>(); }
|
||||
|
||||
const Component::PointLight& PointLightActor::getPointLightComponent() const
|
||||
{
|
||||
return accessComponent<Component::PointLight>();
|
||||
}
|
||||
const Component::PointLight& PointLightActor::getPointLightComponent() const { return accessComponent<Component::PointLight>(); }
|
||||
@@ -2,17 +2,16 @@
|
||||
#include "Actor.h"
|
||||
#include "Component/PointLight.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class PointLightActor : public Actor
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
class PointLightActor : public Actor {
|
||||
public:
|
||||
PointLightActor(PScene scene);
|
||||
PointLightActor(PScene scene, Vector position, Vector color, float attenuation);
|
||||
virtual ~PointLightActor();
|
||||
Component::PointLight& getPointLightComponent();
|
||||
const Component::PointLight& getPointLightComponent() const;
|
||||
private:
|
||||
|
||||
private:
|
||||
};
|
||||
DEFINE_REF(PointLightActor)
|
||||
} // namespace Seele
|
||||
|
||||
@@ -2,22 +2,10 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
StaticMeshActor::StaticMeshActor(PScene scene, PMeshAsset mesh)
|
||||
: Actor(scene)
|
||||
{
|
||||
attachComponent<Component::Mesh>(mesh);
|
||||
}
|
||||
StaticMeshActor::StaticMeshActor(PScene scene, PMeshAsset mesh) : Actor(scene) { attachComponent<Component::Mesh>(mesh); }
|
||||
|
||||
Seele::StaticMeshActor::~StaticMeshActor()
|
||||
{
|
||||
}
|
||||
Seele::StaticMeshActor::~StaticMeshActor() {}
|
||||
|
||||
Component::Mesh &Seele::StaticMeshActor::getMesh()
|
||||
{
|
||||
return accessComponent<Component::Mesh>();
|
||||
}
|
||||
Component::Mesh& Seele::StaticMeshActor::getMesh() { return accessComponent<Component::Mesh>(); }
|
||||
|
||||
const Component::Mesh &Seele::StaticMeshActor::getMesh() const
|
||||
{
|
||||
return accessComponent<Component::Mesh>();
|
||||
}
|
||||
const Component::Mesh& Seele::StaticMeshActor::getMesh() const { return accessComponent<Component::Mesh>(); }
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
#include "Actor.h"
|
||||
#include "Component/Mesh.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class StaticMeshActor : public Actor
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
class StaticMeshActor : public Actor {
|
||||
public:
|
||||
StaticMeshActor(PScene scene, PMeshAsset mesh);
|
||||
virtual ~StaticMeshActor();
|
||||
Component::Mesh& getMesh();
|
||||
const Component::Mesh& getMesh() const;
|
||||
private:
|
||||
|
||||
private:
|
||||
};
|
||||
DEFINE_REF(StaticMeshActor)
|
||||
} // namespace Seele
|
||||
|
||||
Reference in New Issue
Block a user