diff --git a/.travis.yml b/.travis.yml index dbcb00ff8..b5c49048b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ branches: - master - coverity_scan - /openmw-.*$/ + - test-release-build-on-travis env: global: - macos_qt_formula=qt@5.5 diff --git a/apps/essimporter/converter.cpp b/apps/essimporter/converter.cpp index a428a8c71..68ee93c89 100644 --- a/apps/essimporter/converter.cpp +++ b/apps/essimporter/converter.cpp @@ -137,7 +137,7 @@ namespace ESSImport osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("png"); if (!readerwriter) { - std::cerr << "can't write global map image, no png readerwriter found" << std::endl; + std::cerr << "Error: can't write global map image, no png readerwriter found" << std::endl; return; } @@ -146,7 +146,7 @@ namespace ESSImport osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*image2, ostream); if (!result.success()) { - std::cerr << "can't write global map image: " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: can't write global map image: " << result.message() << " code " << result.status() << std::endl; return; } diff --git a/apps/essimporter/importer.cpp b/apps/essimporter/importer.cpp index a420d08da..c27e15a3e 100644 --- a/apps/essimporter/importer.cpp +++ b/apps/essimporter/importer.cpp @@ -38,7 +38,7 @@ namespace { if (fileHeader.mSCRS.size() != 128*128*4) { - std::cerr << "unexpected screenshot size " << std::endl; + std::cerr << "Error: unexpected screenshot size " << std::endl; return; } @@ -66,14 +66,14 @@ namespace osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("jpg"); if (!readerwriter) { - std::cerr << "can't write screenshot: no jpg readerwriter found" << std::endl; + std::cerr << "Error: can't write screenshot: no jpg readerwriter found" << std::endl; return; } osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*image, ostream); if (!result.success()) { - std::cerr << "can't write screenshot: " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: can't write screenshot: " << result.message() << " code " << result.status() << std::endl; return; } @@ -333,7 +333,7 @@ namespace ESSImport if (unknownRecords.insert(n.intval).second) { std::ios::fmtflags f(std::cerr.flags()); - std::cerr << "unknown record " << n.toString() << " (0x" << std::hex << esm.getFileOffset() << ")" << std::endl; + std::cerr << "Error: unknown record " << n.toString() << " (0x" << std::hex << esm.getFileOffset() << ")" << std::endl; std::cerr.flags(f); } diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index cf57f5623..0895c92d5 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -452,16 +452,16 @@ void OMW::Engine::setWindowIcon() std::string windowIcon = (mResDir / "mygui" / "openmw.png").string(); windowIconStream.open(windowIcon, std::ios_base::in | std::ios_base::binary); if (windowIconStream.fail()) - std::cerr << "Failed to open " << windowIcon << std::endl; + std::cerr << "Error: Failed to open " << windowIcon << std::endl; osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension("png"); if (!reader) { - std::cerr << "Failed to read window icon, no png readerwriter found" << std::endl; + std::cerr << "Error: Failed to read window icon, no png readerwriter found" << std::endl; return; } osgDB::ReaderWriter::ReadResult result = reader->readImage(windowIconStream); if (!result.success()) - std::cerr << "Failed to read " << windowIcon << ": " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: Failed to read " << windowIcon << ": " << result.message() << " code " << result.status() << std::endl; else { osg::ref_ptr image = result.getImage(); @@ -636,14 +636,14 @@ public: osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension(mScreenshotFormat); if (!readerwriter) { - std::cerr << "Can't write screenshot, no '" << mScreenshotFormat << "' readerwriter found" << std::endl; + std::cerr << "Error: Can't write screenshot, no '" << mScreenshotFormat << "' readerwriter found" << std::endl; return; } osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(image, outStream); if (!result.success()) { - std::cerr << "Can't write screenshot: " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: Can't write screenshot: " << result.message() << " code " << result.status() << std::endl; } } diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index ca835ad51..df26780a9 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -147,7 +147,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("fallback", bpo::value()->default_value(FallbackMap(), "") ->multitoken()->composing(), "fallback values") - ("no-grab", "Don't grab mouse cursor") + ("no-grab", bpo::value()->implicit_value(true)->default_value(false), "Don't grab mouse cursor") ("export-fonts", bpo::value()->implicit_value(true) ->default_value(false), "Export Morrowind .fnt fonts to PNG image and XML file in current directory") @@ -185,7 +185,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat Version::Version v = Version::getOpenmwVersion(variables["resources"].as().toStdString()); std::cout << v.describe() << std::endl; - engine.setGrabMouse(!variables.count("no-grab")); + engine.setGrabMouse(!variables["no-grab"].as()); // Font encoding settings std::string encoding(variables["encoding"].as().toStdString()); @@ -234,7 +234,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setCell(variables["start"].as().toStdString()); engine.setSkipMenu (variables["skip-menu"].as(), variables["new-game"].as()); if (!variables["skip-menu"].as() && variables["new-game"].as()) - std::cerr << "new-game used without skip-menu -> ignoring it" << std::endl; + std::cerr << "Warning: new-game used without skip-menu -> ignoring it" << std::endl; // scripts engine.setCompileAll(variables["script-all"].as()); diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 29bbc80f8..254bc7d47 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -238,7 +238,7 @@ namespace MWDialogue if (!success) { std::cerr - << "compiling failed (dialogue script)" << std::endl + << "Warning: compiling failed (dialogue script)" << std::endl << cmd << std::endl << std::endl; } diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index d72e6627f..9464daaf6 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -274,7 +274,7 @@ namespace MWGui } catch (std::exception& e) { - std::cerr << "Failed to create chargen window: " << e.what() << std::endl; + std::cerr << "Error: Failed to create chargen window: " << e.what() << std::endl; } } @@ -592,7 +592,7 @@ namespace MWGui mGenerateClass = "Mage"; else { - std::cerr << "Failed to deduce class from chosen answers in generate class dialog" << std::endl; + std::cout << "Failed to deduce class from chosen answers in generate class dialog" << std::endl; mGenerateClass = "Thief"; } } diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 5187c3043..f93d1cc0a 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -405,14 +405,14 @@ namespace MWGui osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("jpg"); if (!readerwriter) { - std::cerr << "Can't open savegame screenshot, no jpg readerwriter found" << std::endl; + std::cerr << "Error: Can't open savegame screenshot, no jpg readerwriter found" << std::endl; return; } osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(instream); if (!result.success()) { - std::cerr << "Failed to read savegame screenshot: " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: Failed to read savegame screenshot: " << result.message() << " code " << result.status() << std::endl; return; } diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 3211473e2..c167164d9 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -33,7 +33,7 @@ namespace if (val == "linear") return "Trilinear"; if (val == "nearest") return "Bilinear"; if (val != "none") - std::cerr<< "Invalid texture mipmap option: "<getStore().get().search(enchId); if (!ench) { - std::cerr << "Can't find enchantment '" << enchId << "' on item " << base.getCellRef().getRefId() << std::endl; + std::cerr << "Warning: Can't find enchantment '" << enchId << "' on item " << base.getCellRef().getRefId() << std::endl; return false; } diff --git a/apps/openmw/mwgui/spellmodel.cpp b/apps/openmw/mwgui/spellmodel.cpp index c77533008..d4ab552ff 100644 --- a/apps/openmw/mwgui/spellmodel.cpp +++ b/apps/openmw/mwgui/spellmodel.cpp @@ -84,7 +84,7 @@ namespace MWGui const ESM::Enchantment* enchant = esmStore.get().search(enchantId); if (!enchant) { - std::cerr << "Can't find enchantment '" << enchantId << "' on item " << item.getCellRef().getRefId() << std::endl; + std::cerr << "Warning: Can't find enchantment '" << enchantId << "' on item " << item.getCellRef().getRefId() << std::endl; continue; } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 4fb096a7f..654d654c7 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1162,7 +1162,7 @@ namespace MWGui { if (!mStore) { - std::cerr << "WindowManager::onRetrieveTag: no Store set up yet, can not replace '" << tag << "'" << std::endl; + std::cerr << "Error: WindowManager::onRetrieveTag: no Store set up yet, can not replace '" << tag << "'" << std::endl; return; } const ESM::GameSetting *setting = mStore->get().find(tag); diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 3141e42f6..8591bc94f 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -389,47 +389,49 @@ namespace MWInput updateCursorMode(); - if(mJoystickLastUsed) + if (mGuiCursorEnabled) { - if (mGuiCursorEnabled) + float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue()*2.0f-1.0f; + float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue()*2.0f-1.0f; + float zAxis = mInputBinder->getChannel(A_LookUpDown)->getValue()*2.0f-1.0f; + const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize(); + + xAxis *= (1.5f - mInputBinder->getChannel(A_Use)->getValue()); + yAxis *= (1.5f - mInputBinder->getChannel(A_Use)->getValue()); + + // We keep track of our own mouse position, so that moving the mouse while in + // game mode does not move the position of the GUI cursor + float xmove = xAxis * dt * 1500.0f * mInvUiScalingFactor; + float ymove = yAxis * dt * 1500.0f * mInvUiScalingFactor; + if (xmove != 0|| ymove != 0) { - float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue()*2.0f-1.0f; - float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue()*2.0f-1.0f; - float zAxis = mInputBinder->getChannel(A_LookUpDown)->getValue()*2.0f-1.0f; - const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize(); - - xAxis *= (1.5f - mInputBinder->getChannel(A_Use)->getValue()); - yAxis *= (1.5f - mInputBinder->getChannel(A_Use)->getValue()); - - // We keep track of our own mouse position, so that moving the mouse while in - // game mode does not move the position of the GUI cursor - mGuiCursorX += xAxis * dt * 1500.0f * mInvUiScalingFactor; - mGuiCursorY += yAxis * dt * 1500.0f * mInvUiScalingFactor; + mGuiCursorX += xmove; + mGuiCursorY += ymove; mMouseWheel -= static_cast(zAxis * dt * 1500.0f); - mGuiCursorX = std::max(0.f, std::min(mGuiCursorX, float(viewSize.width))); - mGuiCursorY = std::max(0.f, std::min(mGuiCursorY, float(viewSize.height))); + mGuiCursorX = std::max(0.f, std::min(mGuiCursorX, float(viewSize.width-1))); + mGuiCursorY = std::max(0.f, std::min(mGuiCursorY, float(viewSize.height-1))); MyGUI::InputManager::getInstance().injectMouseMove(static_cast(mGuiCursorX), static_cast(mGuiCursorY), mMouseWheel); mInputManager->warpMouse(static_cast(mGuiCursorX/mInvUiScalingFactor), static_cast(mGuiCursorY/mInvUiScalingFactor)); } - if (mMouseLookEnabled) - { - float xAxis = mInputBinder->getChannel(A_LookLeftRight)->getValue()*2.0f-1.0f; - float yAxis = mInputBinder->getChannel(A_LookUpDown)->getValue()*2.0f-1.0f; - resetIdleTime(); + } + if (mMouseLookEnabled) + { + float xAxis = mInputBinder->getChannel(A_LookLeftRight)->getValue()*2.0f-1.0f; + float yAxis = mInputBinder->getChannel(A_LookUpDown)->getValue()*2.0f-1.0f; + resetIdleTime(); - float rot[3]; - rot[0] = yAxis * (dt * 100.0f) * 10.0f * mCameraSensitivity * (1.0f/256.f) * (mInvertY ? -1 : 1) * mCameraYMultiplier; - rot[1] = 0.0f; - rot[2] = xAxis * (dt * 100.0f) * 10.0f * mCameraSensitivity * (1.0f/256.f); + float rot[3]; + rot[0] = yAxis * (dt * 100.0f) * 10.0f * mCameraSensitivity * (1.0f/256.f) * (mInvertY ? -1 : 1) * mCameraYMultiplier; + rot[1] = 0.0f; + rot[2] = xAxis * (dt * 100.0f) * 10.0f * mCameraSensitivity * (1.0f/256.f); - // Only actually turn player when we're not in vanity mode - if(!MWBase::Environment::get().getWorld()->vanityRotateCamera(rot)) - { - mPlayer->yaw(rot[2]); - mPlayer->pitch(rot[0]); - } + // Only actually turn player when we're not in vanity mode + if(!MWBase::Environment::get().getWorld()->vanityRotateCamera(rot)) + { + mPlayer->yaw(rot[2]); + mPlayer->pitch(rot[0]); } } @@ -443,73 +445,73 @@ namespace MWInput { bool triedToMove = false; bool isRunning = false; - if(mJoystickLastUsed) + + // joystick movement + float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue(); + float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue(); + if (xAxis < .5) { - float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue(); - float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue(); - if (xAxis < .5) - { - triedToMove = true; - mPlayer->setLeftRight (-1); - } - else if (xAxis > .5) - { - triedToMove = true; - mPlayer->setLeftRight (1); - } + triedToMove = true; + mPlayer->setLeftRight (-1); + } + else if (xAxis > .5) + { + triedToMove = true; + mPlayer->setLeftRight (1); + } - if (yAxis < .5) - { - triedToMove = true; - mPlayer->setAutoMove (false); - mPlayer->setForwardBackward (1); - } - else if (yAxis > .5) - { - triedToMove = true; - mPlayer->setAutoMove (false); - mPlayer->setForwardBackward (-1); - } + if (yAxis < .5) + { + triedToMove = true; + mPlayer->setAutoMove (false); + mPlayer->setForwardBackward (1); + } + else if (yAxis > .5) + { + triedToMove = true; + mPlayer->setAutoMove (false); + mPlayer->setForwardBackward (-1); + } + else if(mPlayer->getAutoMove()) + { + triedToMove = true; + mPlayer->setForwardBackward (1); + } + if (triedToMove) + mJoystickLastUsed = true; - else if(mPlayer->getAutoMove()) - { - triedToMove = true; - mPlayer->setForwardBackward (1); - } - isRunning = xAxis > .75 || xAxis < .25 || yAxis > .75 || yAxis < .25; - if(triedToMove) resetIdleTime(); + // keyboard movement + isRunning = xAxis > .75 || xAxis < .25 || yAxis > .75 || yAxis < .25; + if(triedToMove) resetIdleTime(); + + if (actionIsActive(A_MoveLeft)) + { + triedToMove = true; + mPlayer->setLeftRight (-1); } - else + else if (actionIsActive(A_MoveRight)) { - if (actionIsActive(A_MoveLeft)) - { - triedToMove = true; - mPlayer->setLeftRight (-1); - } - else if (actionIsActive(A_MoveRight)) - { - triedToMove = true; - mPlayer->setLeftRight (1); - } + triedToMove = true; + mPlayer->setLeftRight (1); + } - if (actionIsActive(A_MoveForward)) - { - triedToMove = true; - mPlayer->setAutoMove (false); - mPlayer->setForwardBackward (1); - } - else if (actionIsActive(A_MoveBackward)) - { - triedToMove = true; - mPlayer->setAutoMove (false); - mPlayer->setForwardBackward (-1); - } + if (actionIsActive(A_MoveForward)) + { + triedToMove = true; + mPlayer->setAutoMove (false); + mPlayer->setForwardBackward (1); + } + else if (actionIsActive(A_MoveBackward)) + { + triedToMove = true; + mPlayer->setAutoMove (false); + mPlayer->setForwardBackward (-1); + } - else if(mPlayer->getAutoMove()) - { - triedToMove = true; - mPlayer->setForwardBackward (1); - } + else if(mPlayer->getAutoMove()) + { + triedToMove = true; + mPlayer->setForwardBackward (1); } if (!mSneakToggles) @@ -855,7 +857,6 @@ namespace MWInput void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg ) { - mJoystickLastUsed = true; if (!mControlsDisabled) mInputBinder->axisMoved(deviceID, arg); } diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index b0f9b1d50..fcb6a20e2 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1507,7 +1507,7 @@ namespace MWMechanics } else { - std::cerr<< "Error in Actors::playAnimationGroup: Unable to find " << ptr.getCellRef().getRefId() << std::endl; + std::cerr<< "Warning: Actors::playAnimationGroup: Unable to find " << ptr.getCellRef().getRefId() << std::endl; return false; } } diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 73ddce4b4..5396b5b39 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -725,7 +725,7 @@ namespace MWMechanics } else { - std::cerr<< "Attempted to play out of range idle animation \""<accept(visitor); if (!visitor.mFound) { - std::cerr << "animateCollisionShapes: Can't find node " << recIndex << " for " << mPtr.getCellRef().getRefId() << std::endl; + std::cerr << "Error: animateCollisionShapes can't find node " << recIndex << " for " << mPtr.getCellRef().getRefId() << std::endl; return; } osg::NodePath nodePath = visitor.mFoundPath; diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 5300d6ab4..ba4307c89 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -562,7 +562,7 @@ namespace MWRender NodeMap::const_iterator found = nodeMap.find(bonename); if (found == nodeMap.end()) { - std::cerr << "addAnimSource: can't find bone '" + bonename << "' in " << model << " (referenced by " << kfname << ")" << std::endl; + std::cerr << "Warning: addAnimSource: can't find bone '" + bonename << "' in " << model << " (referenced by " << kfname << ")" << std::endl; continue; } @@ -1697,12 +1697,12 @@ namespace MWRender PartHolder::~PartHolder() { if (mNode.get() && !mNode->getNumParents()) - std::cerr << "Warning: part has no parents " << std::endl; + std::cerr << "Error: part has no parents " << std::endl; if (mNode.get() && mNode->getNumParents()) { if (mNode->getNumParents() > 1) - std::cerr << "Warning: part has multiple parents " << mNode->getNumParents() << " " << mNode.get() << std::endl; + std::cerr << "Error: part has multiple parents " << mNode->getNumParents() << " " << mNode.get() << std::endl; mNode->getParent(0)->removeChild(mNode); } } diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index b105746c6..cb6489ef4 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -155,7 +155,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot) } catch (std::exception& e) { - std::cerr << "Error adding creature part: " << e.what() << std::endl; + std::cerr << "Can not add creature part: " << e.what() << std::endl; } } diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 0d8a7a039..2536818ef 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -408,14 +408,14 @@ namespace MWRender osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("png"); if (!readerwriter) { - std::cerr << "Can't write map overlay: no png readerwriter found" << std::endl; + std::cerr << "Error: Can't write map overlay: no png readerwriter found" << std::endl; return; } osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*mOverlayImage, ostream); if (!result.success()) { - std::cerr << "Can't write map overlay: " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: Can't write map overlay: " << result.message() << " code " << result.status() << std::endl; return; } @@ -460,14 +460,14 @@ namespace MWRender osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("png"); if (!readerwriter) { - std::cerr << "Can't read map overlay: no png readerwriter found" << std::endl; + std::cerr << "Error: Can't read map overlay: no png readerwriter found" << std::endl; return; } osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(istream); if (!result.success()) { - std::cerr << "Can't read map overlay: " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: Can't read map overlay: " << result.message() << " code " << result.status() << std::endl; return; } @@ -569,7 +569,7 @@ namespace MWRender CameraVector::iterator found = std::find(mActiveCameras.begin(), mActiveCameras.end(), camera); if (found == mActiveCameras.end()) { - std::cerr << "GlobalMap trying to remove an inactive camera" << std::endl; + std::cerr << "Error: GlobalMap trying to remove an inactive camera" << std::endl; return; } mActiveCameras.erase(found); diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 240ddc2e5..0e854d5dc 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -320,7 +320,7 @@ void LocalMap::markForRemoval(osg::Camera *cam) CameraVector::iterator found = std::find(mActiveCameras.begin(), mActiveCameras.end(), cam); if (found == mActiveCameras.end()) { - std::cerr << "trying to remove an inactive camera" << std::endl; + std::cerr << "Error: trying to remove an inactive camera" << std::endl; return; } mActiveCameras.erase(found); @@ -487,7 +487,7 @@ void LocalMap::requestInteriorMap(const MWWorld::CellStore* cell) // We are using the same bounds and angle as we were using when the textures were originally made. Segments should come out the same. if (i >= int(fog->mFogTextures.size())) { - std::cout << "Warning: fog texture count mismatch" << std::endl; + std::cout << "Error: fog texture count mismatch" << std::endl; break; } @@ -679,7 +679,7 @@ void LocalMap::MapSegment::loadFogOfWar(const ESM::FogTexture &esm) osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("tga"); if (!readerwriter) { - std::cerr << "Unable to load fog, can't find a tga ReaderWriter" << std::endl; + std::cerr << "Error: Unable to load fog, can't find a tga ReaderWriter" << std::endl; return; } @@ -688,7 +688,7 @@ void LocalMap::MapSegment::loadFogOfWar(const ESM::FogTexture &esm) osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(in); if (!result.success()) { - std::cerr << "Failed to read fog: " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: Failed to read fog: " << result.message() << " code " << result.status() << std::endl; return; } @@ -711,7 +711,7 @@ void LocalMap::MapSegment::saveFogOfWar(ESM::FogTexture &fog) const osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("tga"); if (!readerwriter) { - std::cerr << "Unable to write fog, can't find a tga ReaderWriter" << std::endl; + std::cerr << "Error: Unable to write fog, can't find a tga ReaderWriter" << std::endl; return; } @@ -720,7 +720,7 @@ void LocalMap::MapSegment::saveFogOfWar(ESM::FogTexture &fog) const osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*mFogOfWarImage, ostream); if (!result.success()) { - std::cerr << "Unable to write fog: " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: Unable to write fog: " << result.message() << " code " << result.status() << std::endl; return; } mFogOfWarImage->flipVertical(); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 1219f8920..87b6ae2bc 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -435,7 +435,7 @@ void NpcAnimation::updateNpcBase() if (bp) mHeadModel = "meshes\\" + bp->mModel; else - std::cerr << "Failed to load body part '" << mNpc->mHead << "'" << std::endl; + std::cerr << "Warning: Failed to load body part '" << mNpc->mHead << "'" << std::endl; } mHairModel = ""; @@ -445,7 +445,7 @@ void NpcAnimation::updateNpcBase() if (bp) mHairModel = "meshes\\" + bp->mModel; else - std::cerr << "Failed to load body part '" << mNpc->mHair << "'" << std::endl; + std::cerr << "Warning: Failed to load body part '" << mNpc->mHair << "'" << std::endl; } } @@ -625,7 +625,8 @@ void NpcAnimation::updateParts() const ESM::Light *light = part.get()->mBase; addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1, "meshes\\"+light->mModel); - addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), light); + if (mObjectParts[ESM::PRT_Shield]) + addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), light); } } @@ -828,7 +829,7 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vectormFemale << "'" << std::endl; + std::cerr << "Warning: Failed to find body part '" << part->mFemale << "'" << std::endl; } if(!bodypart && !part->mMale.empty()) { @@ -843,7 +844,7 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vectormMale << "'" << std::endl; + std::cerr << "Warning: Failed to find body part '" << part->mMale << "'" << std::endl; } if(bodypart) @@ -920,7 +921,7 @@ void NpcAnimation::showCarriedLeft(bool show) if (addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1, mesh, !iter->getClass().getEnchantment(*iter).empty(), &glowColor)) { - if (iter->getTypeName() == typeid(ESM::Light).name()) + if (iter->getTypeName() == typeid(ESM::Light).name() && mObjectParts[ESM::PRT_Shield]) addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), iter->get()->mBase); } } diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 2e10d42e5..d2ad1f9b5 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -197,16 +197,16 @@ osg::ref_ptr readPngImage (const std::string& file) boost::filesystem::ifstream inStream; inStream.open(file, std::ios_base::in | std::ios_base::binary); if (inStream.fail()) - std::cerr << "Failed to open " << file << std::endl; + std::cerr << "Error: Failed to open " << file << std::endl; osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension("png"); if (!reader) { - std::cerr << "Failed to read " << file << ", no png readerwriter found" << std::endl; + std::cerr << "Error: Failed to read " << file << ", no png readerwriter found" << std::endl; return osg::ref_ptr(); } osgDB::ReaderWriter::ReadResult result = reader->readImage(inStream); if (!result.success()) - std::cerr << "Failed to read " << file << ": " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: Failed to read " << file << ": " << result.message() << " code " << result.status() << std::endl; return result.getImage(); } diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 97ea19a63..7c1f9bf4d 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -65,14 +65,14 @@ namespace MWScript } catch (const std::exception& error) { - std::cerr << "An exception has been thrown: " << error.what() << std::endl; + std::cerr << "Error: An exception has been thrown: " << error.what() << std::endl; Success = false; } if (!Success) { std::cerr - << "compiling failed: " << name << std::endl; + << "Warning: compiling failed: " << name << std::endl; } if (Success) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 59b6d5829..7b9fecc93 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -238,7 +238,7 @@ namespace MWScript if (R()(runtime, false, true).isEmpty()) { std::cerr - << "Compensating for broken script in Morrowind.esm by " + << "Warning: Compensating for broken script in Morrowind.esm by " << "ignoring remote access to dagoth_ur_1" << std::endl; return; } diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 1fcf070d8..477657b8d 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -332,7 +332,7 @@ namespace MWScript store = MWBase::Environment::get().getWorld()->getExterior(cx,cy); if(!cell) { - std::string error = "PositionCell: unknown interior cell (" + cellID + "), moving to exterior instead"; + std::string error = "Warning: PositionCell: unknown interior cell (" + cellID + "), moving to exterior instead"; runtime.getContext().report (error); std::cerr << error << std::endl; } diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index 58d85fe5b..64c543fb1 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -471,7 +471,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str default: // ignore invalid records - std::cerr << "Ignoring unknown record: " << n.toString() << std::endl; + std::cerr << "Warning: Ignoring unknown record: " << n.toString() << std::endl; reader.skipRecord(); } int progressPercent = static_cast(float(reader.getFileOffset())/total*100); @@ -613,7 +613,7 @@ bool MWState::StateManager::verifyProfile(const ESM::SavedGame& profile) const if (std::find(selectedContentFiles.begin(), selectedContentFiles.end(), *it) == selectedContentFiles.end()) { - std::cerr << "Savegame dependency " << *it << " is missing." << std::endl; + std::cerr << "Warning: Savegame dependency " << *it << " is missing." << std::endl; notFound = true; } } @@ -641,7 +641,7 @@ void MWState::StateManager::writeScreenshot(std::vector &imageData) const osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("jpg"); if (!readerwriter) { - std::cerr << "Unable to write screenshot, can't find a jpg ReaderWriter" << std::endl; + std::cerr << "Error: Unable to write screenshot, can't find a jpg ReaderWriter" << std::endl; return; } @@ -649,7 +649,7 @@ void MWState::StateManager::writeScreenshot(std::vector &imageData) const osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*screenshot, ostream); if (!result.success()) { - std::cerr << "Unable to write screenshot: " << result.message() << " code " << result.status() << std::endl; + std::cerr << "Error: Unable to write screenshot: " << result.message() << " code " << result.status() << std::endl; return; } diff --git a/apps/openmw/mwworld/cellpreloader.cpp b/apps/openmw/mwworld/cellpreloader.cpp index 7b90da43b..278efa53d 100644 --- a/apps/openmw/mwworld/cellpreloader.cpp +++ b/apps/openmw/mwworld/cellpreloader.cpp @@ -209,12 +209,12 @@ namespace MWWorld { if (!mWorkQueue) { - std::cerr << "can't preload, no work queue set " << std::endl; + std::cerr << "Error: can't preload, no work queue set " << std::endl; return; } if (cell->getState() == CellStore::State_Unloaded) { - std::cerr << "can't preload objects for unloaded cell" << std::endl; + std::cerr << "Error: can't preload objects for unloaded cell" << std::endl; return; } diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index 384d7e124..6cd495ee6 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -349,7 +349,7 @@ bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, uint32_t type, catch (...) { // silently drop cells that don't exist anymore - std::cerr << "Dropping state for cell " << state.mId.mWorldspace << " (cell no longer exists)" << std::endl; + std::cerr << "Warning: Dropping state for cell " << state.mId.mWorldspace << " (cell no longer exists)" << std::endl; reader.skipRecord(); return true; } diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 59fa1f5e2..52af21954 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -140,7 +140,7 @@ namespace return; } - std::cerr << "Dropping reference to " << state.mRef.mRefID << " (invalid content file link)" << std::endl; + std::cerr << "Warning: Dropping reference to " << state.mRef.mRefID << " (invalid content file link)" << std::endl; return; } @@ -199,7 +199,7 @@ namespace MWWorld else { std::cerr - << "Error: could not resolve cell reference '" << ref.mRefID << "'" + << "Warning: could not resolve cell reference '" << ref.mRefID << "'" << " (dropping reference)" << std::endl; } } @@ -750,7 +750,7 @@ namespace MWWorld default: std::cerr - << "WARNING: Ignoring reference '" << ref.mRefID << "' of unhandled type\n"; + << "Error: Ignoring reference '" << ref.mRefID << "' of unhandled type\n"; return; } @@ -981,7 +981,7 @@ namespace MWWorld if (!visitor.mFound) { - std::cerr << "Dropping moved ref tag for " << refnum.mIndex << " (moved object no longer exists)" << std::endl; + std::cerr << "Warning: Dropping moved ref tag for " << refnum.mIndex << " (moved object no longer exists)" << std::endl; continue; } @@ -991,7 +991,7 @@ namespace MWWorld if (otherCell == NULL) { - std::cerr << "Dropping moved ref tag for " << movedRef->mRef.getRefId() + std::cerr << "Warning: Dropping moved ref tag for " << movedRef->mRef.getRefId() << " (target cell " << movedTo.mWorldspace << " no longer exists). Reference moved back to its original location." << std::endl; // Note by dropping tag the object will automatically re-appear in its original cell, though potentially at inapproriate coordinates. // Restore original coordinates: diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index a5090a66a..d9fddf7a9 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -496,7 +496,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std:: } catch (const std::exception& e) { - std::cerr << "Error in MWWorld::ContainerStore::addInitialItem: " << e.what() << std::endl; + std::cerr << "Warning: MWWorld::ContainerStore::addInitialItem: " << e.what() << std::endl; } } @@ -796,10 +796,10 @@ void MWWorld::ContainerStore::readState (const ESM::InventoryState& inventory) case ESM::REC_WEAP: readEquipmentState (getState (weapons, state), thisIndex, inventory); break; case ESM::REC_LIGH: readEquipmentState (getState (lights, state), thisIndex, inventory); break; case 0: - std::cerr << "Dropping reference to '" << state.mRef.mRefID << "' (object no longer exists)" << std::endl; + std::cerr << "Warning: Dropping reference to '" << state.mRef.mRefID << "' (object no longer exists)" << std::endl; break; default: - std::cerr << "Invalid item type in inventory state, refid " << state.mRef.mRefID << std::endl; + std::cerr << "Warning: Invalid item type in inventory state, refid " << state.mRef.mRefID << std::endl; break; } } diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index ccde37d60..a0d550f7f 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -857,7 +857,7 @@ void MWWorld::InventoryStore::updateRechargingItems() enchantmentId); if (!enchantment) { - std::cerr << "Can't find enchantment '" << enchantmentId << "' on item " << it->getCellRef().getRefId() << std::endl; + std::cerr << "Warning: Can't find enchantment '" << enchantmentId << "' on item " << it->getCellRef().getRefId() << std::endl; continue; } diff --git a/apps/openmw/mwworld/livecellref.cpp b/apps/openmw/mwworld/livecellref.cpp index 6d138d7e1..66d1c8d70 100644 --- a/apps/openmw/mwworld/livecellref.cpp +++ b/apps/openmw/mwworld/livecellref.cpp @@ -40,7 +40,7 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state) catch (const std::exception& exception) { std::cerr - << "failed to load state for local script " << scriptId + << "Error: failed to load state for local script " << scriptId << " because an exception has been thrown: " << exception.what() << std::endl; } diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index 5f6d10b31..4ed83bf11 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -93,7 +93,7 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) for (std::list >::iterator iter = mScripts.begin(); iter!=mScripts.end(); ++iter) if (iter->second==ptr) { - std::cerr << "warning, tried to add local script twice for " << ptr.getCellRef().getRefId() << std::endl; + std::cerr << "Error: tried to add local script twice for " << ptr.getCellRef().getRefId() << std::endl; remove(ptr); break; } diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index a44d79157..fe13a4d60 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -330,7 +330,7 @@ namespace MWWorld if (!player.mObject.mEnabled) { - std::cerr << "Savegame attempted to disable the player." << std::endl; + std::cerr << "Warning: Savegame attempted to disable the player." << std::endl; player.mObject.mEnabled = true; } @@ -357,7 +357,7 @@ namespace MWWorld } catch (...) { - std::cerr << "Player cell '" << player.mCellId.mWorldspace << "' no longer exists" << std::endl; + std::cerr << "Warning: Player cell '" << player.mCellId.mWorldspace << "' no longer exists" << std::endl; // Cell no longer exists. The loader will have to choose a default cell. mCellStore = NULL; } diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 2c7a86379..b8a362c40 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -152,7 +152,7 @@ namespace } catch (const std::exception& e) { - std::string error ("error during rendering '" + ptr.getCellRef().getRefId() + "': "); + std::string error ("failed to render '" + ptr.getCellRef().getRefId() + "': "); std::cerr << error + e.what() << std::endl; } } @@ -682,7 +682,7 @@ namespace MWWorld } catch (std::exception& e) { - std::cerr << "error during rendering '" << ptr.getCellRef().getRefId() << "': " << e.what() << std::endl; + std::cerr << "failed to render '" << ptr.getCellRef().getRefId() << "': " << e.what() << std::endl; } } diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index cdf66f570..704dbf970 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -687,7 +687,7 @@ namespace MWWorld if (it_lease != wipecell->mLeasedRefs.end()) wipecell->mLeasedRefs.erase(it_lease); else - std::cerr << "can't find " << it->mRefNum.mIndex << " " << it->mRefNum.mContentFile << " in leasedRefs " << std::endl; + std::cerr << "Error: can't find " << it->mRefNum.mIndex << " " << it->mRefNum.mContentFile << " in leasedRefs " << std::endl; } *itold = *it; } diff --git a/components/esm/loaddial.cpp b/components/esm/loaddial.cpp index f06b42250..9ef3d3964 100644 --- a/components/esm/loaddial.cpp +++ b/components/esm/loaddial.cpp @@ -128,7 +128,7 @@ namespace ESM return; } - std::cerr << "Failed to insert info " << info.mId << std::endl; + std::cerr << "Warning: Failed to insert info " << info.mId << std::endl; } void Dialogue::clearDeletedInfos() diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index 70ad0a50b..d1ccbeab5 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -319,7 +319,7 @@ namespace ESMTerrain const ESM::LandTexture* ltex = getLandTexture(id.first-1, id.second); if (!ltex) { - std::cerr << "Unable to find land texture index " << id.first-1 << " in plugin " << id.second << ", using default texture instead" << std::endl; + std::cerr << "Warning: Unable to find land texture index " << id.first-1 << " in plugin " << id.second << ", using default texture instead" << std::endl; return defaultTexture; } diff --git a/components/interpreter/defines.cpp b/components/interpreter/defines.cpp index 912a5e1d9..515c6c7d5 100644 --- a/components/interpreter/defines.cpp +++ b/components/interpreter/defines.cpp @@ -191,7 +191,7 @@ namespace Interpreter{ } catch (std::exception& e) { - std::cerr << "Failed to replace escape character, with the following error: " << e.what() << std::endl; + std::cerr << "Error: Failed to replace escape character, with the following error: " << e.what() << std::endl; std::cerr << "Full text below: " << std::endl << text << std::endl; } diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index cade74147..ff986c1f8 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1364,7 +1364,7 @@ namespace NifOsg size_t mipSize = mip.height * mip.width * pixelData->bpp / 8; if (mipSize + mip.dataOffset > pixelData->data.size()) { - std::cerr << "Internal texture's mipmap data out of bounds" << std::endl; + std::cerr << "Warning: Internal texture's mipmap data out of bounds, ignoring texture" << std::endl; return NULL; } @@ -1379,7 +1379,7 @@ namespace NifOsg if (width <= 0 || height <= 0) { - std::cerr << "Width and height must be non zero " << std::endl; + std::cerr << "Warning: Internal Texture Width and height must be non zero, ignoring texture" << std::endl; return NULL; } @@ -1421,7 +1421,7 @@ namespace NifOsg { // Not used by the vanilla engine. MCP (Morrowind Code Patch) adds an option to use Gloss maps: // "- Gloss map fix. Morrowind removed gloss map entries from model files after loading them. This stops Morrowind from removing them." - std::cerr << "NiTexturingProperty::GlossTexture in " << mFilename << " not currently used." << std::endl; + //std::cerr << "NiTexturingProperty::GlossTexture in " << mFilename << " not currently used." << std::endl; continue; } default: diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index fa0fe0be3..62360b9d6 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -284,7 +284,7 @@ void Emitter::emitParticles(double dt) if (!visitor.mFound) { - std::cerr << "Emitter: Can't find emitter node" << randomRecIndex << std::endl; + std::cerr << "Error: Can't find emitter node" << randomRecIndex << std::endl; return; } diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index d050d5448..698060597 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -1,6 +1,8 @@ #include "scenemanager.hpp" #include +#include + #include #include @@ -434,6 +436,29 @@ namespace Resource return true; } + unsigned int getOptimizationOptions() + { + using namespace SceneUtil; + const char* env = getenv("OPENMW_OPTIMIZE"); + unsigned int options = Optimizer::FLATTEN_STATIC_TRANSFORMS|Optimizer::REMOVE_REDUNDANT_NODES|Optimizer::MERGE_GEOMETRY; + if (env) + { + std::string str(env); + + if(str.find("OFF")!=std::string::npos) options = 0; + + if(str.find("~FLATTEN_STATIC_TRANSFORMS")!=std::string::npos) options ^= Optimizer::FLATTEN_STATIC_TRANSFORMS; + else if(str.find("FLATTEN_STATIC_TRANSFORMS")!=std::string::npos) options |= Optimizer::FLATTEN_STATIC_TRANSFORMS; + + if(str.find("~REMOVE_REDUNDANT_NODES")!=std::string::npos) options ^= Optimizer::REMOVE_REDUNDANT_NODES; + else if(str.find("REMOVE_REDUNDANT_NODES")!=std::string::npos) options |= Optimizer::REMOVE_REDUNDANT_NODES; + + if(str.find("~MERGE_GEOMETRY")!=std::string::npos) options ^= Optimizer::MERGE_GEOMETRY; + else if(str.find("MERGE_GEOMETRY")!=std::string::npos) options |= Optimizer::MERGE_GEOMETRY; + } + return options; + } + osg::ref_ptr SceneManager::getTemplate(const std::string &name) { std::string normalized = name; @@ -500,7 +525,9 @@ namespace Resource SceneUtil::Optimizer optimizer; optimizer.setIsOperationPermissibleForObjectCallback(new CanOptimizeCallback); - optimizer.optimize(loaded, SceneUtil::Optimizer::FLATTEN_STATIC_TRANSFORMS|SceneUtil::Optimizer::REMOVE_REDUNDANT_NODES|SceneUtil::Optimizer::MERGE_GEOMETRY); + static const unsigned int options = getOptimizationOptions(); + + optimizer.optimize(loaded, options); } if (mIncrementalCompileOperation) @@ -613,12 +640,12 @@ namespace Resource if(magfilter == "nearest") mag = osg::Texture::NEAREST; else if(magfilter != "linear") - std::cerr<< "Invalid texture mag filter: "< node = *it; if (node->getNumParents() > 1) - std::cerr << "CopyRigVisitor warning: node has multiple parents" << std::endl; + std::cerr << "Error CopyRigVisitor: node has multiple parents" << std::endl; while (node->getNumParents()) node->getParent(0)->removeChild(node); diff --git a/components/sceneutil/optimizer.cpp b/components/sceneutil/optimizer.cpp index 99f7ae122..b5cee6966 100644 --- a/components/sceneutil/optimizer.cpp +++ b/components/sceneutil/optimizer.cpp @@ -281,11 +281,11 @@ class CollectLowestTransformsVisitor : public BaseOptimizerVisitor ObjectStruct():_canBeApplied(true),_moreThanOneMatrixRequired(false) {} - void add(osg::Transform* transform) + void add(osg::Transform* transform, bool canOptimize) { if (transform) { - if (transform->getDataVariance()!=osg::Transform::STATIC) _moreThanOneMatrixRequired=true; + if (!canOptimize) _moreThanOneMatrixRequired=true; else if (transform->getReferenceFrame()!=osg::Transform::RELATIVE_RF) _moreThanOneMatrixRequired=true; else { @@ -322,7 +322,7 @@ class CollectLowestTransformsVisitor : public BaseOptimizerVisitor itr!=_currentObjectList.end(); ++itr) { - _objectMap[*itr].add(transform); + _objectMap[*itr].add(transform, transform && isOperationPermissibleForObject(transform)); } } @@ -802,8 +802,7 @@ bool Optimizer::RemoveRedundantNodesVisitor::isOperationPermissible(osg::Node& n void Optimizer::RemoveRedundantNodesVisitor::apply(osg::Group& group) { - if (group.getNumChildren()==1 && - typeid(group)==typeid(osg::Group) && + if (typeid(group)==typeid(osg::Group) && isOperationPermissible(group)) { _redundantNodeList.insert(&group); diff --git a/components/sceneutil/riggeometry.cpp b/components/sceneutil/riggeometry.cpp index ba779df3e..9adfdcddb 100644 --- a/components/sceneutil/riggeometry.cpp +++ b/components/sceneutil/riggeometry.cpp @@ -162,13 +162,13 @@ bool RigGeometry::initFromParentSkeleton(osg::NodeVisitor* nv) if (!mSkeleton) { - std::cerr << "A RigGeometry did not find its parent skeleton" << std::endl; + std::cerr << "Error: A RigGeometry did not find its parent skeleton" << std::endl; return false; } if (!mInfluenceMap) { - std::cerr << "No InfluenceMap set on RigGeometry" << std::endl; + std::cerr << "Error: No InfluenceMap set on RigGeometry" << std::endl; return false; } @@ -179,7 +179,7 @@ bool RigGeometry::initFromParentSkeleton(osg::NodeVisitor* nv) Bone* bone = mSkeleton->getBone(it->first); if (!bone) { - std::cerr << "RigGeometry did not find bone " << it->first << std::endl; + std::cerr << "Error: RigGeometry did not find bone " << it->first << std::endl; continue; } @@ -232,7 +232,7 @@ void RigGeometry::update(osg::NodeVisitor* nv) { if (!mSkeleton) { - std::cerr << "RigGeometry rendering with no skeleton, should have been initialized by UpdateVisitor" << std::endl; + std::cerr << "Error: RigGeometry rendering with no skeleton, should have been initialized by UpdateVisitor" << std::endl; // try to recover anyway, though rendering is likely to be incorrect. if (!initFromParentSkeleton(nv)) return; diff --git a/components/sceneutil/skeleton.cpp b/components/sceneutil/skeleton.cpp index f3c2aef77..f7c141e20 100644 --- a/components/sceneutil/skeleton.cpp +++ b/components/sceneutil/skeleton.cpp @@ -128,7 +128,7 @@ void Skeleton::updateBoneMatrices(unsigned int traversalNumber) mRootBone->mChildren[i]->update(NULL); } else - std::cerr << "no root bone" << std::endl; + std::cerr << "Error: no root bone" << std::endl; mNeedToUpdateBoneMatrices = false; } @@ -188,7 +188,7 @@ void Bone::update(const osg::Matrixf* parentMatrixInSkeletonSpace) { if (!mNode) { - std::cerr << "Bone without node " << std::endl; + std::cerr << "Error: Bone without node " << std::endl; return; } if (parentMatrixInSkeletonSpace) diff --git a/components/sceneutil/workqueue.cpp b/components/sceneutil/workqueue.cpp index 831c70a3f..cc40506f0 100644 --- a/components/sceneutil/workqueue.cpp +++ b/components/sceneutil/workqueue.cpp @@ -71,7 +71,7 @@ void WorkQueue::addWorkItem(osg::ref_ptr item, bool front) { if (item->isDone()) { - std::cerr << "warning, trying to add a work item that is already completed" << std::endl; + std::cerr << "Error: trying to add a work item that is already completed" << std::endl; return; }