Merge fixes
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include "../Core/Ray.h"
|
||||
#include "../Core/AABB.h"
|
||||
#include "../Rendering/RawModel.h"
|
||||
#include "../Rendering/RenderQueueFactory.h"
|
||||
#include "../Core/Transform.h"
|
||||
#include "../Core/Entity.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
|
||||
|
||||
@@ -14,22 +14,24 @@
|
||||
#include "ModelJob.h"
|
||||
#include "Renderer.h"
|
||||
#include "../Core/Transform.h"
|
||||
#include "DebugCameraInputController.h"
|
||||
|
||||
class RenderSystem : public ImpureSystem
|
||||
{
|
||||
public:
|
||||
RenderSystem(EventBroker* eventBrokerer, const IRenderer* renderer, RenderFrame* renderFrame);
|
||||
~RenderSystem();
|
||||
|
||||
virtual void Update(World* world, double dt) override;
|
||||
|
||||
private:
|
||||
World* m_World = nullptr;
|
||||
const IRenderer* m_Renderer = nullptr;
|
||||
const IRenderer* m_Renderer;
|
||||
|
||||
RenderFrame* m_RenderFrame;
|
||||
bool m_SwitchCamera = false;
|
||||
Camera* m_Camera = nullptr;
|
||||
Camera* m_DefaultCamera = nullptr;
|
||||
Camera* m_Camera;
|
||||
DebugCameraInputController<RenderSystem>* m_DebugCameraInputController;
|
||||
|
||||
std::list<ComponentWrapper> m_CameraComponents;
|
||||
|
||||
@@ -41,8 +43,6 @@ private:
|
||||
|
||||
void updateCamera(World* world, double dt);
|
||||
void updateProjectionMatrix(ComponentWrapper& cameraComponent);
|
||||
glm::mat4 m_ViewMatrix;
|
||||
glm::mat4 m_ProjectionMatrix;
|
||||
|
||||
void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<c:Camera>
|
||||
<Name>cam</Name>
|
||||
<FOV>60.0</FOV>
|
||||
<FOV>45</FOV>
|
||||
<NearClip>0.01</NearClip>
|
||||
<FarClip>5000</FarClip>
|
||||
</c:Camera>
|
||||
@@ -10,7 +10,9 @@
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="Name" type="t:string" minOccurs="0"/>
|
||||
<xs:element name="FOV" type="t:double" minOccurs="0"/>
|
||||
<xs:element name="FOV" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Vertical Field of View in degrees</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="NearClip" type="t:double" minOccurs="0"/>
|
||||
<xs:element name="FarClip" type="t:double" minOccurs="0"/>
|
||||
</xs:all>
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
</Components>
|
||||
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Camera/>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:AABB/>
|
||||
|
||||
@@ -290,8 +290,8 @@ boost::optional<AABB> EntityAbsoluteAABB(EntityWrapper& entity)
|
||||
}
|
||||
|
||||
ComponentWrapper& cAABB = entity["AABB"];
|
||||
glm::vec3 absPosition = RenderQueueFactory::AbsolutePosition(entity.World, entity.ID);
|
||||
glm::vec3 absScale = RenderQueueFactory::AbsoluteScale(entity.World, entity.ID);
|
||||
glm::vec3 absPosition = Transform::AbsolutePosition(entity.World, entity.ID);
|
||||
glm::vec3 absScale = Transform::AbsoluteScale(entity.World, entity.ID);
|
||||
glm::vec3 origin = absPosition + (glm::vec3)cAABB["Origin"];
|
||||
glm::vec3 size = (glm::vec3)cAABB["Size"] * absScale;
|
||||
return AABB::FromOriginSize(origin, size);
|
||||
|
||||
@@ -125,6 +125,9 @@ bool EditorSystem::OnMouseMove(const Events::MouseMove& e)
|
||||
if (m_Selection == 0) {
|
||||
return false;
|
||||
}
|
||||
if (m_Camera == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
||||
glm::vec3 widgetOrientation = widgetTransform["Orientation"];
|
||||
|
||||
@@ -109,7 +109,7 @@ void PickingPass::ClearPicking()
|
||||
{
|
||||
m_PickingColorsToEntity.clear();
|
||||
m_EntityColors.clear();
|
||||
m_ColorCounter[0] = 0;
|
||||
m_ColorCounter[0] = 1;
|
||||
m_ColorCounter[1] = 0;
|
||||
|
||||
m_PickingBuffer.Bind();
|
||||
@@ -138,10 +138,10 @@ PickData PickingPass::Pick(glm::vec2 screenCoord)
|
||||
pickInfo = it->second;
|
||||
} else {
|
||||
pickData.Entity = EntityID_Invalid;
|
||||
return pickData;
|
||||
}
|
||||
|
||||
pickData.Position = ScreenCoords::ToWorldPos(screenCoord.x, screenCoord.y, data.Depth, resolution, pickInfo.Camera->ProjectionMatrix(), pickInfo.Camera->ViewMatrix());
|
||||
|
||||
|
||||
pickData.Entity = pickInfo.Entity;
|
||||
pickData.Camera = pickInfo.Camera;
|
||||
pickData.World = pickInfo.World;
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
#include "Rendering/RenderSystem.h"
|
||||
#include "Rendering/DebugCameraInputController.h"
|
||||
|
||||
RenderSystem::RenderSystem(EventBroker* eventBrokerer, const IRenderer* renderer, RenderFrame* renderFrame) :ImpureSystem(eventBrokerer)
|
||||
RenderSystem::RenderSystem(EventBroker* eventBroker, const IRenderer* renderer, RenderFrame* renderFrame)
|
||||
: System(eventBroker)
|
||||
, m_Renderer(renderer)
|
||||
, m_RenderFrame(renderFrame)
|
||||
{
|
||||
m_Renderer = renderer;
|
||||
m_RenderFrame = renderFrame;
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
|
||||
|
||||
m_DefaultCamera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 5000.f);
|
||||
m_DefaultCamera->SetPosition(glm::vec3(0, 0, 10));
|
||||
if (m_Camera == nullptr) {
|
||||
m_Camera = m_DefaultCamera;
|
||||
m_Camera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 5000.f);
|
||||
m_DebugCameraInputController = new DebugCameraInputController<RenderSystem>(eventBroker, -1);
|
||||
}
|
||||
|
||||
RenderSystem::~RenderSystem()
|
||||
{
|
||||
delete m_Camera;
|
||||
delete m_DebugCameraInputController;
|
||||
}
|
||||
|
||||
bool RenderSystem::OnSetCamera(const Events::SetCamera &event)
|
||||
@@ -54,14 +57,11 @@ void RenderSystem::switchCamera(EntityID entity)
|
||||
void RenderSystem::updateProjectionMatrix(ComponentWrapper& cameraComponent)
|
||||
{
|
||||
double fov = cameraComponent["FOV"];
|
||||
double aspectRatio = m_Renderer->Resolution().Width / m_Renderer->Resolution().Height;
|
||||
double aspectRatio = (float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height;
|
||||
double nearClip = cameraComponent["NearClip"];
|
||||
double farClip = cameraComponent["FarClip"];
|
||||
|
||||
double fovY = atan(tan(glm::radians(fov)/2.0) * aspectRatio) * 2.0;
|
||||
m_ProjectionMatrix = glm::perspective(fovY, aspectRatio, nearClip, farClip);
|
||||
|
||||
m_Camera->SetFOV(fovY);
|
||||
m_Camera->SetFOV(glm::radians(fov));
|
||||
m_Camera->SetAspectRatio(aspectRatio);
|
||||
m_Camera->SetNearClip(nearClip);
|
||||
m_Camera->SetFarClip(farClip);
|
||||
@@ -129,9 +129,6 @@ void RenderSystem::Update(World* world, double dt)
|
||||
|
||||
void RenderSystem::updateCamera(World* world, double dt)
|
||||
{
|
||||
|
||||
static DebugCameraInputController<RenderSystem> firstPersonInputController(m_EventBroker, -1);
|
||||
|
||||
if (m_SwitchCamera) {
|
||||
auto cameras = world->GetComponents("Camera");
|
||||
for (auto it = cameras->begin(); it != cameras->end(); it++) {
|
||||
@@ -148,9 +145,8 @@ void RenderSystem::updateCamera(World* world, double dt)
|
||||
ComponentWrapper& cameraComponent = world->GetComponent(m_CurrentCamera, "Camera");
|
||||
ComponentWrapper& cameraTransform = world->GetComponent(m_CurrentCamera, "Transform");
|
||||
|
||||
firstPersonInputController.SetOrientation(glm::quat((glm::vec3)cameraTransform["Orientation"]));
|
||||
firstPersonInputController.SetPosition(cameraTransform["Position"]);
|
||||
|
||||
m_DebugCameraInputController->SetOrientation(glm::quat((glm::vec3)cameraTransform["Orientation"]));
|
||||
m_DebugCameraInputController->SetPosition(cameraTransform["Position"]);
|
||||
}
|
||||
|
||||
if (m_World->ValidEntity(m_CurrentCamera)) {
|
||||
@@ -158,9 +154,9 @@ void RenderSystem::updateCamera(World* world, double dt)
|
||||
ComponentWrapper& cameraComponent = world->GetComponent(m_CurrentCamera, "Camera");
|
||||
ComponentWrapper& cameraTransform = world->GetComponent(m_CurrentCamera, "Transform");
|
||||
|
||||
firstPersonInputController.Update(dt);
|
||||
(glm::vec3&)cameraTransform["Orientation"] = glm::eulerAngles(firstPersonInputController.Orientation());
|
||||
(glm::vec3&)cameraTransform["Position"] = firstPersonInputController.Position();
|
||||
m_DebugCameraInputController->Update(dt);
|
||||
(glm::vec3&)cameraTransform["Orientation"] = glm::eulerAngles(m_DebugCameraInputController->Orientation());
|
||||
(glm::vec3&)cameraTransform["Position"] = m_DebugCameraInputController->Position();
|
||||
|
||||
glm::vec3 position = Transform::AbsolutePosition(world, m_CurrentCamera);
|
||||
glm::quat orientation = Transform::AbsoluteOrientation(world, m_CurrentCamera);
|
||||
@@ -172,7 +168,7 @@ void RenderSystem::updateCamera(World* world, double dt)
|
||||
|
||||
}
|
||||
} else {
|
||||
m_Camera = m_DefaultCamera;
|
||||
m_Camera = m_Camera;
|
||||
|
||||
auto cameras = world->GetComponents("Camera");
|
||||
if (cameras != nullptr) {
|
||||
@@ -183,8 +179,8 @@ void RenderSystem::updateCamera(World* world, double dt)
|
||||
ComponentWrapper& cameraComponent = world->GetComponent(m_CurrentCamera, "Camera");
|
||||
ComponentWrapper& cameraTransform = world->GetComponent(m_CurrentCamera, "Transform");
|
||||
|
||||
firstPersonInputController.SetOrientation(glm::quat((glm::vec3)cameraTransform["Orientation"]));
|
||||
firstPersonInputController.SetPosition(cameraTransform["Position"]);
|
||||
m_DebugCameraInputController->SetOrientation(glm::quat((glm::vec3)cameraTransform["Orientation"]));
|
||||
m_DebugCameraInputController->SetPosition(cameraTransform["Position"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -35,6 +35,7 @@ Game::Game(int argc, char* argv[])
|
||||
));
|
||||
m_Renderer->Initialize();
|
||||
//m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
|
||||
m_RenderFrame = new RenderFrame();
|
||||
|
||||
// Create input manager
|
||||
m_InputManager = new InputManager(m_Renderer->Window(), m_EventBroker);
|
||||
@@ -59,8 +60,6 @@ Game::Game(int argc, char* argv[])
|
||||
fp.MergeEntities(m_World);
|
||||
}
|
||||
|
||||
m_RenderFrame = new RenderFrame();
|
||||
|
||||
// Create Octrees
|
||||
m_OctreeCollision = new Octree(AABB(glm::vec3(-100), glm::vec3(100)), 4);
|
||||
m_OctreeFrustrumCulling = new Octree(AABB(glm::vec3(-100), glm::vec3(100)), 4);
|
||||
@@ -82,7 +81,6 @@ Game::Game(int argc, char* argv[])
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision);
|
||||
m_SystemPipeline->AddSystem<TriggerSystem>(updateOrderLevel, m_OctreeCollision);
|
||||
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user