Skip to content
Snippets Groups Projects
Commit e24dc64f authored by jwendt's avatar jwendt
Browse files

some bugfixes

parent 0bb38df0
No related branches found
No related tags found
1 merge request!160Feature/#415 resource pointer component
//------------------------------------------------------------------------------
// Project Phoenix
//
// Copyright (c) 2017-2018 RWTH Aachen University, Germany,
// Virtual Reality & Immersive Visualization Group.
//------------------------------------------------------------------------------
// License
//
// Licensed under the 3-Clause BSD License (the "License");
// you may not use this file except in compliance with the License.
// See the file LICENSE for the full text.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//------------------------------------------------------------------------------
#include "phx/rendering/components/resource_component.hpp"
#include <string>
namespace phx {
} // namespace phx
......@@ -29,7 +29,6 @@
#include <utility>
#include <vector>
#include "phx/resources/types/material.hpp"
#include "phx/suppress_warnings.hpp"
SUPPRESS_WARNINGS_BEGIN
......@@ -45,6 +44,7 @@ SUPPRESS_WARNINGS_END
#include "phx/rendering/components/projection.hpp"
#include "phx/rendering/components/transform.hpp"
#include "phx/rendering/render_passes/render_pass.hpp"
#include "phx/resources/types/material.hpp"
#include "phx/resources/types/mesh.hpp"
namespace phx {
......
......@@ -82,31 +82,20 @@ void RenderingSystem::Update(const FrameTimer::TimeInfo&) {
for (auto& entity : GetEngine()->GetEntities()) {
auto light = entity->GetFirstComponent<Light>();
auto transform = entity->GetFirstComponent<Transform>();
<<<<<<< HEAD
const auto material =
entity->GetFirstComponent<ResourceComponent<Material>>();
const auto mesh = entity->GetFirstComponent<ResourceComponent<Mesh>>();
const auto mesh_render_settings =
entity->GetFirstComponent<MeshRenderSettings>();
if (transform != nullptr) {
if (mesh != nullptr) {
rendering_instances.push_back(
{mesh->GetResourcePointer().Get(),
(material != nullptr ? material->GetResourcePointer().Get()
: nullptr),
transform});
== == == = auto material_handle =
entity->GetFirstComponent<MaterialHandle>();
Material* material = nullptr;
if (material_handle != nullptr)
material = material_handle->GetMaterial().Get();
auto mesh_render_settings =
entity->GetFirstComponent<MeshRenderSettings>();
transform, mesh_render_settings});
if (transform != nullptr) {
if (mesh_handle != nullptr) {
rendering_instances.push_back({mesh_handle->GetMesh().Get(),
material, transform,
mesh_render_settings});
>>>>>>> master
} else if (light != nullptr) {
light_transform_pairs.push_back(
std::pair<Light*, Transform*>(light, transform));
......@@ -134,8 +123,7 @@ void RenderingSystem::Update(const FrameTimer::TimeInfo&) {
return frame_graph_.get();
}
void RenderingSystem::SetFrameGraph(
std::unique_ptr<FrameGraph> frame_graph) {
void RenderingSystem::SetFrameGraph(std::unique_ptr<FrameGraph> frame_graph) {
frame_graph_ = std::move(frame_graph);
}
......
......@@ -90,7 +90,7 @@ SCENARIO(
}
}
}
SCENARIO("ResourcePointers can be used as components directly") {
SCENARIO("ResourcePointers can be used in a ResourceComponent") {
GIVEN("A resource pointer to an arbitrarily chosen model resource.") {
phx::ResourcePointer<phx::Model> resource_pointer =
phx::ResourceManager::instance().DeclareResource<phx::Model>(
......@@ -98,12 +98,12 @@ SCENARIO("ResourcePointers can be used as components directly") {
resource_pointer.Load();
auto mesh_resource_pointer = resource_pointer->GetMeshes()[0];
phx::Entity entity;
WHEN("We add the mesh_resource_pointer as resource component") {
WHEN("We add the mesh_resource_pointer as ResourceComponent") {
entity.AddComponent<phx::ResourceComponent<phx::Mesh>>(
mesh_resource_pointer);
THEN(
"the resouce pointer itself is the resource and can be obtained as "
"usual") {
"the resouce pointer is in the ResourceComponent and can be obtained "
"using GetResourcePointer()") {
auto resource_component =
entity.GetFirstComponent<phx::ResourceComponent<phx::Mesh>>();
REQUIRE(resource_component->GetResourcePointer().Get() ==
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment