Use bullet built-in function

This commit is contained in:
Benau 2016-11-11 10:20:15 +08:00
parent 656ddcfdee
commit 6b282acae2
4 changed files with 3 additions and 11 deletions

View File

@ -43,7 +43,7 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
m_distance_2 = 1.2f;
initItem(type, xyz);
m_original_rotation = Track::createRotationFromNormal(normal);
m_original_rotation = shortestArcQuat(Vec3(0, 1, 0), normal);
m_rotation_angle = 0.0f;
m_original_mesh = mesh;
m_original_lowmesh = lowres_mesh;

View File

@ -711,7 +711,7 @@ void ThreeStrikesBattle::loadCustomModels()
const ArenaNode* n = ag->getNode(node);
btTransform t;
t.setOrigin(n->getCenter());
t.setRotation(Track::createRotationFromNormal(n->getNormal()));
t.setRotation(shortestArcQuat(Vec3(0, 1, 0), n->getNormal()));
pos.push_back(t);
pos_created++;
used.push_back(node);

View File

@ -692,7 +692,7 @@ btQuaternion Track::getArenaStartRotation(const Vec3& xyz, float heading)
}
const Vec3& normal = Graph::get()->getQuad(node)->getNormal();
btQuaternion q = createRotationFromNormal(normal);
btQuaternion q = shortestArcQuat(Vec3(0, 1, 0), normal);
btMatrix3x3 m;
m.setRotation(q);
return btQuaternion(m.getColumn(1), heading * DEGREE_TO_RAD) * q;

View File

@ -392,14 +392,6 @@ public:
static const float NOHIT;
static btQuaternion createRotationFromNormal(const Vec3& normal)
{
Vec3 axis = -normal.cross(Vec3(0, 1, 0));
if (axis.length() == 0)
axis = Vec3(0, 0, 1);
return btQuaternion(axis, normal.angle(Vec3(0, 1, 0)));
} // createRotationFromNormal
Track (const std::string &filename);
~Track ();
void cleanup ();