Merge remote-tracking branch 'megaton/master'

actorid
Marc Zinnschlag 11 years ago
commit 12e46c5dc7

@ -196,9 +196,8 @@ namespace MWMechanics
{ {
disp = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(ptr); disp = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(ptr);
} }
bool LOS = MWBase::Environment::get().getWorld()->getLOS(ptr,player)
&& MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, ptr); if( (fight == 100 )
if( ( (fight == 100 )
|| (fight >= 95 && d <= 3000) || (fight >= 95 && d <= 3000)
|| (fight >= 90 && d <= 2000) || (fight >= 90 && d <= 2000)
|| (fight >= 80 && d <= 1000) || (fight >= 80 && d <= 1000)
@ -206,12 +205,17 @@ namespace MWMechanics
|| (fight >= 70 && disp <= 35 && d <= 1000) || (fight >= 70 && disp <= 35 && d <= 1000)
|| (fight >= 60 && disp <= 30 && d <= 1000) || (fight >= 60 && disp <= 30 && d <= 1000)
|| (fight >= 50 && disp == 0) || (fight >= 50 && disp == 0)
|| (fight >= 40 && disp <= 10 && d <= 500) ) || (fight >= 40 && disp <= 10 && d <= 500)
&& LOS
) )
{ {
creatureStats.getAiSequence().stack(AiCombat(MWBase::Environment::get().getWorld()->getPlayerPtr())); bool LOS = MWBase::Environment::get().getWorld()->getLOS(ptr,player)
creatureStats.setHostile(true); && MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, ptr);
if (LOS)
{
creatureStats.getAiSequence().stack(AiCombat(MWBase::Environment::get().getWorld()->getPlayerPtr()));
creatureStats.setHostile(true);
}
} }
} }

@ -390,8 +390,13 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
TexturePtr tex = TextureManager::getSingleton().getByName(texName+"_fog"); TexturePtr tex = TextureManager::getSingleton().getByName(texName+"_fog");
if (!tex.isNull()) if (!tex.isNull())
{ {
std::map <std::string, std::vector<Ogre::uint32> >::iterator anIter;
// get its buffer // get its buffer
if (mBuffers.find(texName) == mBuffers.end()) return; anIter = mBuffers.find(texName);
if (anIter == mBuffers.end()) return;
std::vector<Ogre::uint32>& aBuffer = (*anIter).second;
int i=0; int i=0;
for (int texV = 0; texV<sFogOfWarResolution; ++texV) for (int texV = 0; texV<sFogOfWarResolution; ++texV)
{ {
@ -399,17 +404,17 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
{ {
float sqrDist = Math::Sqr((texU + mx*(sFogOfWarResolution-1)) - u*(sFogOfWarResolution-1)) float sqrDist = Math::Sqr((texU + mx*(sFogOfWarResolution-1)) - u*(sFogOfWarResolution-1))
+ Math::Sqr((texV + my*(sFogOfWarResolution-1)) - v*(sFogOfWarResolution-1)); + Math::Sqr((texV + my*(sFogOfWarResolution-1)) - v*(sFogOfWarResolution-1));
uint32 clr = mBuffers[texName][i]; uint32 clr = aBuffer[i];
uint8 alpha = (clr >> 24); uint8 alpha = (clr >> 24);
alpha = std::min( alpha, (uint8) (std::max(0.f, std::min(1.f, (sqrDist/sqrExploreRadius)))*255) ); alpha = std::min( alpha, (uint8) (std::max(0.f, std::min(1.f, (sqrDist/sqrExploreRadius)))*255) );
mBuffers[texName][i] = (uint32) (alpha << 24); aBuffer[i] = (uint32) (alpha << 24);
++i; ++i;
} }
} }
// copy to the texture // copy to the texture
memcpy(tex->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &mBuffers[texName][0], sFogOfWarResolution*sFogOfWarResolution*4); memcpy(tex->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &aBuffer[0], sFogOfWarResolution*sFogOfWarResolution*4);
tex->getBuffer()->unlock(); tex->getBuffer()->unlock();
} }
} }

@ -18,16 +18,21 @@ namespace NifOgre
if(time <= keys.front().mTime) if(time <= keys.front().mTime)
return keys.front().mValue; return keys.front().mValue;
Nif::FloatKeyList::VecType::const_iterator iter(keys.begin()+1); const Nif::FloatKey* keyArray = keys.data();
for(;iter != keys.end();iter++) size_t size = keys.size();
for (size_t i = 1; i < size; ++i)
{ {
if(iter->mTime < time) const Nif::FloatKey* aKey = &keyArray[i];
if(aKey->mTime < time)
continue; continue;
Nif::FloatKeyList::VecType::const_iterator last(iter-1); const Nif::FloatKey* aLastKey = &keyArray[i-1];
float a = (time-last->mTime) / (iter->mTime-last->mTime); float a = (time - aLastKey->mTime) / (aKey->mTime - aLastKey->mTime);
return last->mValue + ((iter->mValue - last->mValue)*a); return aLastKey->mValue + ((aKey->mValue - aLastKey->mValue) * a);
} }
return keys.back().mValue; return keys.back().mValue;
} }
@ -36,16 +41,21 @@ namespace NifOgre
if(time <= keys.front().mTime) if(time <= keys.front().mTime)
return keys.front().mValue; return keys.front().mValue;
Nif::Vector3KeyList::VecType::const_iterator iter(keys.begin()+1); const Nif::Vector3Key* keyArray = keys.data();
for(;iter != keys.end();iter++) size_t size = keys.size();
for (size_t i = 1; i < size; ++i)
{ {
if(iter->mTime < time) const Nif::Vector3Key* aKey = &keyArray[i];
if(aKey->mTime < time)
continue; continue;
Nif::Vector3KeyList::VecType::const_iterator last(iter-1); const Nif::Vector3Key* aLastKey = &keyArray[i-1];
float a = (time-last->mTime) / (iter->mTime-last->mTime); float a = (time - aLastKey->mTime) / (aKey->mTime - aLastKey->mTime);
return last->mValue + ((iter->mValue - last->mValue)*a); return aLastKey->mValue + ((aKey->mValue - aLastKey->mValue) * a);
} }
return keys.back().mValue; return keys.back().mValue;
} }
}; };

@ -385,16 +385,21 @@ public:
if(time <= keys.front().mTime) if(time <= keys.front().mTime)
return keys.front().mValue; return keys.front().mValue;
Nif::QuaternionKeyList::VecType::const_iterator iter(keys.begin()+1); const Nif::QuaternionKey* keyArray = keys.data();
for(;iter != keys.end();iter++) size_t size = keys.size();
for (size_t i = 1; i < size; ++i)
{ {
if(iter->mTime < time) const Nif::QuaternionKey* aKey = &keyArray[i];
if(aKey->mTime < time)
continue; continue;
Nif::QuaternionKeyList::VecType::const_iterator last(iter-1); const Nif::QuaternionKey* aLastKey = &keyArray[i-1];
float a = (time-last->mTime) / (iter->mTime-last->mTime); float a = (time - aLastKey->mTime) / (aKey->mTime - aLastKey->mTime);
return Ogre::Quaternion::nlerp(a, last->mValue, iter->mValue); return Ogre::Quaternion::nlerp(a, aLastKey->mValue, aKey->mValue);
} }
return keys.back().mValue; return keys.back().mValue;
} }

Loading…
Cancel
Save