mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 04:30:09 -05:00
Update Ghoul repository to have the factory return unique_ptrs
Adjust accordingly
This commit is contained in:
@@ -68,7 +68,9 @@ documentation:: Documentation ModelGeometry::Documentation() {
|
||||
}
|
||||
|
||||
|
||||
ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) {
|
||||
std::unique_ptr<ModelGeometry> ModelGeometry::createFromDictionary(
|
||||
const ghoul::Dictionary& dictionary)
|
||||
{
|
||||
if (!dictionary.hasKeyAndValue<std::string>(keyType)) {
|
||||
throw ghoul::RuntimeError("Dictionary did not contain a key 'Type'");
|
||||
}
|
||||
@@ -76,7 +78,7 @@ ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dict
|
||||
std::string geometryType = dictionary.value<std::string>(keyType);
|
||||
auto factory = FactoryManager::ref().factory<ModelGeometry>();
|
||||
|
||||
ModelGeometry* result = factory->create(geometryType, dictionary);
|
||||
std::unique_ptr<ModelGeometry> result = factory->create(geometryType, dictionary);
|
||||
if (result == nullptr) {
|
||||
throw ghoul::RuntimeError(
|
||||
"Failed to create a ModelGeometry object of type '" + geometryType + "'"
|
||||
|
||||
@@ -38,7 +38,9 @@ namespace modelgeometry {
|
||||
|
||||
class ModelGeometry : public properties::PropertyOwner {
|
||||
public:
|
||||
static ModelGeometry* createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
static std::unique_ptr<ModelGeometry> createFromDictionary(
|
||||
const ghoul::Dictionary& dictionary
|
||||
);
|
||||
|
||||
struct Vertex {
|
||||
GLfloat location[4];
|
||||
|
||||
@@ -85,7 +85,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
if (success)
|
||||
_colorTexturePath = absPath(texturePath);
|
||||
|
||||
addPropertySubOwner(_geometry);
|
||||
addPropertySubOwner(_geometry.get());
|
||||
|
||||
addProperty(_colorTexturePath);
|
||||
_colorTexturePath.onChange(std::bind(&RenderableModel::loadTexture, this));
|
||||
@@ -153,7 +153,6 @@ bool RenderableModel::initialize() {
|
||||
bool RenderableModel::deinitialize() {
|
||||
if (_geometry) {
|
||||
_geometry->deinitialize();
|
||||
delete _geometry;
|
||||
_geometry = nullptr;
|
||||
}
|
||||
_texture = nullptr;
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace modelgeometry {
|
||||
@@ -65,7 +67,7 @@ private:
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
|
||||
modelgeometry::ModelGeometry* _geometry;
|
||||
std::unique_ptr<modelgeometry::ModelGeometry> _geometry;
|
||||
|
||||
glm::dmat3 _modelTransform;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user