diff --git a/rwengine/CMakeLists.txt b/rwengine/CMakeLists.txt index 5e9b8951..534744c3 100644 --- a/rwengine/CMakeLists.txt +++ b/rwengine/CMakeLists.txt @@ -41,8 +41,6 @@ set(RWENGINE_SOURCES src/data/PathData.hpp src/data/PedData.cpp src/data/PedData.hpp - src/data/Skeleton.cpp - src/data/Skeleton.hpp src/data/WeaponData.hpp src/data/ZoneData.hpp src/dynamics/CollisionInstance.cpp diff --git a/rwengine/src/data/Skeleton.cpp b/rwengine/src/data/Skeleton.cpp deleted file mode 100644 index 2665344a..00000000 --- a/rwengine/src/data/Skeleton.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include - -Skeleton::FrameTransform Skeleton::IdentityTransform = {glm::vec3(0.f), - glm::quat()}; -Skeleton::FrameData Skeleton::IdentityData = { - Skeleton::IdentityTransform, Skeleton::IdentityTransform, true}; - -Skeleton::Skeleton() { -} - -void Skeleton::setAllData(const Skeleton::FramesData& data) { - framedata = data; -} - -const Skeleton::FrameData& Skeleton::getData(unsigned int frameIdx) const { - auto fdit = framedata.find(frameIdx); - if (fdit == framedata.end()) { - return Skeleton::IdentityData; - } - - return fdit->second; -} - -void Skeleton::setData(unsigned int frameIdx, const Skeleton::FrameData& data) { - framedata[frameIdx] = data; -} - -void Skeleton::setEnabled(ModelFrame* frame, bool enabled) { - auto fdit = framedata.find(frame->getIndex()); - if (fdit != framedata.end()) { - fdit->second.enabled = enabled; - } else { - FrameTransform tf{frame->getDefaultTranslation(), - glm::quat_cast(frame->getDefaultRotation())}; - framedata.insert({frame->getIndex(), {tf, tf, enabled}}); - } -} - -void Skeleton::setEnabled(unsigned int frameIdx, bool enabled) { - auto fdit = framedata.find(frameIdx); - if (fdit == framedata.end()) { - framedata.insert({frameIdx, - {Skeleton::IdentityTransform, - Skeleton::IdentityTransform, enabled}}); - } else { - fdit->second.enabled = enabled; - } -} - -const Skeleton::FrameTransform& Skeleton::getInterpolated( - unsigned int frameIdx) const { - auto itit = interpolateddata.find(frameIdx); - if (itit == interpolateddata.end()) { - return Skeleton::IdentityTransform; - } - - return itit->second; -} - -void Skeleton::interpolate(float alpha) { - interpolateddata.clear(); - - for (auto i = framedata.begin(); i != framedata.end(); ++i) { - auto& t2 = i->second.a.translation; - auto& t1 = i->second.b.translation; - - auto& r2 = i->second.a.rotation; - auto& r1 = i->second.b.rotation; - - interpolateddata.insert( - {i->first, {glm::mix(t1, t2, alpha), glm::slerp(r1, r2, alpha)}}); - } -} - -glm::mat4 Skeleton::getMatrix(unsigned int frameIdx) const { - const FrameTransform& ft = getInterpolated(frameIdx); - - glm::mat4 m; - - m = glm::translate(m, ft.translation); - m = m * glm::mat4_cast(ft.rotation); - - return m; -} - -glm::mat4 Skeleton::getMatrix(ModelFrame* frame) const { - auto itit = interpolateddata.find(frame->getIndex()); - if (itit != interpolateddata.end()) { - glm::mat4 m; - - m = glm::translate(m, itit->second.translation); - m = m * glm::mat4_cast(itit->second.rotation); - - return m; - } - - return frame->getTransform(); -} diff --git a/rwengine/src/data/Skeleton.hpp b/rwengine/src/data/Skeleton.hpp deleted file mode 100644 index 0c487989..00000000 --- a/rwengine/src/data/Skeleton.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _SKELETON_HPP_ -#define _SKELETON_HPP_ - -#include -#include -#include -#include - -class ModelFrame; -/** - * Data class for additional frame transformation and meta data. - * - * Provides interfaces to modify and query the visibility of model frames, - * as well as their transformation. Modified by Animator to animate models. - */ -class Skeleton { -public: - struct FrameTransform { - glm::vec3 translation; - glm::quat rotation; - }; - - static FrameTransform IdentityTransform; - - struct FrameData { - FrameTransform a; - FrameTransform b; - bool enabled; - }; - - static FrameData IdentityData; - - typedef std::map FramesData; - typedef std::map TransformData; - - Skeleton(); - - void setAllData(const FramesData& data); - - const FrameData& getData(unsigned int frameIdx) const; - - void setData(unsigned int frameIdx, const FrameData& data); - void setEnabled(ModelFrame* frame, bool enabled); - - void setEnabled(unsigned int frameIdx, bool enabled); - - const FrameTransform& getInterpolated(unsigned int frameIdx) const; - - glm::mat4 getMatrix(unsigned int frameIdx) const; - glm::mat4 getMatrix(ModelFrame* frame) const; - - void interpolate(float alpha); - -private: - FramesData framedata; - TransformData interpolateddata; -}; - -#endif \ No newline at end of file diff --git a/rwengine/src/engine/Animator.cpp b/rwengine/src/engine/Animator.cpp index 68dabbd6..a03cd2c9 100644 --- a/rwengine/src/engine/Animator.cpp +++ b/rwengine/src/engine/Animator.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/rwengine/src/items/Weapon.cpp b/rwengine/src/items/Weapon.cpp index b45bd993..560161de 100644 --- a/rwengine/src/items/Weapon.cpp +++ b/rwengine/src/items/Weapon.cpp @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/rwengine/src/objects/CharacterObject.cpp b/rwengine/src/objects/CharacterObject.cpp index 5fca3a35..ba3608b9 100644 --- a/rwengine/src/objects/CharacterObject.cpp +++ b/rwengine/src/objects/CharacterObject.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/rwengine/src/objects/CutsceneObject.cpp b/rwengine/src/objects/CutsceneObject.cpp index c5893929..bc35a74e 100644 --- a/rwengine/src/objects/CutsceneObject.cpp +++ b/rwengine/src/objects/CutsceneObject.cpp @@ -1,4 +1,3 @@ -#include #include #include diff --git a/rwengine/src/objects/GameObject.cpp b/rwengine/src/objects/GameObject.cpp index 08f6741a..c80d51ed 100644 --- a/rwengine/src/objects/GameObject.cpp +++ b/rwengine/src/objects/GameObject.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -9,9 +8,6 @@ GameObject::~GameObject() { if (animator) { delete animator; } - if (skeleton) { - delete skeleton; - } if (modelinfo_) { modelinfo_->removeReference(); diff --git a/rwengine/src/objects/GameObject.hpp b/rwengine/src/objects/GameObject.hpp index bbce6e20..7a6de40a 100644 --- a/rwengine/src/objects/GameObject.hpp +++ b/rwengine/src/objects/GameObject.hpp @@ -11,7 +11,6 @@ #include #include -class Skeleton; class CharacterController; class Animator; class GameWorld; @@ -46,7 +45,6 @@ public: GameWorld* engine; Animator* animator; /// Object's animator. - Skeleton* skeleton; bool inWater; @@ -71,7 +69,6 @@ public: , rotation(rot) , engine(engine) , animator(nullptr) - , skeleton(nullptr) , inWater(false) , _lastHeight(std::numeric_limits::max()) , visible(true) diff --git a/rwengine/src/objects/VehicleObject.cpp b/rwengine/src/objects/VehicleObject.cpp index 30b76773..2792b178 100644 --- a/rwengine/src/objects/VehicleObject.cpp +++ b/rwengine/src/objects/VehicleObject.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include diff --git a/rwengine/src/render/GameRenderer.cpp b/rwengine/src/render/GameRenderer.cpp index d6596528..c0a33b5d 100644 --- a/rwengine/src/render/GameRenderer.cpp +++ b/rwengine/src/render/GameRenderer.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include diff --git a/rwengine/src/render/ObjectRenderer.cpp b/rwengine/src/render/ObjectRenderer.cpp index c0ac1d9f..bc0098f3 100644 --- a/rwengine/src/render/ObjectRenderer.cpp +++ b/rwengine/src/render/ObjectRenderer.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include diff --git a/rwengine/src/script/modules/GTA3ModuleImpl.inl b/rwengine/src/script/modules/GTA3ModuleImpl.inl index 843558f5..c2f77a26 100644 --- a/rwengine/src/script/modules/GTA3ModuleImpl.inl +++ b/rwengine/src/script/modules/GTA3ModuleImpl.inl @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include diff --git a/rwviewer/ViewerWidget.cpp b/rwviewer/ViewerWidget.cpp index 1f563bc7..c2a8ea50 100644 --- a/rwviewer/ViewerWidget.cpp +++ b/rwviewer/ViewerWidget.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -81,9 +80,8 @@ void ViewerWidget::paintGL() { r.setViewport(width(), height()); - if (dummyObject && dummyObject->animator && dummyObject->skeleton) { + if (dummyObject && dummyObject->animator) { dummyObject->animator->tick(1.f / 60.f); - dummyObject->skeleton->interpolate(1.f); } r.getRenderer()->invalidate(); diff --git a/rwviewer/models/DFFFramesTreeModel.cpp b/rwviewer/models/DFFFramesTreeModel.cpp index 10840ce9..3950482c 100644 --- a/rwviewer/models/DFFFramesTreeModel.cpp +++ b/rwviewer/models/DFFFramesTreeModel.cpp @@ -1,10 +1,9 @@ #include "DFFFramesTreeModel.hpp" #include -#include -DFFFramesTreeModel::DFFFramesTreeModel(Clump* m, Skeleton* skel, +DFFFramesTreeModel::DFFFramesTreeModel(Clump* m, QObject* parent) - : QAbstractItemModel(parent), model(m), skeleton(skel) { + : QAbstractItemModel(parent), model(m) { } int DFFFramesTreeModel::columnCount(const QModelIndex& parent) const { @@ -59,10 +58,7 @@ QVariant DFFFramesTreeModel::data(const QModelIndex& index, int role) const { } } else if (role == Qt::CheckStateRole) { if (index.column() == 0) { - if (skeleton) { - return skeleton->getData(f->getIndex()).enabled ? Qt::Checked - : Qt::Unchecked; - } + return true; } } return QVariant(); @@ -77,11 +73,10 @@ bool DFFFramesTreeModel::setData(const QModelIndex& index, ModelFrame* f = static_cast(index.internalPointer()); if (role == Qt::CheckStateRole) { - if (index.column() == 0 && skeleton) { + if (index.column() == 0) { if ((Qt::CheckState)value.toInt() == Qt::Checked) { - skeleton->setEnabled(f, true); + RW_UNIMPLEMENTED("Hiding Frames"); } else { - skeleton->setEnabled(f, false); } return true; } @@ -97,7 +92,7 @@ Qt::ItemFlags DFFFramesTreeModel::flags(const QModelIndex& index) const { Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; - if (index.column() == 0 && skeleton) { + if (index.column() == 0) { flags |= Qt::ItemIsUserCheckable; } diff --git a/rwviewer/models/DFFFramesTreeModel.hpp b/rwviewer/models/DFFFramesTreeModel.hpp index 236578c7..f4ec521f 100644 --- a/rwviewer/models/DFFFramesTreeModel.hpp +++ b/rwviewer/models/DFFFramesTreeModel.hpp @@ -5,14 +5,12 @@ #include class Clump; -class Skeleton; class DFFFramesTreeModel : public QAbstractItemModel { Clump* model; - Skeleton* skeleton; public: - explicit DFFFramesTreeModel(Clump* m, Skeleton* skel, QObject* parent = 0); + explicit DFFFramesTreeModel(Clump* m, QObject* parent = 0); virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; diff --git a/rwviewer/views/ModelViewer.cpp b/rwviewer/views/ModelViewer.cpp index 2baecf28..be210123 100644 --- a/rwviewer/views/ModelViewer.cpp +++ b/rwviewer/views/ModelViewer.cpp @@ -1,6 +1,5 @@ #include "ModelViewer.hpp" #include -#include #include #include #include @@ -9,7 +8,7 @@ ModelViewer::ModelViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags f) - : ViewerInterface(parent, f), viewing(nullptr), skeleton(nullptr) { + : ViewerInterface(parent, f), viewing(nullptr) { mainSplit = new QSplitter; mainLayout = new QVBoxLayout; @@ -42,19 +41,14 @@ void ModelViewer::setViewerWidget(ViewerWidget* widget) { void ModelViewer::showModel(Clump* model) { viewing = model; - if (skeleton) { - delete skeleton; - } - skeleton = new Skeleton(); viewerWidget->showModel(model); - frames->setModel(model, nullptr); + frames->setModel(model); } void ModelViewer::showObject(uint16_t object) { viewerWidget->showObject(object); viewing = viewerWidget->currentModel(); - skeleton = viewerWidget->currentObject()->skeleton; - frames->setModel(viewing, skeleton); + frames->setModel(viewing); } void ModelViewer::loadAnimations(const QString& file) { diff --git a/rwviewer/views/ModelViewer.hpp b/rwviewer/views/ModelViewer.hpp index 7154d248..c8085c6d 100644 --- a/rwviewer/views/ModelViewer.hpp +++ b/rwviewer/views/ModelViewer.hpp @@ -15,7 +15,6 @@ class ViewerWidget; class Clump; -class Skeleton; class ModelFramesWidget; class Animation; @@ -23,7 +22,6 @@ class ModelViewer : public ViewerInterface { Q_OBJECT Clump* viewing; - Skeleton* skeleton; QSplitter* mainSplit; QVBoxLayout* mainLayout; diff --git a/rwviewer/widgets/ModelFramesWidget.cpp b/rwviewer/widgets/ModelFramesWidget.cpp index 4fa3bb15..51720ce5 100644 --- a/rwviewer/widgets/ModelFramesWidget.cpp +++ b/rwviewer/widgets/ModelFramesWidget.cpp @@ -33,7 +33,7 @@ ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags) setLayout(_layout); } -void ModelFramesWidget::setModel(Clump* model, Skeleton* skeleton) { +void ModelFramesWidget::setModel(Clump* model) { if (framemodel) { delete framemodel; framemodel = nullptr; @@ -41,7 +41,7 @@ void ModelFramesWidget::setModel(Clump* model, Skeleton* skeleton) { } gmodel = model; if (model != nullptr) { - framemodel = new DFFFramesTreeModel(model, skeleton, this); + framemodel = new DFFFramesTreeModel(model, this); tree->setModel(framemodel); tree->setDisabled(false); connect(tree->selectionModel(), diff --git a/rwviewer/widgets/ModelFramesWidget.hpp b/rwviewer/widgets/ModelFramesWidget.hpp index cdc96907..3bdf48f8 100644 --- a/rwviewer/widgets/ModelFramesWidget.hpp +++ b/rwviewer/widgets/ModelFramesWidget.hpp @@ -30,7 +30,7 @@ public: public slots: - void setModel(Clump* model, Skeleton* skeleton); + void setModel(Clump* model); signals: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e663ed70..e8d4eb3d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -38,7 +38,6 @@ set(TEST_SOURCES "test_rwbstream.cpp" "test_SaveGame.cpp" "test_scriptmachine.cpp" - "test_skeleton.cpp" "test_state.cpp" "test_text.cpp" "test_trafficdirector.cpp" diff --git a/tests/test_animation.cpp b/tests/test_animation.cpp index 77f24f96..36848543 100644 --- a/tests/test_animation.cpp +++ b/tests/test_animation.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include "test_globals.hpp" @@ -10,7 +9,6 @@ BOOST_AUTO_TEST_SUITE(AnimationTests) #if RW_TEST_WITH_DATA BOOST_AUTO_TEST_CASE(test_matrix) { { - Skeleton skeleton; Animation animation; /** Models are currently needed to relate animation bones <=> model diff --git a/tests/test_skeleton.cpp b/tests/test_skeleton.cpp deleted file mode 100644 index cc7ad527..00000000 --- a/tests/test_skeleton.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include -#include - -BOOST_AUTO_TEST_SUITE(SkeletonTests) - -BOOST_AUTO_TEST_CASE(test_methods) { - Skeleton::FrameTransform t1{glm::vec3(0.f, 0.f, 0.f), - glm::quat(0.f, 0.f, 0.f, 0.f)}; - Skeleton::FrameTransform t2{glm::vec3(1.f, 0.f, 0.f), - glm::quat(0.f, 0.f, 1.f, 0.f)}; - - Skeleton skeleton; - - skeleton.setAllData({{0, {t1, t2, true}}}); - - BOOST_CHECK(skeleton.getData(0).a.translation == t1.translation); - BOOST_CHECK(skeleton.getData(0).a.rotation == t1.rotation); - - BOOST_CHECK(skeleton.getData(0).b.translation == t2.translation); - BOOST_CHECK(skeleton.getData(0).b.rotation == t2.rotation); - - BOOST_CHECK(skeleton.getData(0).enabled); - - skeleton.setData(0, {t2, t1, false}); - - BOOST_CHECK(skeleton.getData(0).a.translation == t2.translation); - BOOST_CHECK(skeleton.getData(0).a.rotation == t2.rotation); - - BOOST_CHECK(skeleton.getData(0).b.translation == t1.translation); - BOOST_CHECK(skeleton.getData(0).b.rotation == t1.rotation); - - BOOST_CHECK(!skeleton.getData(0).enabled); -} - -BOOST_AUTO_TEST_CASE(test_interpolate) { - Skeleton::FrameTransform t1{glm::vec3(0.f, 0.f, 0.f), - glm::quat(0.f, 0.f, 0.f, 0.f)}; - Skeleton::FrameTransform t2{glm::vec3(1.f, 0.f, 0.f), - glm::quat(0.f, 0.f, 1.f, 0.f)}; - - Skeleton skeleton; - - skeleton.setAllData({{0, {t2, t1, true}}}); - - /** Without calling Skeleton::interpolate(alpha) the result is identity */ - - BOOST_CHECK(skeleton.getInterpolated(0).translation == - Skeleton::IdentityTransform.translation); - BOOST_CHECK(skeleton.getInterpolated(0).rotation == - Skeleton::IdentityTransform.rotation); - - skeleton.interpolate(0.f); - - BOOST_CHECK(skeleton.getInterpolated(0).translation == t1.translation); - BOOST_CHECK(skeleton.getInterpolated(0).rotation == t1.rotation); - - skeleton.interpolate(1.f); - - BOOST_CHECK(skeleton.getInterpolated(0).translation == t2.translation); - BOOST_CHECK(skeleton.getInterpolated(0).rotation == t2.rotation); -} -BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/test_vehicle.cpp b/tests/test_vehicle.cpp index d5082d8d..a50dedc7 100644 --- a/tests/test_vehicle.cpp +++ b/tests/test_vehicle.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include "test_globals.hpp"