Convert raw pointers to std::unique_ptr in ModelGeometry
parent
37cab4140b
commit
4d5f2d9c64
|
@ -36,6 +36,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <fmt/printf.h>
|
#include <fmt/printf.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
using namespace cmod;
|
using namespace cmod;
|
||||||
|
@ -196,7 +197,7 @@ Geometry* GeometryInfo::load(const string& resolvedFilename)
|
||||||
originalMaterialCount,
|
originalMaterialCount,
|
||||||
model->getMaterialCount());
|
model->getMaterialCount());
|
||||||
|
|
||||||
return new ModelGeometry(model);
|
return new ModelGeometry(unique_ptr<cmod::Model>(model));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,17 +51,10 @@ public:
|
||||||
/** Create a new ModelGeometry wrapping the specified model.
|
/** Create a new ModelGeometry wrapping the specified model.
|
||||||
* The ModelGeoemtry takes ownership of the model.
|
* The ModelGeoemtry takes ownership of the model.
|
||||||
*/
|
*/
|
||||||
ModelGeometry::ModelGeometry(Model* model) :
|
ModelGeometry::ModelGeometry(unique_ptr<cmod::Model>&& model) :
|
||||||
m_model(model)
|
m_model(move(model)),
|
||||||
|
m_glData(unique_ptr<ModelOpenGLData>(new ModelOpenGLData()))
|
||||||
{
|
{
|
||||||
m_glData = new ModelOpenGLData();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ModelGeometry::~ModelGeometry()
|
|
||||||
{
|
|
||||||
delete m_model;
|
|
||||||
delete m_glData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "geometry.h"
|
#include "geometry.h"
|
||||||
#include <celmodel/model.h>
|
#include <celmodel/model.h>
|
||||||
#include <celutil/resmanager.h>
|
#include <celutil/resmanager.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
class CelestiaTextureResource : public cmod::Material::TextureResource
|
class CelestiaTextureResource : public cmod::Material::TextureResource
|
||||||
|
@ -40,8 +41,8 @@ class ModelOpenGLData;
|
||||||
class ModelGeometry : public Geometry
|
class ModelGeometry : public Geometry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ModelGeometry(cmod::Model* model);
|
ModelGeometry(std::unique_ptr<cmod::Model>&& model);
|
||||||
~ModelGeometry();
|
~ModelGeometry() = default;
|
||||||
|
|
||||||
/*! Find the closest intersection between the ray and the
|
/*! Find the closest intersection between the ray and the
|
||||||
* model. If the ray intersects the model, return true
|
* model. If the ray intersects the model, return true
|
||||||
|
@ -60,9 +61,9 @@ class ModelGeometry : public Geometry
|
||||||
void loadTextures();
|
void loadTextures();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cmod::Model* m_model;
|
std::unique_ptr<cmod::Model> m_model;
|
||||||
bool m_vbInitialized{ false };
|
bool m_vbInitialized{ false };
|
||||||
ModelOpenGLData* m_glData{ nullptr };
|
std::unique_ptr<ModelOpenGLData> m_glData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !_CELENGINE_MODEL_H_
|
#endif // !_CELENGINE_MODEL_H_
|
||||||
|
|
Loading…
Reference in New Issue