mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
563f44b823
12 changed files with 90 additions and 34 deletions
|
@ -1363,6 +1363,7 @@ namespace MWRender
|
|||
foundKeyframeCtrl = true;
|
||||
break;
|
||||
}
|
||||
cb = cb->getNestedCallback();
|
||||
}
|
||||
|
||||
if (foundKeyframeCtrl)
|
||||
|
|
|
@ -182,23 +182,30 @@ void WeaponAnimation::deleteControllers()
|
|||
|
||||
void WeaponAnimation::configureControllers(float characterPitchRadians)
|
||||
{
|
||||
if (!mSpineControllers[0])
|
||||
return;
|
||||
|
||||
if (mPitchFactor == 0.f || characterPitchRadians == 0.f)
|
||||
{
|
||||
for (int i=0; i<2; ++i)
|
||||
mSpineControllers[i]->setEnabled(false);
|
||||
setControllerEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
float pitch = characterPitchRadians * mPitchFactor;
|
||||
osg::Quat rotate (pitch/2, osg::Vec3f(-1,0,0));
|
||||
for (int i=0; i<2; ++i)
|
||||
{
|
||||
mSpineControllers[i]->setRotate(rotate);
|
||||
mSpineControllers[i]->setEnabled(true);
|
||||
setControllerRotate(rotate);
|
||||
setControllerEnabled(true);
|
||||
}
|
||||
|
||||
void WeaponAnimation::setControllerRotate(const osg::Quat& rotate)
|
||||
{
|
||||
for (int i=0; i<2; ++i)
|
||||
if (mSpineControllers[i])
|
||||
mSpineControllers[i]->setRotate(rotate);
|
||||
}
|
||||
|
||||
void WeaponAnimation::setControllerEnabled(bool enabled)
|
||||
{
|
||||
for (int i=0; i<2; ++i)
|
||||
if (mSpineControllers[i])
|
||||
mSpineControllers[i]->setEnabled(enabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,6 +52,9 @@ namespace MWRender
|
|||
|
||||
osg::ref_ptr<RotateController> mSpineControllers[2];
|
||||
|
||||
void setControllerRotate(const osg::Quat& rotate);
|
||||
void setControllerEnabled(bool enabled);
|
||||
|
||||
virtual osg::Group* getArrowBone() = 0;
|
||||
virtual osg::Node* getWeaponNode() = 0;
|
||||
virtual Resource::ResourceSystem* getResourceSystem() = 0;
|
||||
|
|
|
@ -2039,7 +2039,7 @@ namespace MWWorld
|
|||
|
||||
bool World::isUnderwater(const MWWorld::CellStore* cell, const osg::Vec3f &pos) const
|
||||
{
|
||||
if (!(cell->getCell()->mData.mFlags & ESM::Cell::HasWater)) {
|
||||
if (!(cell->getCell()->hasWater())) {
|
||||
return false;
|
||||
}
|
||||
return pos.z() < cell->getWaterLevel();
|
||||
|
|
|
@ -141,7 +141,7 @@ struct Cell
|
|||
|
||||
bool hasWater() const
|
||||
{
|
||||
return (mData.mFlags&HasWater) != 0;
|
||||
return ((mData.mFlags&HasWater) != 0) || isExterior();
|
||||
}
|
||||
|
||||
// Restore the given reader to the stored position. Will try to open
|
||||
|
|
|
@ -470,7 +470,7 @@ namespace NifOsg
|
|||
const Nif::NiTextureEffect* textureEffect = static_cast<const Nif::NiTextureEffect*>(nifNode);
|
||||
if (textureEffect->textureType != Nif::NiTextureEffect::Environment_Map)
|
||||
{
|
||||
std::cerr << "Unhandled NiTextureEffect type " << textureEffect->textureType << std::endl;
|
||||
std::cerr << "Unhandled NiTextureEffect type " << textureEffect->textureType << " in " << mFilename << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ namespace NifOsg
|
|||
texGen->setMode(osg::TexGen::SPHERE_MAP);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Unhandled NiTextureEffect coordGenType " << textureEffect->coordGenType << std::endl;
|
||||
std::cerr << "Unhandled NiTextureEffect coordGenType " << textureEffect->coordGenType << " in " << mFilename << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1374,17 +1374,15 @@ namespace NifOsg
|
|||
case Nif::NiTexturingProperty::DarkTexture:
|
||||
case Nif::NiTexturingProperty::BumpTexture:
|
||||
case Nif::NiTexturingProperty::DetailTexture:
|
||||
case Nif::NiTexturingProperty::DecalTexture:
|
||||
break;
|
||||
case Nif::NiTexturingProperty::GlossTexture:
|
||||
{
|
||||
// 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;
|
||||
continue;
|
||||
}
|
||||
case Nif::NiTexturingProperty::DecalTexture:
|
||||
{
|
||||
std::cerr << "NiTexturingProperty::DecalTexture in " << mFilename << " not currently used." << std::endl;
|
||||
continue;
|
||||
}
|
||||
default:
|
||||
{
|
||||
std::cerr << "Warning: unhandled texture stage " << i << " in " << mFilename << std::endl;
|
||||
|
@ -1435,16 +1433,16 @@ namespace NifOsg
|
|||
{
|
||||
osg::TexEnvCombine* texEnv = new osg::TexEnvCombine;
|
||||
texEnv->setScale_RGB(2.f);
|
||||
texEnv->setCombine_Alpha(GL_MODULATE);
|
||||
texEnv->setOperand0_Alpha(GL_SRC_ALPHA);
|
||||
texEnv->setOperand1_Alpha(GL_SRC_ALPHA);
|
||||
texEnv->setSource0_Alpha(GL_PREVIOUS_ARB);
|
||||
texEnv->setSource1_Alpha(GL_TEXTURE);
|
||||
texEnv->setCombine_RGB(GL_MODULATE);
|
||||
texEnv->setOperand0_RGB(GL_SRC_COLOR);
|
||||
texEnv->setOperand1_RGB(GL_SRC_COLOR);
|
||||
texEnv->setSource0_RGB(GL_PREVIOUS_ARB);
|
||||
texEnv->setSource1_RGB(GL_TEXTURE);
|
||||
texEnv->setCombine_Alpha(osg::TexEnvCombine::MODULATE);
|
||||
texEnv->setOperand0_Alpha(osg::TexEnvCombine::SRC_ALPHA);
|
||||
texEnv->setOperand1_Alpha(osg::TexEnvCombine::SRC_ALPHA);
|
||||
texEnv->setSource0_Alpha(osg::TexEnvCombine::PREVIOUS);
|
||||
texEnv->setSource1_Alpha(osg::TexEnvCombine::TEXTURE);
|
||||
texEnv->setCombine_RGB(osg::TexEnvCombine::MODULATE);
|
||||
texEnv->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);
|
||||
texEnv->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR);
|
||||
texEnv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
|
||||
texEnv->setSource1_RGB(osg::TexEnvCombine::TEXTURE);
|
||||
stateset->setTextureAttributeAndModes(texUnit, texEnv, osg::StateAttribute::ON);
|
||||
}
|
||||
else if (i == Nif::NiTexturingProperty::BumpTexture)
|
||||
|
@ -1452,6 +1450,21 @@ namespace NifOsg
|
|||
// Set this texture to Off by default since we can't render it with the fixed-function pipeline
|
||||
stateset->setTextureMode(texUnit, GL_TEXTURE_2D, osg::StateAttribute::OFF);
|
||||
}
|
||||
else if (i == Nif::NiTexturingProperty::DecalTexture)
|
||||
{
|
||||
osg::TexEnvCombine* texEnv = new osg::TexEnvCombine;
|
||||
texEnv->setCombine_RGB(osg::TexEnvCombine::INTERPOLATE);
|
||||
texEnv->setSource0_RGB(osg::TexEnvCombine::TEXTURE);
|
||||
texEnv->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);
|
||||
texEnv->setSource1_RGB(osg::TexEnvCombine::PREVIOUS);
|
||||
texEnv->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR);
|
||||
texEnv->setSource2_RGB(osg::TexEnvCombine::TEXTURE);
|
||||
texEnv->setOperand2_RGB(osg::TexEnvCombine::SRC_ALPHA);
|
||||
texEnv->setCombine_Alpha(osg::TexEnvCombine::REPLACE);
|
||||
texEnv->setSource0_Alpha(osg::TexEnvCombine::PREVIOUS);
|
||||
texEnv->setOperand0_Alpha(osg::TexEnvCombine::SRC_ALPHA);
|
||||
stateset->setTextureAttributeAndModes(texUnit, texEnv, osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
switch (i)
|
||||
{
|
||||
|
@ -1470,6 +1483,9 @@ namespace NifOsg
|
|||
case Nif::NiTexturingProperty::DetailTexture:
|
||||
texture2d->setName("detailMap");
|
||||
break;
|
||||
case Nif::NiTexturingProperty::DecalTexture:
|
||||
texture2d->setName("decalMap");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ namespace Resource
|
|||
|
||||
}
|
||||
|
||||
ResourceManager::~ResourceManager()
|
||||
{
|
||||
}
|
||||
|
||||
void ResourceManager::updateCache(double referenceTime)
|
||||
{
|
||||
mCache->updateTimeStampOfObjectsInCacheWithExternalReferences(referenceTime);
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Resource
|
|||
{
|
||||
public:
|
||||
ResourceManager(const VFS::Manager* vfs);
|
||||
virtual ~ResourceManager();
|
||||
|
||||
/// Clear cache entries that have not been referenced for longer than expiryDelay.
|
||||
virtual void updateCache(double referenceTime);
|
||||
|
|
|
@ -102,9 +102,15 @@ namespace SceneUtil
|
|||
// Need to invert culling because of the negative scale
|
||||
// Note: for absolute correctness we would need to check the current front face for every mesh then invert it
|
||||
// However MW isn't doing this either, so don't. Assuming all meshes are using backface culling is more efficient.
|
||||
static osg::ref_ptr<osg::StateSet> frontFaceStateSet;
|
||||
if (!frontFaceStateSet)
|
||||
{
|
||||
frontFaceStateSet = new osg::StateSet;
|
||||
osg::FrontFace* frontFace = new osg::FrontFace;
|
||||
frontFace->setMode(osg::FrontFace::CLOCKWISE);
|
||||
trans->getOrCreateStateSet()->setAttributeAndModes(frontFace, osg::StateAttribute::ON);
|
||||
frontFaceStateSet->setAttributeAndModes(frontFace, osg::StateAttribute::ON);
|
||||
}
|
||||
trans->setStateSet(frontFaceStateSet);
|
||||
}
|
||||
|
||||
if (trans)
|
||||
|
|
|
@ -88,11 +88,11 @@ namespace Shader
|
|||
return newStateSet.get();
|
||||
}
|
||||
|
||||
const char* defaultTextures[] = { "diffuseMap", "normalMap", "emissiveMap", "darkMap", "detailMap", "envMap", "specularMap" };
|
||||
const char* defaultTextures[] = { "diffuseMap", "normalMap", "emissiveMap", "darkMap", "detailMap", "envMap", "specularMap", "decalMap" };
|
||||
bool isTextureNameRecognized(const std::string& name)
|
||||
{
|
||||
for (unsigned int i=0; i<sizeof(defaultTextures)/sizeof(defaultTextures[0]); ++i)
|
||||
if (name.c_str() == defaultTextures[i])
|
||||
if (name == defaultTextures[i])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,11 @@ uniform sampler2D detailMap;
|
|||
varying vec2 detailMapUV;
|
||||
#endif
|
||||
|
||||
#if @decalMap
|
||||
uniform sampler2D decalMap;
|
||||
varying vec2 decalMapUV;
|
||||
#endif
|
||||
|
||||
#if @emissiveMap
|
||||
uniform sampler2D emissiveMap;
|
||||
varying vec2 emissiveMapUV;
|
||||
|
@ -67,6 +72,11 @@ void main()
|
|||
gl_FragData[0].xyz *= texture2D(darkMap, darkMapUV).xyz;
|
||||
#endif
|
||||
|
||||
#if @decalMap
|
||||
vec4 decalTex = texture2D(decalMap, decalMapUV);
|
||||
gl_FragData[0].xyz = mix(gl_FragData[0].xyz, decalTex.xyz, decalTex.a);
|
||||
#endif
|
||||
|
||||
vec3 viewNormal = passViewNormal;
|
||||
|
||||
#if @normalMap
|
||||
|
|
|
@ -12,6 +12,10 @@ varying vec2 darkMapUV;
|
|||
varying vec2 detailMapUV;
|
||||
#endif
|
||||
|
||||
#if @decalMap
|
||||
varying vec2 decalMapUV;
|
||||
#endif
|
||||
|
||||
#if @emissiveMap
|
||||
varying vec2 emissiveMapUV;
|
||||
#endif
|
||||
|
@ -68,7 +72,11 @@ void main(void)
|
|||
#endif
|
||||
|
||||
#if @detailMap
|
||||
detailMapUV = (gl_TextureMatrix[@detailMap] * gl_MultiTexCoord@detailMap).xy;
|
||||
detailMapUV = (gl_TextureMatrix[@detailMapUV] * gl_MultiTexCoord@detailMapUV).xy;
|
||||
#endif
|
||||
|
||||
#if @decalMap
|
||||
decalMapUV = (gl_TextureMatrix[@decalMapUV] * gl_MultiTexCoord@decalMapUV).xy;
|
||||
#endif
|
||||
|
||||
#if @emissiveMap
|
||||
|
|
Loading…
Reference in a new issue