All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PropRenderableService.h
1 #pragma once
2 
3 #include "Interiors.h"
4 #include "PropResource.h"
5 #include "IProp.h"
6 #include "Rendering.h"
7 #include "InteriorIdFloorIdPair.h"
8 #include "PropModelRepository.h"
9 #include "InteriorsInstanceRepository.h"
10 #include <unordered_map>
11 
12 namespace Eegeo
13 {
14  namespace Resources
15  {
16  namespace Interiors
17  {
18  typedef std::vector<IProp::IdType> PropConsumerSet;
19 
21  {
22  std::string m_propUrl;
23  std::unordered_map<InteriorIdFloorIdPair, PropConsumerSet, InteriorIdFloorIdPairHash> m_floorsToConsumers;
24  };
25 
27  {
28  public:
30  PropModelRepository& propModelRepository,
31  PropRenderableRepository& propRenderableRepository,
32  InteriorsInstanceRepository& interiorsInstanceRepository,
33  PropStreamingService& propStreamingService,
34  PropRenderableFactory& propRenderableFactory,
35  PropResourceRepository& propResourceRepository);
36 
38 
39  void AssignGeometryForProp(const IProp& prop);
40  void AssignGeometryForProps(const std::vector<const IProp*>& props);
41 
42  void RemoveGeometryForProp(const IProp& prop);
43  void RemoveGeometryForProps(const std::vector<const IProp*>& props);
44 
45  PropGeometry& GetGeometryForProp(const IProp::IdType propId);
46 
47  private:
48 
49  PropModelRepository& m_propModelRepository;
50  PropResourceRepository& m_propResourceRepository;
51  InteriorsInstanceRepository& m_interiorsInstanceRepository;
52  PropStreamingService& m_propStreamingService;
53  PropRenderableFactory& m_propRenderableFactory;
54  PropRenderableRepository& m_propRenderableRepository;
55 
56  std::unordered_map<std::string, InFlightPropRequest> m_inflightPropRequests;
57  std::unordered_map<IProp::IdType, PropGeometry> m_propsToGeometry;
58 
60 
61  typedef std::unordered_map<Rendering::Renderables::InstancedInteriorFloorRenderable*, std::vector<int>> RenderableToTransformIndexRemappingTable;
62  typedef std::unordered_map<Rendering::Renderables::InstancedInteriorFloorRenderable*, std::vector<InteriorsInstanceRepository::InstanceData>> RenderableToRemappedInstanceDataTable;
63 
64  void HandleInFlightPropLoadCompletion(const InFlightPropRequest& request, Builder::PropResource& propResource);
65 
66  void HandleLoadPropResource(const std::string& propResourceUrl);
67 
68  PropConsumerSet& GetOrAddPropConsumerSet(InFlightPropRequest &inFlightRequest, const InteriorId& interiorId, int floorId);
69 
70  InFlightPropRequest& GetOrAddPropResourceRequest(const std::string& relativeUrl);
71 
72  Collision::CollisionBvh* CloneBvh(const Collision::CollisionBvh& input, const Eegeo::dv3& newOrigin);
73 
74  bool TryGetExistingGeometryForRenderable(const InteriorId& interiorId, int floorId, const std::string& geometryId, PropGeometry& outGeometry);
75 
76  void LoadGeometryForProp(const std::string& propGeometryId, const IProp& prop);
77 
78  InteriorsInstanceRepository::InstanceData AddGeometryForPropFromResource(Builder::PropResource &resource, const IProp& prop, const dv3& origin);
79 
80  InteriorsInstanceRepository::InstanceData AddGeometryForPropByMergingWithExisting(PropGeometry &existingGeometry, const std::string& propGeometryId, IProp::IdType propId);
81 
82  bool TryAssignGeometryFromLoadedResources(const std::string& propGeometryId, const IProp& prop, InteriorsInstanceRepository::InstanceData& out_instanceData);
83 
84  RenderableToTransformIndexRemappingTable CalculateIndexRemappingForRenderablesAfterRemovals(const std::vector<const IProp*>& propsToRemove);
85 
86  RenderableToTransformIndexRemappingTable CalculateReferencedPropIndicesAfterRemovals(const std::vector<const IProp*>& propsToRemove);
87 
88  void DeleteUnreferencedRenderablesAndUpdateInstanceRepository(const RenderableToTransformIndexRemappingTable& renderableTransformIndexRemappings, const RenderableToRemappedInstanceDataTable& modifiedInstanceData);
89 
90  RenderableToRemappedInstanceDataTable UpdateGeometryRecordsForRemapping(const RenderableToTransformIndexRemappingTable& renderableTransformIndexRemappings);
91 
92  void RemoveGeometryRecordsForDeletedProps(const std::vector<const IProp*>& props);
93  };
94  }
95  }
96 }