| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "imodule.h" |
| 4 |
#include "imodel.h" |
| 5 |
#include "inode.h" |
| 6 |
#include <sigc++/signal.h> |
| 7 |
|
| 8 |
namespace model |
| 9 |
{ |
| 10 |
|
| 11 |
/** Modelcache interface. |
| 12 |
*/ |
| 13 |
class IModelCache : |
| 14 |
public RegisterableModule |
| 15 |
{ |
| 16 |
public: |
| 17 |
/** |
| 18 |
* greebo: This method returns the readily fabricated scene::Node |
| 19 |
* containing the suitable model node. The modelPath is analysed |
| 20 |
* and the correct ModelLoader is invoked to create the node. |
| 21 |
* |
| 22 |
* @returns: a valid scene::INodePtr, which is never empty. If the model |
| 23 |
* could not be loaded, the fallback "NullModel" is returned. |
| 24 |
* |
| 25 |
* Note that the model path should refer to an actual object in the VFS, |
| 26 |
* modelPaths referring to modelDef declarations need to be resolved |
| 27 |
* by the caller. |
| 28 |
*/ |
| 29 |
virtual scene::INodePtr getModelNode(const std::string& modelPath) = 0; |
| 30 |
|
| 31 |
/** |
| 32 |
* greebo: Get the IModel object for the given VFS path. The request is cached, |
| 33 |
* so calling this with the same path twice will return the same |
| 34 |
* IModelPtr to save memory. |
| 35 |
* |
| 36 |
* This method is primarily used by the ModelLoaders to acquire their model data. |
| 37 |
*/ |
| 38 |
virtual IModelPtr getModel(const std::string& modelPath) = 0; |
| 39 |
|
| 40 |
// Loads a model from the static resources in DarkRadiant's runtime data/resources folder |
| 41 |
virtual scene::INodePtr getModelNodeForStaticResource(const std::string& resourcePath) = 0; |
| 42 |
|
| 43 |
// This reloads all models in the map |
| 44 |
virtual void refreshModels(bool blockScreenUpdates = true) = 0; |
| 45 |
|
| 46 |
// This reloads all selected models in the map |
| 47 |
virtual void refreshSelectedModels(bool blockScreenUpdates = true) = 0; |
| 48 |
|
| 49 |
// Clears a specific model from the cache |
| 50 |
virtual void removeModel(const std::string& modelPath) = 0; |
| 51 |
|
| 52 |
// Clears the modelcache |
| 53 |
virtual void clear() = 0; |
| 54 |
|
| 55 |
/// Signal emitted after models are reloaded |
| 56 |
virtual sigc::signal<void> signal_modelsReloaded() = 0; |
| 57 |
}; |
| 58 |
|
| 59 |
} // namespace model |
| 60 |
|
| 61 |
constexpr const char* const MODULE_MODELCACHE("ModelCache"); |
| 62 |
|
| 63 |
inline model::IModelCache& GlobalModelCache() |
| 64 |
{ |
| 65 |
static module::InstanceReference<model::IModelCache> _reference(MODULE_MODELCACHE); |
| 66 |
return _reference; |
| 67 |
} |