Merge pull request #183 from H0zen/qfix
Remove rotation matrices from GameObjectModel
This commit is contained in:
commit
f3ae65f581
@ -58,7 +58,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include "Formulas.h"
|
#include "Formulas.h"
|
||||||
#include "G3D/Quat.h" // for turning GO's
|
#include "G3D/Quat.h" // for turning GO's
|
||||||
#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
|
#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
|
||||||
#include "MoveMap.h" // for mmap manager
|
#include "MoveMap.h" // for mmap manager
|
||||||
#include "PathFinder.h" // for mmap commands
|
#include "PathFinder.h" // for mmap commands
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include "GameObjectModel.h"
|
#include "GameObjectModel.h"
|
||||||
#include "DBCStores.h"
|
#include "DBCStores.h"
|
||||||
#include "Creature.h"
|
#include "Creature.h"
|
||||||
#include "G3D/Quat.h"
|
|
||||||
|
|
||||||
struct GameobjectModelData
|
struct GameobjectModelData
|
||||||
{
|
{
|
||||||
@ -136,9 +135,7 @@ bool GameObjectModel::initialize(const GameObject* const pGo, const GameObjectDi
|
|||||||
|
|
||||||
void GameObjectModel::UpdateRotation(G3D::Quat const& q)
|
void GameObjectModel::UpdateRotation(G3D::Quat const& q)
|
||||||
{
|
{
|
||||||
q.toRotationMatrix(iRot);
|
iQuat = q;
|
||||||
|
|
||||||
iInvRot = iRot.inverse();
|
|
||||||
|
|
||||||
G3D::AABox mdl_box(iModelBound);
|
G3D::AABox mdl_box(iModelBound);
|
||||||
|
|
||||||
@ -148,7 +145,7 @@ void GameObjectModel::UpdateRotation(G3D::Quat const& q)
|
|||||||
G3D::AABox rotated_bounds;
|
G3D::AABox rotated_bounds;
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{ rotated_bounds.merge(iRot * mdl_box.corner(i)); }
|
{ rotated_bounds.merge((iQuat * G3D::Quat(mdl_box.corner(i)) * iQuat.conj()).imag()); }
|
||||||
|
|
||||||
iBound = rotated_bounds + iPos;
|
iBound = rotated_bounds + iPos;
|
||||||
}
|
}
|
||||||
@ -179,8 +176,8 @@ bool GameObjectModel::IntersectRay(const G3D::Ray& ray, float& MaxDist, bool Sto
|
|||||||
{ return false; }
|
{ return false; }
|
||||||
|
|
||||||
// child bounds are defined in object space:
|
// child bounds are defined in object space:
|
||||||
Vector3 p = iInvRot * (ray.origin() - iPos) * iInvScale;
|
Vector3 p = (iQuat.conj() * G3D::Quat((ray.origin() - iPos) * iInvScale) * iQuat).imag();
|
||||||
Ray modRay(p, iInvRot * ray.direction());
|
Ray modRay(p, (iQuat.conj() * G3D::Quat(ray.direction()) * iQuat).imag());
|
||||||
float distance = MaxDist * iInvScale;
|
float distance = MaxDist * iInvScale;
|
||||||
bool hit = iModel->IntersectRay(modRay, distance, StopAtFirstHit);
|
bool hit = iModel->IntersectRay(modRay, distance, StopAtFirstHit);
|
||||||
if (hit)
|
if (hit)
|
||||||
@ -195,7 +192,7 @@ bool GameObjectModel::GetIntersectPoint(const G3D::Vector3& srcPoint, G3D::Vecto
|
|||||||
{
|
{
|
||||||
G3D::Vector3 p;
|
G3D::Vector3 p;
|
||||||
if (absolute)
|
if (absolute)
|
||||||
p = iInvRot * (srcPoint - iPos) * iInvScale;
|
p = (iQuat * G3D::Quat((srcPoint - iPos) * iInvScale) * iQuat.conj()).imag();
|
||||||
else
|
else
|
||||||
p = srcPoint;
|
p = srcPoint;
|
||||||
|
|
||||||
@ -218,4 +215,3 @@ void GameObjectModel::GetWorldCoords(const G3D::Vector3& localCoords, G3D::Vecto
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <G3D/Vector3.h>
|
#include <G3D/Vector3.h>
|
||||||
#include <G3D/AABox.h>
|
#include <G3D/AABox.h>
|
||||||
#include <G3D/Ray.h>
|
#include <G3D/Ray.h>
|
||||||
|
#include <G3D/Quat.h>
|
||||||
#include "DBCStructure.h"
|
#include "DBCStructure.h"
|
||||||
#include "GameObject.h"
|
#include "GameObject.h"
|
||||||
|
|
||||||
@ -40,11 +41,6 @@ namespace VMAP
|
|||||||
class WorldModel;
|
class WorldModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace G3D
|
|
||||||
{
|
|
||||||
class Quat;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
@ -52,17 +48,16 @@ namespace G3D
|
|||||||
class GameObjectModel
|
class GameObjectModel
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool isCollidable;
|
bool isCollidable;
|
||||||
|
|
||||||
std::string iName;
|
std::string iName;
|
||||||
G3D::AABox iBound;
|
G3D::AABox iBound;
|
||||||
G3D::AABox iModelBound;
|
G3D::AABox iModelBound;
|
||||||
G3D::Vector3 iPos;
|
G3D::Vector3 iPos;
|
||||||
G3D::Matrix3 iRot;
|
G3D::Quat iQuat; //Note: this must be a unit quaternion!!!
|
||||||
float iScale;
|
|
||||||
|
|
||||||
|
float iScale;
|
||||||
float iInvScale;
|
float iInvScale;
|
||||||
G3D::Matrix3 iInvRot;
|
|
||||||
|
|
||||||
VMAP::WorldModel* iModel;
|
VMAP::WorldModel* iModel;
|
||||||
GameObject const* iOwner;
|
GameObject const* iOwner;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user