mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-18 05:42:40 +00:00
Merge branch 'Embedded-error-marker' into 'master'
Embed marker error See merge request OpenMW/openmw!1383
This commit is contained in:
commit
adc3bab51e
@ -99,6 +99,7 @@
|
|||||||
Feature #6161: Refactor Sky to use shaders and GLES/GL3 friendly
|
Feature #6161: Refactor Sky to use shaders and GLES/GL3 friendly
|
||||||
Feature #6162: Refactor GUI to use shaders and to be GLES and GL3+ friendly
|
Feature #6162: Refactor GUI to use shaders and to be GLES and GL3+ friendly
|
||||||
Feature #6199: Support FBO Rendering
|
Feature #6199: Support FBO Rendering
|
||||||
|
Feature #6248: Embedded error marker mesh
|
||||||
Feature #6249: Alpha testing support for Collada
|
Feature #6249: Alpha testing support for Collada
|
||||||
Feature #6251: OpenMW-CS: Set instance movement based on camera zoom
|
Feature #6251: OpenMW-CS: Set instance movement based on camera zoom
|
||||||
Feature #6288: Preserve the "blocked" record flag for referenceable objects.
|
Feature #6288: Preserve the "blocked" record flag for referenceable objects.
|
||||||
|
@ -37,7 +37,7 @@ add_component_dir (settings
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (bsa
|
add_component_dir (bsa
|
||||||
bsa_file compressedbsafile memorystream
|
bsa_file compressedbsafile
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (vfs
|
add_component_dir (vfs
|
||||||
@ -93,7 +93,7 @@ add_component_dir (esmterrain
|
|||||||
|
|
||||||
add_component_dir (misc
|
add_component_dir (misc
|
||||||
constants utf8stream stringops resourcehelpers rng messageformatparser weakcache thread
|
constants utf8stream stringops resourcehelpers rng messageformatparser weakcache thread
|
||||||
compression osguservalues
|
compression osguservalues errorMarker
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (debug
|
add_component_dir (debug
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
OpenMW - The completely unofficial reimplementation of Morrowind
|
|
||||||
Copyright (C) 2008-2010 Nicolay Korslund
|
|
||||||
Email: < korslund@gmail.com >
|
|
||||||
WWW: http://openmw.sourceforge.net/
|
|
||||||
|
|
||||||
This file (memorystream.cpp) is part of the OpenMW package.
|
|
||||||
|
|
||||||
OpenMW is distributed as free software: you can redistribute it
|
|
||||||
and/or modify it under the terms of the GNU General Public License
|
|
||||||
version 3, as published by the Free Software Foundation.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
version 3 along with this program. If not, see
|
|
||||||
http://www.gnu.org/licenses/ .
|
|
||||||
|
|
||||||
Compressed BSA upgrade added by Azdul 2019
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "memorystream.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Bsa
|
|
||||||
{
|
|
||||||
MemoryInputStreamBuf::MemoryInputStreamBuf(size_t bufferSize) : mBufferPtr(bufferSize)
|
|
||||||
{
|
|
||||||
this->setg(mBufferPtr.data(), mBufferPtr.data(), mBufferPtr.data() + bufferSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* MemoryInputStreamBuf::getRawData() {
|
|
||||||
return mBufferPtr.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryInputStream::MemoryInputStream(size_t bufferSize) :
|
|
||||||
MemoryInputStreamBuf(bufferSize),
|
|
||||||
std::istream(static_cast<std::streambuf*>(this)) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
char* MemoryInputStream::getRawData() {
|
|
||||||
return MemoryInputStreamBuf::getRawData();
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,22 +28,10 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <components/files/memorystream.hpp>
|
||||||
|
|
||||||
namespace Bsa
|
namespace Bsa
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
Class used internally by MemoryInputStream.
|
|
||||||
*/
|
|
||||||
class MemoryInputStreamBuf : public std::streambuf {
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit MemoryInputStreamBuf(size_t bufferSize);
|
|
||||||
virtual char* getRawData();
|
|
||||||
private:
|
|
||||||
//correct call to delete [] on C++ 11
|
|
||||||
std::vector<char> mBufferPtr;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Class replaces Ogre memory streams without introducing any new external dependencies
|
Class replaces Ogre memory streams without introducing any new external dependencies
|
||||||
beyond standard library.
|
beyond standard library.
|
||||||
@ -52,10 +40,18 @@ private:
|
|||||||
|
|
||||||
Memory buffer is freed once the class instance is destroyed.
|
Memory buffer is freed once the class instance is destroyed.
|
||||||
*/
|
*/
|
||||||
class MemoryInputStream : virtual MemoryInputStreamBuf, std::istream {
|
class MemoryInputStream : private std::vector<char>, public virtual Files::MemBuf, public std::istream {
|
||||||
public:
|
public:
|
||||||
explicit MemoryInputStream(size_t bufferSize);
|
explicit MemoryInputStream(size_t bufferSize)
|
||||||
char* getRawData() override;
|
: std::vector<char>(bufferSize)
|
||||||
|
, Files::MemBuf(this->data(), this->size())
|
||||||
|
, std::istream(static_cast<std::streambuf*>(this))
|
||||||
|
{}
|
||||||
|
|
||||||
|
char* getRawData()
|
||||||
|
{
|
||||||
|
return this->data();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
1390
components/misc/errorMarker.cpp
Normal file
1390
components/misc/errorMarker.cpp
Normal file
File diff suppressed because it is too large
Load Diff
11
components/misc/errorMarker.hpp
Normal file
11
components/misc/errorMarker.hpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef OPENMW_COMPONENTS_MISC_ERRORMARKER_H
|
||||||
|
#define OPENMW_COMPONENTS_MISC_ERRORMARKER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Misc
|
||||||
|
{
|
||||||
|
extern const std::string errorMarker;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -21,6 +21,7 @@
|
|||||||
#include <components/misc/pathhelpers.hpp>
|
#include <components/misc/pathhelpers.hpp>
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
#include <components/misc/algorithm.hpp>
|
#include <components/misc/algorithm.hpp>
|
||||||
|
#include <components/misc/errorMarker.hpp>
|
||||||
#include <components/misc/osguservalues.hpp>
|
#include <components/misc/osguservalues.hpp>
|
||||||
|
|
||||||
#include <components/vfs/manager.hpp>
|
#include <components/vfs/manager.hpp>
|
||||||
@ -36,6 +37,7 @@
|
|||||||
#include <components/shader/shadermanager.hpp>
|
#include <components/shader/shadermanager.hpp>
|
||||||
|
|
||||||
#include <components/files/hash.hpp>
|
#include <components/files/hash.hpp>
|
||||||
|
#include <components/files/memorystream.hpp>
|
||||||
|
|
||||||
#include "imagemanager.hpp"
|
#include "imagemanager.hpp"
|
||||||
#include "niffilemanager.hpp"
|
#include "niffilemanager.hpp"
|
||||||
@ -483,13 +485,11 @@ namespace Resource
|
|||||||
Resource::ImageManager* mImageManager;
|
Resource::ImageManager* mImageManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> load (const std::string& normalizedFilename, const VFS::Manager* vfs, Resource::ImageManager* imageManager, Resource::NifFileManager* nifFileManager)
|
namespace
|
||||||
{
|
{
|
||||||
auto ext = Misc::getFileExtension(normalizedFilename);
|
osg::ref_ptr<osg::Node> loadNonNif(const std::string& normalizedFilename, std::istream& model, Resource::ImageManager* imageManager)
|
||||||
if (ext == "nif")
|
|
||||||
return NifOsg::Loader::load(nifFileManager->get(normalizedFilename), imageManager);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
auto ext = Misc::getFileExtension(normalizedFilename);
|
||||||
osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension(std::string(ext));
|
osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension(std::string(ext));
|
||||||
if (!reader)
|
if (!reader)
|
||||||
{
|
{
|
||||||
@ -505,10 +505,9 @@ namespace Resource
|
|||||||
options->setReadFileCallback(new ImageReadCallback(imageManager));
|
options->setReadFileCallback(new ImageReadCallback(imageManager));
|
||||||
if (ext == "dae") options->setOptionString("daeUseSequencedTextureUnits");
|
if (ext == "dae") options->setOptionString("daeUseSequencedTextureUnits");
|
||||||
|
|
||||||
Files::IStreamPtr stream = vfs->get(normalizedFilename);
|
const std::uint64_t fileHash = Files::getHash(normalizedFilename, model);
|
||||||
const std::uint64_t fileHash = Files::getHash(normalizedFilename, *stream);
|
|
||||||
|
|
||||||
osgDB::ReaderWriter::ReadResult result = reader->readNode(*stream, options);
|
osgDB::ReaderWriter::ReadResult result = reader->readNode(model, options);
|
||||||
if (!result.success())
|
if (!result.success())
|
||||||
{
|
{
|
||||||
std::stringstream errormsg;
|
std::stringstream errormsg;
|
||||||
@ -519,7 +518,9 @@ namespace Resource
|
|||||||
// Recognize and hide collision node
|
// Recognize and hide collision node
|
||||||
unsigned int hiddenNodeMask = 0;
|
unsigned int hiddenNodeMask = 0;
|
||||||
SceneUtil::FindByNameVisitor nameFinder("Collision");
|
SceneUtil::FindByNameVisitor nameFinder("Collision");
|
||||||
result.getNode()->accept(nameFinder);
|
|
||||||
|
auto node = result.getNode();
|
||||||
|
node->accept(nameFinder);
|
||||||
if (nameFinder.mFoundNode)
|
if (nameFinder.mFoundNode)
|
||||||
nameFinder.mFoundNode->setNodeMask(hiddenNodeMask);
|
nameFinder.mFoundNode->setNodeMask(hiddenNodeMask);
|
||||||
|
|
||||||
@ -527,16 +528,14 @@ namespace Resource
|
|||||||
{
|
{
|
||||||
// Collada alpha testing
|
// Collada alpha testing
|
||||||
Resource::ColladaAlphaTrickVisitor colladaAlphaTrickVisitor;
|
Resource::ColladaAlphaTrickVisitor colladaAlphaTrickVisitor;
|
||||||
result.getNode()->accept(colladaAlphaTrickVisitor);
|
node->accept(colladaAlphaTrickVisitor);
|
||||||
|
|
||||||
result.getNode()->getOrCreateStateSet()->addUniform(new osg::Uniform("emissiveMult", 1.f));
|
node->getOrCreateStateSet()->addUniform(new osg::Uniform("emissiveMult", 1.f));
|
||||||
result.getNode()->getOrCreateStateSet()->addUniform(new osg::Uniform("specStrength", 1.f));
|
node->getOrCreateStateSet()->addUniform(new osg::Uniform("specStrength", 1.f));
|
||||||
result.getNode()->getOrCreateStateSet()->addUniform(new osg::Uniform("envMapColor", osg::Vec4f(1,1,1,1)));
|
node->getOrCreateStateSet()->addUniform(new osg::Uniform("envMapColor", osg::Vec4f(1,1,1,1)));
|
||||||
result.getNode()->getOrCreateStateSet()->addUniform(new osg::Uniform("useFalloff", false));
|
node->getOrCreateStateSet()->addUniform(new osg::Uniform("useFalloff", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto node = result.getNode();
|
|
||||||
|
|
||||||
node->setUserValue(Misc::OsgUserValues::sFileHash,
|
node->setUserValue(Misc::OsgUserValues::sFileHash,
|
||||||
std::string(reinterpret_cast<const char*>(&fileHash), sizeof(fileHash)));
|
std::string(reinterpret_cast<const char*>(&fileHash), sizeof(fileHash)));
|
||||||
|
|
||||||
@ -544,6 +543,15 @@ namespace Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Node> load (const std::string& normalizedFilename, const VFS::Manager* vfs, Resource::ImageManager* imageManager, Resource::NifFileManager* nifFileManager)
|
||||||
|
{
|
||||||
|
auto ext = Misc::getFileExtension(normalizedFilename);
|
||||||
|
if (ext == "nif")
|
||||||
|
return NifOsg::Loader::load(nifFileManager->get(normalizedFilename), imageManager);
|
||||||
|
else
|
||||||
|
return loadNonNif(normalizedFilename, *vfs->get(normalizedFilename), imageManager);
|
||||||
|
}
|
||||||
|
|
||||||
class CanOptimizeCallback : public SceneUtil::Optimizer::IsOperationPermissibleForObjectCallback
|
class CanOptimizeCallback : public SceneUtil::Optimizer::IsOperationPermissibleForObjectCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -659,23 +667,23 @@ namespace Resource
|
|||||||
{
|
{
|
||||||
loaded = load(normalized, mVFS, mImageManager, mNifFileManager);
|
loaded = load(normalized, mVFS, mImageManager, mNifFileManager);
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", "dae" };
|
static osg::ref_ptr<osg::Node> errorMarkerNode = [&] {
|
||||||
|
static const char* const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", "dae" };
|
||||||
|
|
||||||
for (unsigned int i=0; i<sizeof(sMeshTypes)/sizeof(sMeshTypes[0]); ++i)
|
for (unsigned int i=0; i<sizeof(sMeshTypes)/sizeof(sMeshTypes[0]); ++i)
|
||||||
{
|
|
||||||
normalized = "meshes/marker_error." + std::string(sMeshTypes[i]);
|
|
||||||
if (mVFS->exists(normalized))
|
|
||||||
{
|
{
|
||||||
Log(Debug::Error) << "Failed to load '" << name << "': " << e.what() << ", using marker_error." << sMeshTypes[i] << " instead";
|
normalized = "meshes/marker_error." + std::string(sMeshTypes[i]);
|
||||||
loaded = load(normalized, mVFS, mImageManager, mNifFileManager);
|
if (mVFS->exists(normalized))
|
||||||
break;
|
return load(normalized, mVFS, mImageManager, mNifFileManager);
|
||||||
}
|
}
|
||||||
}
|
Files::IMemStream file(Misc::errorMarker.data(), Misc::errorMarker.size());
|
||||||
|
return loadNonNif("error_marker.osgt", file, mImageManager);
|
||||||
|
}();
|
||||||
|
|
||||||
if (!loaded)
|
Log(Debug::Error) << "Failed to load '" << name << "': " << e.what() << ", using marker_error instead";
|
||||||
throw;
|
loaded = static_cast<osg::Node*>(errorMarkerNode->clone(osg::CopyOp::DEEP_COPY_ALL));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set filtering settings
|
// set filtering settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user