General perfomance optimizations.

actorid
megaton 11 years ago
parent d04bb3befb
commit 50af9bc0d3

@ -196,9 +196,8 @@ namespace MWMechanics
{
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 >= 90 && d <= 2000)
|| (fight >= 80 && d <= 1000)
@ -206,12 +205,17 @@ namespace MWMechanics
|| (fight >= 70 && disp <= 35 && d <= 1000)
|| (fight >= 60 && disp <= 30 && d <= 1000)
|| (fight >= 50 && disp == 0)
|| (fight >= 40 && disp <= 10 && d <= 500) )
&& LOS
|| (fight >= 40 && disp <= 10 && d <= 500)
)
{
creatureStats.getAiSequence().stack(AiCombat(MWBase::Environment::get().getWorld()->getPlayerPtr()));
creatureStats.setHostile(true);
bool LOS = MWBase::Environment::get().getWorld()->getLOS(ptr,player)
&& 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");
if (!tex.isNull())
{
std::map <std::string, std::vector<Ogre::uint32> >::iterator anIter;
// 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;
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))
+ Math::Sqr((texV + my*(sFogOfWarResolution-1)) - v*(sFogOfWarResolution-1));
uint32 clr = mBuffers[texName][i];
uint32 clr = aBuffer[i];
uint8 alpha = (clr >> 24);
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;
}
}
// 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();
}
}

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

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

Loading…
Cancel
Save