From dd5c083124de4eed518930dc5963c9129b387edc Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 24 Sep 2012 00:42:05 +0200 Subject: [PATCH 1/3] fix the race selection escape crash --- apps/openmw/mwgui/race.cpp | 19 +++++++++++++------ apps/openmw/mwgui/race.hpp | 3 ++- apps/openmw/mwrender/characterpreview.cpp | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 3fe70d959b..99cb5f3b2d 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -33,11 +33,6 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager) setText("AppearanceT", mWindowManager.getGameSettingString("sRaceMenu1", "Appearance")); getWidget(mPreviewImage, "PreviewImage"); - MWBase::Environment::get().getWorld ()->setupExternalRendering (mPreview); - mPreview.update (0); - - mPreviewImage->setImageTexture ("CharacterHeadPreview"); - getWidget(mHeadRotate, "HeadRotate"); mHeadRotate->setScrollRange(50); mHeadRotate->setScrollPosition(20); @@ -107,6 +102,12 @@ void RaceDialog::open() updateRaces(); updateSkills(); updateSpellPowers(); + + mPreview = new MWRender::RaceSelectionPreview(); + MWBase::Environment::get().getWorld ()->setupExternalRendering (*mPreview); + mPreview->update (0); + + mPreviewImage->setImageTexture ("CharacterHeadPreview"); } @@ -138,6 +139,12 @@ int wrap(int index, int max) return index; } +void RaceDialog::close() +{ + delete mPreview; + mPreview = 0; +} + // widget controls void RaceDialog::onOkClicked(MyGUI::Widget* _sender) @@ -154,7 +161,7 @@ void RaceDialog::onHeadRotate(MyGUI::ScrollBar*, size_t _position) { float angle = (float(_position) / 49.f - 0.5) * 3.14 * 2; float diff = angle - mCurrentAngle; - mPreview.update (diff); + mPreview->update (diff); mCurrentAngle += diff; } diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index 0505e58e13..c4734eae8c 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -46,6 +46,7 @@ namespace MWGui void setNextButtonShow(bool shown); virtual void open(); + virtual void close(); // Events typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; @@ -94,7 +95,7 @@ namespace MWGui float mCurrentAngle; - MWRender::RaceSelectionPreview mPreview; + MWRender::RaceSelectionPreview* mPreview; }; } #endif diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index c8852bff52..4a05545683 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -25,6 +25,7 @@ namespace MWRender , mPosition(position) , mLookAt(lookAt) , mCharacter(character) + , mAnimation(NULL) { } From f8a18d58a628584b7bd9b180d6cd00a615c5086c Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 24 Sep 2012 01:06:17 +0200 Subject: [PATCH 2/3] re-use the texture across preview instances --- apps/openmw/mwrender/characterpreview.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index 4a05545683..175f48e42a 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -54,10 +54,13 @@ namespace MWRender mCamera->setNearClipDistance (0.01); mCamera->setFarClipDistance (1000); - mTexture = Ogre::TextureManager::getSingleton().createManual(mName, - Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mSizeX, mSizeY, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET); + mTexture = Ogre::TextureManager::getSingleton().getByName (mName); + if (mTexture.isNull ()) + mTexture = Ogre::TextureManager::getSingleton().createManual(mName, + Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mSizeX, mSizeY, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET); mRenderTarget = mTexture->getBuffer()->getRenderTarget(); + mRenderTarget->removeAllViewports (); mViewport = mRenderTarget->addViewport(mCamera); mViewport->setOverlaysEnabled(false); mViewport->setBackgroundColour(Ogre::ColourValue(0, 0, 0, 0)); From 02e7b3df4fb4a3574c0bb9853c9319003106a5c8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 24 Sep 2012 01:07:33 +0200 Subject: [PATCH 3/3] oops --- apps/openmw/mwrender/characterpreview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index 175f48e42a..f755f34ef2 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -75,7 +75,7 @@ namespace MWRender CharacterPreview::~CharacterPreview () { - Ogre::TextureManager::getSingleton().remove(mName); + //Ogre::TextureManager::getSingleton().remove(mName); mSceneMgr->destroyCamera (mName); delete mAnimation; }