mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01:00
rwlib: Use ClumpPtr instead of Clump*
Should fix these memory leaks: ==22737== 14,598,040 (131,472 direct, 14,466,568 indirect) bytes in 2,739 blocks are definitely lost in loss record 3,124 of 3,126 ==22737== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334) ==22737== by 0x90FE4B: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:443) ==22737== by 0x7BCC86: GameData::loadModel(unsigned short) (GameData.cpp:474) ==22737== by 0x7DF7BC: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144) ==22737== by 0x7DF44C: GameWorld::placeItems(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:120) ==22737== by 0x758D38: RWGame::newGame() (RWGame.cpp:116) ==22737== by 0x786389: LoadingState::enter() (LoadingState.cpp:9) ==22737== by 0x75DC59: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:40) ==22737== by 0x758484: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81) ==22737== by 0x747815: main (main.cpp:13)
This commit is contained in:
parent
bc8652baba
commit
7e4e1db85d
@ -135,14 +135,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @todo change with librw
|
/// @todo change with librw
|
||||||
void setAtomic(Clump* model, int n, AtomicPtr atomic) {
|
void setAtomic(ClumpPtr model, int n, AtomicPtr atomic) {
|
||||||
model_ = model;
|
model_ = model;
|
||||||
/// @todo disassociated the Atomic from Clump
|
/// @todo disassociated the Atomic from Clump
|
||||||
atomics_[n] = atomic;
|
atomics_[n] = atomic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @todo remove this
|
/// @todo remove this
|
||||||
Clump* getModel() const {
|
ClumpPtr getModel() const {
|
||||||
return model_;
|
return model_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,11 +178,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isLoaded() const override {
|
bool isLoaded() const override {
|
||||||
return model_ != nullptr;
|
return model_.get() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unload() override {
|
void unload() override {
|
||||||
delete model_;
|
|
||||||
model_ = nullptr;
|
model_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +248,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Clump* model_ = nullptr;
|
ClumpPtr model_;
|
||||||
std::array<AtomicPtr, 3> atomics_;
|
std::array<AtomicPtr, 3> atomics_;
|
||||||
float loddistances_[3] = {};
|
float loddistances_[3] = {};
|
||||||
uint8_t numatomics_ = 0;
|
uint8_t numatomics_ = 0;
|
||||||
@ -280,25 +279,24 @@ public:
|
|||||||
ClumpModelInfo(ModelDataType type) : BaseModelInfo(type) {
|
ClumpModelInfo(ModelDataType type) : BaseModelInfo(type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setModel(Clump* model) {
|
void setModel(ClumpPtr model) {
|
||||||
model_ = model;
|
model_ = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
Clump* getModel() const {
|
ClumpPtr getModel() const {
|
||||||
return model_;
|
return model_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isLoaded() const override {
|
bool isLoaded() const override {
|
||||||
return model_ != nullptr;
|
return model_.get() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unload() override {
|
void unload() override {
|
||||||
delete model_;
|
|
||||||
model_ = nullptr;
|
model_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Clump* model_ = nullptr;
|
ClumpPtr model_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <loaders/LoaderDFF.hpp>
|
#include <loaders/LoaderDFF.hpp>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
Animator::Animator(Clump* model) : model(model) {
|
Animator::Animator(ClumpPtr model) : model(model) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animator::tick(float dt) {
|
void Animator::tick(float dt) {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <rw/defines.hpp>
|
#include <rw/defines.hpp>
|
||||||
|
|
||||||
class Clump;
|
#include <rw/forward.hpp>
|
||||||
class ModelFrame;
|
class ModelFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +40,7 @@ class Animator {
|
|||||||
/**
|
/**
|
||||||
* @brief model The model being animated.
|
* @brief model The model being animated.
|
||||||
*/
|
*/
|
||||||
Clump* model;
|
ClumpPtr model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Currently playing animations
|
* @brief Currently playing animations
|
||||||
@ -48,7 +48,7 @@ class Animator {
|
|||||||
std::vector<AnimationState> animations;
|
std::vector<AnimationState> animations;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Animator(Clump* model);
|
Animator(ClumpPtr model);
|
||||||
|
|
||||||
Animation* getAnimation(unsigned int slot) {
|
Animation* getAnimation(unsigned int slot) {
|
||||||
if (slot < animations.size()) {
|
if (slot < animations.size()) {
|
||||||
|
@ -385,7 +385,7 @@ void GameData::getNameAndLod(std::string& name, int& lod) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Clump* GameData::loadClump(const std::string& name) {
|
ClumpPtr GameData::loadClump(const std::string& name) {
|
||||||
auto file = index.openFile(name);
|
auto file = index.openFile(name);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
logger->error("Data", "Failed to load model " + name);
|
logger->error("Data", "Failed to load model " + name);
|
||||||
|
@ -133,7 +133,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Loads an archived model and returns it directly
|
* Loads an archived model and returns it directly
|
||||||
*/
|
*/
|
||||||
Clump* loadClump(const std::string& name);
|
ClumpPtr loadClump(const std::string& name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a DFF and associates its atomics with models.
|
* Loads a DFF and associates its atomics with models.
|
||||||
|
@ -37,7 +37,7 @@ CharacterObject::CharacterObject(GameWorld* engine, const glm::vec3& pos,
|
|||||||
setClump(ClumpPtr(info->getModel()->clone()));
|
setClump(ClumpPtr(info->getModel()->clone()));
|
||||||
if (info->getModel()) {
|
if (info->getModel()) {
|
||||||
setModel(info->getModel());
|
setModel(info->getModel());
|
||||||
animator = new Animator(getClump().get());
|
animator = new Animator(getClump());
|
||||||
|
|
||||||
createActor();
|
createActor();
|
||||||
}
|
}
|
||||||
@ -279,7 +279,7 @@ void CharacterObject::changeCharacterModel(const std::string& name) {
|
|||||||
|
|
||||||
setModel(newmodel);
|
setModel(newmodel);
|
||||||
|
|
||||||
animator = new Animator(getClump().get());
|
animator = new Animator(getClump());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterObject::updateCharacter(float dt) {
|
void CharacterObject::updateCharacter(float dt) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <engine/Animator.hpp>
|
|
||||||
#include <objects/CutsceneObject.hpp>
|
#include <objects/CutsceneObject.hpp>
|
||||||
|
#include <engine/Animator.hpp>
|
||||||
|
|
||||||
CutsceneObject::CutsceneObject(GameWorld *engine, const glm::vec3 &pos,
|
CutsceneObject::CutsceneObject(GameWorld *engine, const glm::vec3 &pos,
|
||||||
const glm::quat &rot, Clump *model,
|
const glm::quat &rot, ClumpPtr model,
|
||||||
BaseModelInfo *modelinfo)
|
BaseModelInfo *modelinfo)
|
||||||
: GameObject(engine, pos, rot, modelinfo)
|
: GameObject(engine, pos, rot, modelinfo)
|
||||||
, _parent(nullptr)
|
, _parent(nullptr)
|
||||||
@ -14,7 +14,7 @@ CutsceneObject::CutsceneObject(GameWorld *engine, const glm::vec3 &pos,
|
|||||||
setModel(getModelInfo<ClumpModelInfo>()->getModel());
|
setModel(getModelInfo<ClumpModelInfo>()->getModel());
|
||||||
}
|
}
|
||||||
setClump(ClumpPtr(getModel()->clone()));
|
setClump(ClumpPtr(getModel()->clone()));
|
||||||
animator = new Animator(getClump().get());
|
animator = new Animator(getClump());
|
||||||
}
|
}
|
||||||
|
|
||||||
CutsceneObject::~CutsceneObject() {
|
CutsceneObject::~CutsceneObject() {
|
||||||
|
@ -12,7 +12,7 @@ class CutsceneObject : public GameObject, public ClumpObject {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CutsceneObject(GameWorld* engine, const glm::vec3& pos,
|
CutsceneObject(GameWorld* engine, const glm::vec3& pos,
|
||||||
const glm::quat& rot, Clump* model,
|
const glm::quat& rot, ClumpPtr model,
|
||||||
BaseModelInfo* modelinfo);
|
BaseModelInfo* modelinfo);
|
||||||
~CutsceneObject();
|
~CutsceneObject();
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class GameObject {
|
|||||||
/**
|
/**
|
||||||
* Model used for rendering
|
* Model used for rendering
|
||||||
*/
|
*/
|
||||||
Clump* model_;
|
ClumpPtr model_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeModelInfo(BaseModelInfo* next) {
|
void changeModelInfo(BaseModelInfo* next) {
|
||||||
@ -102,14 +102,14 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @return The model used in rendering
|
* @return The model used in rendering
|
||||||
*/
|
*/
|
||||||
Clump* getModel() const {
|
ClumpPtr getModel() const {
|
||||||
return model_;
|
return model_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the current model, used for re-dressing chars
|
* Changes the current model, used for re-dressing chars
|
||||||
*/
|
*/
|
||||||
void setModel(Clump* model) {
|
void setModel(ClumpPtr model) {
|
||||||
model_ = model;
|
model_ = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera,
|
|||||||
m, glm::vec3(i.radius +
|
m, glm::vec3(i.radius +
|
||||||
0.15f * glm::sin(_renderWorld->getGameTime() * 5.f)));
|
0.15f * glm::sin(_renderWorld->getGameTime() * 5.f)));
|
||||||
|
|
||||||
objectRenderer.renderClump(sphereModel, m, nullptr, renderList);
|
objectRenderer.renderClump(sphereModel.get(), m, nullptr, renderList);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render arrows above anything that isn't radar only (or hidden)
|
// Render arrows above anything that isn't radar only (or hidden)
|
||||||
@ -344,7 +344,7 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera,
|
|||||||
glm::vec3(0.f, 0.f, 2.5f + glm::sin(a) * 0.5f));
|
glm::vec3(0.f, 0.f, 2.5f + glm::sin(a) * 0.5f));
|
||||||
model = glm::rotate(model, a, glm::vec3(0.f, 0.f, 1.f));
|
model = glm::rotate(model, a, glm::vec3(0.f, 0.f, 1.f));
|
||||||
model = glm::scale(model, glm::vec3(1.5f, 1.5f, 1.5f));
|
model = glm::scale(model, glm::vec3(1.5f, 1.5f, 1.5f));
|
||||||
objectRenderer.renderClump(arrowModel, model, nullptr, renderList);
|
objectRenderer.renderClump(arrowModel.get(), model, nullptr, renderList);
|
||||||
}
|
}
|
||||||
|
|
||||||
RW_PROFILE_END();
|
RW_PROFILE_END();
|
||||||
|
@ -62,7 +62,7 @@ class GameRenderer {
|
|||||||
ViewCamera _camera;
|
ViewCamera _camera;
|
||||||
ViewCamera cullingCamera;
|
ViewCamera cullingCamera;
|
||||||
bool cullOverride;
|
bool cullOverride;
|
||||||
|
|
||||||
/** Number of culling events */
|
/** Number of culling events */
|
||||||
size_t culled;
|
size_t culled;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
GLuint getMissingTexture() const {
|
GLuint getMissingTexture() const {
|
||||||
return m_missingTexture;
|
return m_missingTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getCulledCount() {
|
size_t getCulledCount() {
|
||||||
return culled;
|
return culled;
|
||||||
}
|
}
|
||||||
@ -174,16 +174,15 @@ public:
|
|||||||
*
|
*
|
||||||
* GameRenderer will take ownership of the Model* pointer
|
* GameRenderer will take ownership of the Model* pointer
|
||||||
*/
|
*/
|
||||||
void setSpecialModel(SpecialModel usage, Clump* model) {
|
void setSpecialModel(SpecialModel usage, ClumpPtr model) {
|
||||||
specialmodels_[usage].reset(model);
|
specialmodels_[usage] = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Hard-coded models to use for each of the special models
|
/// Hard-coded models to use for each of the special models
|
||||||
std::unique_ptr<Clump>
|
ClumpPtr specialmodels_[SpecialModel::SpecialModelCount];
|
||||||
specialmodels_[SpecialModel::SpecialModelCount];
|
ClumpPtr getSpecialModel(SpecialModel usage) const {
|
||||||
Clump* getSpecialModel(SpecialModel usage) const {
|
return specialmodels_[usage];
|
||||||
return specialmodels_[usage].get();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ SET(RWLIB_SOURCES
|
|||||||
"source/gl/TextureData.cpp"
|
"source/gl/TextureData.cpp"
|
||||||
|
|
||||||
"source/rw/abort.cpp"
|
"source/rw/abort.cpp"
|
||||||
|
"source/rw/forward.hpp"
|
||||||
"source/rw/types.hpp"
|
"source/rw/types.hpp"
|
||||||
"source/rw/defines.hpp"
|
"source/rw/defines.hpp"
|
||||||
|
|
||||||
|
@ -12,18 +12,7 @@
|
|||||||
#include <gl/TextureData.hpp>
|
#include <gl/TextureData.hpp>
|
||||||
#include <loaders/RWBinaryStream.hpp>
|
#include <loaders/RWBinaryStream.hpp>
|
||||||
|
|
||||||
// Forward Declerations
|
#include <rw/forward.hpp>
|
||||||
class ModelFrame;
|
|
||||||
struct Geometry;
|
|
||||||
class Atomic;
|
|
||||||
class Clump;
|
|
||||||
|
|
||||||
// Pointer types
|
|
||||||
using ModelFramePtr = std::shared_ptr<ModelFrame>;
|
|
||||||
using GeometryPtr = std::shared_ptr<Geometry>;
|
|
||||||
using AtomicPtr = std::shared_ptr<Atomic>;
|
|
||||||
using AtomicList = std::vector<AtomicPtr>;
|
|
||||||
using ClumpPtr = std::shared_ptr<Clump>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ModelFrame stores transformation hierarchy
|
* ModelFrame stores transformation hierarchy
|
||||||
|
@ -439,8 +439,8 @@ AtomicPtr LoaderDFF::readAtomic(FrameList &framelist,
|
|||||||
return atomic;
|
return atomic;
|
||||||
}
|
}
|
||||||
|
|
||||||
Clump *LoaderDFF::loadFromMemory(FileHandle file) {
|
ClumpPtr LoaderDFF::loadFromMemory(FileHandle file) {
|
||||||
auto model = new Clump;
|
auto model = std::make_shared<Clump>();
|
||||||
|
|
||||||
RWBStream rootStream(file->data, file->length);
|
RWBStream rootStream(file->data, file->length);
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
using GeometryList = std::vector<GeometryPtr>;
|
using GeometryList = std::vector<GeometryPtr>;
|
||||||
using FrameList = std::vector<ModelFramePtr>;
|
using FrameList = std::vector<ModelFramePtr>;
|
||||||
|
|
||||||
Clump* loadFromMemory(FileHandle file);
|
ClumpPtr loadFromMemory(FileHandle file);
|
||||||
|
|
||||||
void setTextureLookupCallback(TextureLookupCallback tlc) {
|
void setTextureLookupCallback(TextureLookupCallback tlc) {
|
||||||
texturelookup = tlc;
|
texturelookup = tlc;
|
||||||
|
22
rwlib/source/rw/forward.hpp
Normal file
22
rwlib/source/rw/forward.hpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef RWLIB_FORWARD_HPP
|
||||||
|
#define RWLIB_FORWARD_HPP
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
class Clump;
|
||||||
|
class ModelFrame;
|
||||||
|
struct Geometry;
|
||||||
|
class Atomic;
|
||||||
|
class Clump;
|
||||||
|
|
||||||
|
// Pointer types
|
||||||
|
using ModelFramePtr = std::shared_ptr<ModelFrame>;
|
||||||
|
using GeometryPtr = std::shared_ptr<Geometry>;
|
||||||
|
using AtomicPtr = std::shared_ptr<Atomic>;
|
||||||
|
using AtomicList = std::vector<AtomicPtr>;
|
||||||
|
using ClumpPtr = std::shared_ptr<Clump>;
|
||||||
|
|
||||||
|
#endif /* FORWARD_HPP */
|
||||||
|
|
@ -103,7 +103,7 @@ void ViewerWidget::paintGL() {
|
|||||||
vc.frustum.fov = viewFov;
|
vc.frustum.fov = viewFov;
|
||||||
vc.frustum.aspectRatio = width() / (height() * 1.f);
|
vc.frustum.aspectRatio = width() / (height() * 1.f);
|
||||||
|
|
||||||
Clump* model = activeModel;
|
ClumpPtr model = activeModel;
|
||||||
if (model != _lastModel) {
|
if (model != _lastModel) {
|
||||||
_lastModel = model;
|
_lastModel = model;
|
||||||
emit modelChanged(_lastModel);
|
emit modelChanged(_lastModel);
|
||||||
@ -133,7 +133,7 @@ void ViewerWidget::paintGL() {
|
|||||||
|
|
||||||
ObjectRenderer renderer(world(), vc, 1.f, 0);
|
ObjectRenderer renderer(world(), vc, 1.f, 0);
|
||||||
RenderList renders;
|
RenderList renders;
|
||||||
renderer.renderClump(model, glm::mat4(), nullptr, renders);
|
renderer.renderClump(model.get(), glm::mat4(), nullptr, renders);
|
||||||
r.getRenderer()->drawBatched(renders);
|
r.getRenderer()->drawBatched(renders);
|
||||||
|
|
||||||
drawFrameWidget(model->getFrame().get());
|
drawFrameWidget(model->getFrame().get());
|
||||||
@ -165,7 +165,7 @@ void ViewerWidget::drawFrameWidget(ModelFrame* f, const glm::mat4& m) {
|
|||||||
glLineWidth(1.f);
|
glLineWidth(1.f);
|
||||||
}
|
}
|
||||||
dp.textures = {whiteTex};
|
dp.textures = {whiteTex};
|
||||||
|
|
||||||
RW_CHECK(renderer != nullptr, "GameRenderer is null");
|
RW_CHECK(renderer != nullptr, "GameRenderer is null");
|
||||||
if(renderer != nullptr) {
|
if(renderer != nullptr) {
|
||||||
renderer->getRenderer()->drawArrays(thisM, _frameWidgetDraw, dp);
|
renderer->getRenderer()->drawArrays(thisM, _frameWidgetDraw, dp);
|
||||||
@ -207,7 +207,7 @@ void ViewerWidget::showObject(qint16 item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerWidget::showModel(Clump* model) {
|
void ViewerWidget::showModel(ClumpPtr model) {
|
||||||
if (dummyObject) gworld->destroyObject(dummyObject);
|
if (dummyObject) gworld->destroyObject(dummyObject);
|
||||||
dummyObject = nullptr;
|
dummyObject = nullptr;
|
||||||
activeModel = model;
|
activeModel = model;
|
||||||
@ -269,7 +269,7 @@ void ViewerWidget::keyReleaseEvent(QKeyEvent* e) {
|
|||||||
if (e->key() == Qt::Key_Shift) moveFast = false;
|
if (e->key() == Qt::Key_Shift) moveFast = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Clump* ViewerWidget::currentModel() const {
|
ClumpPtr ViewerWidget::currentModel() const {
|
||||||
return activeModel;
|
return activeModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,12 +27,12 @@ class ViewerWidget : public QGLWidget {
|
|||||||
QTimer timer;
|
QTimer timer;
|
||||||
GameWorld* gworld;
|
GameWorld* gworld;
|
||||||
|
|
||||||
Clump* activeModel;
|
ClumpPtr activeModel;
|
||||||
ModelFrame* selectedFrame;
|
ModelFrame* selectedFrame;
|
||||||
GameObject* dummyObject;
|
GameObject* dummyObject;
|
||||||
quint16 currentObjectID;
|
quint16 currentObjectID;
|
||||||
|
|
||||||
Clump* _lastModel;
|
ClumpPtr _lastModel;
|
||||||
Animation* canimation;
|
Animation* canimation;
|
||||||
|
|
||||||
float viewDistance;
|
float viewDistance;
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
|
|
||||||
virtual void paintGL();
|
virtual void paintGL();
|
||||||
|
|
||||||
Clump* currentModel() const;
|
ClumpPtr currentModel() const;
|
||||||
GameObject* currentObject() const;
|
GameObject* currentObject() const;
|
||||||
|
|
||||||
GameWorld* world();
|
GameWorld* world();
|
||||||
@ -68,7 +68,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void showObject(qint16 item);
|
void showObject(qint16 item);
|
||||||
void showModel(Clump* model);
|
void showModel(ClumpPtr model);
|
||||||
void selectFrame(ModelFrame* frame);
|
void selectFrame(ModelFrame* frame);
|
||||||
|
|
||||||
void exportModel();
|
void exportModel();
|
||||||
@ -81,7 +81,7 @@ signals:
|
|||||||
|
|
||||||
void fileOpened(const QString& file);
|
void fileOpened(const QString& file);
|
||||||
|
|
||||||
void modelChanged(Clump* model);
|
void modelChanged(ClumpPtr model);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent*) override;
|
void keyPressEvent(QKeyEvent*) override;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "DFFFramesTreeModel.hpp"
|
#include "DFFFramesTreeModel.hpp"
|
||||||
#include <data/Clump.hpp>
|
#include <data/Clump.hpp>
|
||||||
|
|
||||||
DFFFramesTreeModel::DFFFramesTreeModel(Clump* m,
|
DFFFramesTreeModel::DFFFramesTreeModel(ClumpPtr m,
|
||||||
QObject* parent)
|
QObject* parent)
|
||||||
: QAbstractItemModel(parent), model(m) {
|
: QAbstractItemModel(parent), model(m) {
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,14 @@
|
|||||||
#ifndef _DFFFRAMESTREEMODEL_HPP_
|
#ifndef _DFFFRAMESTREEMODEL_HPP_
|
||||||
#define _DFFFRAMESTREEMODEL_HPP_
|
#define _DFFFRAMESTREEMODEL_HPP_
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
#include <rw/forward.hpp>
|
||||||
#include <rw/types.hpp>
|
#include <rw/types.hpp>
|
||||||
|
|
||||||
class Clump;
|
|
||||||
|
|
||||||
class DFFFramesTreeModel : public QAbstractItemModel {
|
class DFFFramesTreeModel : public QAbstractItemModel {
|
||||||
Clump* model;
|
ClumpPtr model;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DFFFramesTreeModel(Clump* m, QObject* parent = 0);
|
explicit DFFFramesTreeModel(ClumpPtr m, QObject* parent = 0);
|
||||||
|
|
||||||
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ void ModelViewer::setViewerWidget(ViewerWidget* widget) {
|
|||||||
showModel(viewing);
|
showModel(viewing);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelViewer::showModel(Clump* model) {
|
void ModelViewer::showModel(ClumpPtr model) {
|
||||||
viewing = model;
|
viewing = model;
|
||||||
viewerWidget->showModel(model);
|
viewerWidget->showModel(model);
|
||||||
frames->setModel(model);
|
frames->setModel(model);
|
||||||
|
@ -21,7 +21,7 @@ class Animation;
|
|||||||
class ModelViewer : public ViewerInterface {
|
class ModelViewer : public ViewerInterface {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Clump* viewing;
|
ClumpPtr viewing;
|
||||||
|
|
||||||
QSplitter* mainSplit;
|
QSplitter* mainSplit;
|
||||||
QVBoxLayout* mainLayout;
|
QVBoxLayout* mainLayout;
|
||||||
@ -43,7 +43,7 @@ public slots:
|
|||||||
/**
|
/**
|
||||||
* Display a raw model
|
* Display a raw model
|
||||||
*/
|
*/
|
||||||
void showModel(Clump* model);
|
void showModel(ClumpPtr model);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a game object's model
|
* Display a game object's model
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <data/Clump.hpp>
|
#include <data/Clump.hpp>
|
||||||
#include <glm/gtx/string_cast.hpp>
|
#include <glm/gtx/string_cast.hpp>
|
||||||
|
|
||||||
void ModelFramesWidget::updateInfoBox(Clump* model, ModelFrame* f) {
|
void ModelFramesWidget::updateInfoBox(ClumpPtr model, ModelFrame* f) {
|
||||||
if (f == nullptr) {
|
if (f == nullptr) {
|
||||||
_frameLabel->setText("");
|
_frameLabel->setText("");
|
||||||
} else {
|
} else {
|
||||||
@ -33,14 +33,14 @@ ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
|
|||||||
setLayout(_layout);
|
setLayout(_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelFramesWidget::setModel(Clump* model) {
|
void ModelFramesWidget::setModel(ClumpPtr model) {
|
||||||
if (framemodel) {
|
if (framemodel) {
|
||||||
delete framemodel;
|
delete framemodel;
|
||||||
framemodel = nullptr;
|
framemodel = nullptr;
|
||||||
tree->setModel(nullptr);
|
tree->setModel(nullptr);
|
||||||
}
|
}
|
||||||
gmodel = model;
|
gmodel = model;
|
||||||
if (model != nullptr) {
|
if (model.get() != nullptr) {
|
||||||
framemodel = new DFFFramesTreeModel(model, this);
|
framemodel = new DFFFramesTreeModel(model, this);
|
||||||
tree->setModel(framemodel);
|
tree->setModel(framemodel);
|
||||||
tree->setDisabled(false);
|
tree->setDisabled(false);
|
||||||
|
@ -13,7 +13,7 @@ class ModelFrame;
|
|||||||
class ModelFramesWidget : public QWidget {
|
class ModelFramesWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Clump* gmodel;
|
ClumpPtr gmodel;
|
||||||
DFFFramesTreeModel* framemodel;
|
DFFFramesTreeModel* framemodel;
|
||||||
QTreeView* tree;
|
QTreeView* tree;
|
||||||
QVBoxLayout* _layout;
|
QVBoxLayout* _layout;
|
||||||
@ -21,7 +21,7 @@ class ModelFramesWidget : public QWidget {
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void updateInfoBox(Clump* model, ModelFrame* f);
|
void updateInfoBox(ClumpPtr model, ModelFrame* f);
|
||||||
|
|
||||||
void selectedModelChanged(const QModelIndex&, const QModelIndex&);
|
void selectedModelChanged(const QModelIndex&, const QModelIndex&);
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setModel(Clump* model);
|
void setModel(ClumpPtr model);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@ BOOST_AUTO_TEST_CASE(test_load_dff) {
|
|||||||
|
|
||||||
LoaderDFF loader;
|
LoaderDFF loader;
|
||||||
|
|
||||||
Clump* m = loader.loadFromMemory(d);
|
auto m = loader.loadFromMemory(d);
|
||||||
|
|
||||||
BOOST_REQUIRE(m != nullptr);
|
BOOST_REQUIRE(m.get() != nullptr);
|
||||||
|
|
||||||
BOOST_REQUIRE(m->getFrame());
|
BOOST_REQUIRE(m->getFrame());
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ BOOST_AUTO_TEST_CASE(test_load_dff) {
|
|||||||
BOOST_REQUIRE(atomic->getGeometry());
|
BOOST_REQUIRE(atomic->getGeometry());
|
||||||
BOOST_REQUIRE(atomic->getFrame());
|
BOOST_REQUIRE(atomic->getFrame());
|
||||||
|
|
||||||
delete m;
|
m.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user