forked from teamnwah/openmw-tes3coop
Merge remote branch 'greye/cross_cell-borders'
This commit is contained in:
commit
766e782aae
7 changed files with 48 additions and 22 deletions
|
@ -27,10 +27,10 @@ namespace MWRender
|
|||
// we are only interested in X and Y rotation
|
||||
|
||||
// Rotate around X axis
|
||||
Ogre::Quaternion xr(Ogre::Degree(rot.x), Ogre::Vector3::UNIT_X);
|
||||
Ogre::Quaternion xr(Ogre::Radian(rot.x), Ogre::Vector3::UNIT_X);
|
||||
|
||||
// Rotate around Y axis
|
||||
Ogre::Quaternion yr(Ogre::Degree(-rot.z), Ogre::Vector3::UNIT_Y);
|
||||
Ogre::Quaternion yr(Ogre::Radian(-rot.z), Ogre::Vector3::UNIT_Y);
|
||||
|
||||
pitchNode->setOrientation(xr);
|
||||
yawNode->setOrientation(yr);
|
||||
|
@ -56,8 +56,8 @@ namespace MWRender
|
|||
Ogre::SceneNode *pitchNode = mCamera->getParentSceneNode();
|
||||
Ogre::SceneNode *yawNode = pitchNode->getParentSceneNode();
|
||||
|
||||
pitchNode->pitch(Ogre::Degree(rot.x));
|
||||
yawNode->yaw(Ogre::Degree(-rot.z));
|
||||
pitchNode->pitch(Ogre::Radian(rot.x));
|
||||
yawNode->yaw(Ogre::Radian(-rot.z));
|
||||
|
||||
controlFlip();
|
||||
updateListener();
|
||||
|
|
|
@ -28,6 +28,8 @@ namespace MWRender
|
|||
bool mVanityModeEnabled;
|
||||
|
||||
void controlFlip();
|
||||
|
||||
/// Updates sound manager listener data
|
||||
void updateListener();
|
||||
|
||||
public:
|
||||
|
@ -35,11 +37,19 @@ namespace MWRender
|
|||
Player (Ogre::Camera *camera, Ogre::SceneNode* mNode);
|
||||
|
||||
/// Set where the player is looking at. Uses Morrowind (euler) angles
|
||||
/// \param rot Rotation angles in radians
|
||||
/// \return true if player object needs to bo rotated physically
|
||||
bool setRotation(const Ogre::Vector3 &rot);
|
||||
|
||||
/// \param rot Rotation angles in radians
|
||||
/// \return true if player object needs to bo rotated physically
|
||||
bool adjustRotation(const Ogre::Vector3 &rot);
|
||||
|
||||
std::string getHandle() const;
|
||||
|
||||
/// Attach camera to object
|
||||
/// \note there is no protection from attaching the same camera to
|
||||
/// several different objects
|
||||
void attachTo(const MWWorld::Ptr &);
|
||||
|
||||
void toggleViewMode() {
|
||||
|
|
|
@ -254,27 +254,31 @@ RenderingManager::rotateObject(
|
|||
Ogre::Vector3 &rot,
|
||||
bool adjust)
|
||||
{
|
||||
if (ptr.getRefData().getHandle() == "player") {
|
||||
bool isPlayer = ptr.getRefData().getHandle() == "player";
|
||||
bool force = true;
|
||||
|
||||
if (isPlayer) {
|
||||
if (adjust) {
|
||||
return mPlayer->adjustRotation(rot);
|
||||
force = mPlayer->adjustRotation(rot);
|
||||
} else {
|
||||
return mPlayer->setRotation(rot);
|
||||
force = mPlayer->setRotation(rot);
|
||||
}
|
||||
}
|
||||
MWWorld::Class::get(ptr).adjustRotation(ptr, rot.x, rot.y, rot.z);
|
||||
|
||||
if (adjust) {
|
||||
/// \note Stored and passed in radians
|
||||
float *f = ptr.getRefData().getPosition().rot;
|
||||
rot.x += f[0], rot.y += f[1], rot.z += f[2];
|
||||
}
|
||||
if (!isPlayer) {
|
||||
Ogre::Quaternion xr(Ogre::Radian(rot.x), Ogre::Vector3::UNIT_X);
|
||||
Ogre::Quaternion yr(Ogre::Radian(rot.y), Ogre::Vector3::UNIT_Y);
|
||||
Ogre::Quaternion zr(Ogre::Radian(rot.z), Ogre::Vector3::UNIT_Z);
|
||||
|
||||
Ogre::Quaternion xr(Ogre::Degree(rot.x), Ogre::Vector3::UNIT_X);
|
||||
Ogre::Quaternion yr(Ogre::Degree(rot.y), Ogre::Vector3::UNIT_Y);
|
||||
Ogre::Quaternion zr(Ogre::Degree(rot.z), Ogre::Vector3::UNIT_Z);
|
||||
|
||||
ptr.getRefData().getBaseNode()->setOrientation(xr * yr * zr);
|
||||
|
||||
return true;
|
||||
ptr.getRefData().getBaseNode()->setOrientation(xr * yr * zr);
|
||||
}
|
||||
return force;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -85,6 +85,11 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
|||
|
||||
void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position);
|
||||
void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale);
|
||||
|
||||
/// Rotates object accordingly to its type
|
||||
/// \param rot euler angles in radians
|
||||
/// \param adjust indicates should rotation be set or adjusted
|
||||
/// \return true if object needs to be rotated physically
|
||||
bool rotateObject (const MWWorld::Ptr& ptr, Ogre::Vector3 &rot, bool adjust = false);
|
||||
|
||||
void setWaterHeight(const float height);
|
||||
|
|
|
@ -140,19 +140,22 @@ namespace MWWorld
|
|||
const ESM::Position& pos,
|
||||
bool adjustPlayerPos)
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->getPlayer().setCell (cell);
|
||||
|
||||
bool hasWater = cell->cell->data.flags & cell->cell->HasWater;
|
||||
mPhysics->setCurrentWater(hasWater, cell->cell->water);
|
||||
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
world->getPlayer().setCell(cell);
|
||||
|
||||
MWWorld::Ptr player = world->getPlayer().getPlayer();
|
||||
|
||||
if (adjustPlayerPos) {
|
||||
world->moveObject(player, pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
world->rotateObject(player, pos.rot[0], pos.rot[1], pos.rot[2]);
|
||||
|
||||
float x = Ogre::Radian(pos.rot[0]).valueDegrees();
|
||||
float y = Ogre::Radian(pos.rot[1]).valueDegrees();
|
||||
float z = Ogre::Radian(pos.rot[2]).valueDegrees();
|
||||
world->rotateObject(player, x, y, z);
|
||||
}
|
||||
world->getPlayer().setCell(cell);
|
||||
|
||||
MWMechanics::MechanicsManager *mechMgr =
|
||||
MWBase::Environment::get().getMechanicsManager();
|
||||
|
|
|
@ -629,12 +629,14 @@ namespace MWWorld
|
|||
|
||||
void World::rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust)
|
||||
{
|
||||
Ogre::Vector3 rot(x, y, z);
|
||||
Ogre::Vector3 rot;
|
||||
rot.x = Ogre::Degree(x).valueRadians();
|
||||
rot.y = Ogre::Degree(y).valueRadians();
|
||||
rot.z = Ogre::Degree(z).valueRadians();
|
||||
|
||||
if (mRendering->rotateObject(ptr, rot, adjust)) {
|
||||
float *objRot = ptr.getRefData().getPosition().rot;
|
||||
objRot[0] = Ogre::Degree(rot.x).valueRadians();
|
||||
objRot[1] = Ogre::Degree(rot.y).valueRadians();
|
||||
objRot[2] = Ogre::Degree(rot.z).valueRadians();
|
||||
objRot[0] = rot.x, objRot[1] = rot.y, objRot[2] = rot.z;
|
||||
|
||||
mPhysics->rotateObject(
|
||||
ptr.getRefData().getHandle(),
|
||||
|
|
|
@ -210,6 +210,8 @@ namespace MWWorld
|
|||
|
||||
virtual void scaleObject (const Ptr& ptr, float scale);
|
||||
|
||||
/// Rotates object, uses degrees
|
||||
/// \param adjust indicates rotation should be set or adjusted
|
||||
virtual void rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust = false);
|
||||
|
||||
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
|
||||
|
|
Loading…
Reference in a new issue