Radium Engine  1.5.20
Loading...
Searching...
No Matches
GeometrySystem.cpp
1#include <Engine/Scene/GeometrySystem.hpp>
2
3#include <Core/Asset/FileData.hpp>
4#include <Core/Asset/GeometryData.hpp>
5#include <Core/Tasks/Task.hpp>
6#include <Core/Tasks/TaskQueue.hpp>
7
8#include <Engine/RadiumEngine.hpp>
9#include <Engine/Scene/ComponentMessenger.hpp>
10#include <Engine/Scene/Entity.hpp>
11#include <Engine/Scene/GeometryComponent.hpp>
12
13namespace Ra {
14namespace Engine {
15namespace Scene {
16
17GeometrySystem::GeometrySystem() : System() {}
18
19void GeometrySystem::handleAssetLoading( Entity* entity,
20 const Ra::Core::Asset::FileData* fileData ) {
21 auto geomData = fileData->getGeometryData();
22
23 uint id = 0;
24
25 for ( const auto& data : geomData ) {
26 Component* comp { nullptr };
27 std::string componentName = "GEOM_" + entity->getName() + std::to_string( id++ );
28 switch ( data->getType() ) {
29 case Ra::Core::Asset::GeometryData::POINT_CLOUD:
30 comp = new PointCloudComponent( componentName, entity, data );
31 break;
32 case Ra::Core::Asset::GeometryData::LINE_MESH:
33 // comp = new LineMeshComponent( componentName, entity, data );
34 // break;
35 case Ra::Core::Asset::GeometryData::TRI_MESH:
36 comp = new TriangleMeshComponent( componentName, entity, data );
37 break;
38 case Ra::Core::Asset::GeometryData::QUAD_MESH:
39 comp = new QuadMeshComponent( componentName, entity, data );
40 break;
41 case Ra::Core::Asset::GeometryData::POLY_MESH:
42 comp = new PolyMeshComponent( componentName, entity, data );
43 break;
44 case Ra::Core::Asset::GeometryData::TETRA_MESH:
45 case Ra::Core::Asset::GeometryData::HEX_MESH:
46 case Ra::Core::Asset::GeometryData::UNKNOWN:
47 default:
48 CORE_ASSERT( false, "unsupported geometry" );
49 }
50 registerComponent( entity, comp );
51 }
52
53 auto volumeData = fileData->getVolumeData();
54
55 id = 0;
56
57 for ( const auto& data : volumeData ) {
58 std::string componentName = "VOL_" + entity->getName() + std::to_string( id++ );
59 auto comp = new VolumeComponent( componentName, entity, data );
60 registerComponent( entity, comp );
61 }
62}
63
64void GeometrySystem::generateTasks( Ra::Core::TaskQueue* /*taskQueue*/,
65 const Ra::Engine::FrameInfo& /*frameInfo*/ ) {
66 // Do nothing, as this system only displays meshes.
67}
68
69} // namespace Scene
70} // namespace Engine
71} // namespace Ra
This class allows tasks to be registered and then executed in parallel on separate threads.
Definition TaskQueue.hpp:48
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3
Structure passed to each system before they fill the task queue.
Definition FrameInfo.hpp:8
T to_string(T... args)