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