forked from mirror/openmw-tes3mp
Implement water walking
This commit is contained in:
parent
5b0a4c9424
commit
0f2b2fabdb
1 changed files with 18 additions and 0 deletions
|
@ -577,10 +577,28 @@ namespace MWWorld
|
||||||
|
|
||||||
float oldHeight = iter->first.getRefData().getPosition().pos[2];
|
float oldHeight = iter->first.getRefData().getPosition().pos[2];
|
||||||
|
|
||||||
|
bool waterCollision = false;
|
||||||
|
if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects()
|
||||||
|
.get(ESM::MagicEffect::WaterWalking).mMagnitude
|
||||||
|
&& cell->hasWater()
|
||||||
|
&& !world->isUnderwater(iter->first.getCell(),
|
||||||
|
Ogre::Vector3(iter->first.getRefData().getPosition().pos)))
|
||||||
|
waterCollision = true;
|
||||||
|
|
||||||
|
btStaticPlaneShape planeShape(btVector3(0,0,1), waterlevel);
|
||||||
|
btCollisionObject object;
|
||||||
|
object.setCollisionShape(&planeShape);
|
||||||
|
|
||||||
|
if (waterCollision)
|
||||||
|
mEngine->dynamicsWorld->addCollisionObject(&object);
|
||||||
|
|
||||||
Ogre::Vector3 newpos = MovementSolver::move(iter->first, iter->second, mTimeAccum,
|
Ogre::Vector3 newpos = MovementSolver::move(iter->first, iter->second, mTimeAccum,
|
||||||
world->isFlying(iter->first),
|
world->isFlying(iter->first),
|
||||||
waterlevel, mEngine);
|
waterlevel, mEngine);
|
||||||
|
|
||||||
|
if (waterCollision)
|
||||||
|
mEngine->dynamicsWorld->removeCollisionObject(&object);
|
||||||
|
|
||||||
float heightDiff = newpos.z - oldHeight;
|
float heightDiff = newpos.z - oldHeight;
|
||||||
|
|
||||||
if (heightDiff < 0)
|
if (heightDiff < 0)
|
||||||
|
|
Loading…
Reference in a new issue