Skip to content

Commit

Permalink
Use bullet built-in function
Browse files Browse the repository at this point in the history
  • Loading branch information
Benau committed Nov 11, 2016
1 parent 656ddcf commit 6b282ac
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/items/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/modes/three_strikes_battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions src/tracks/track.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,6 @@ class Track

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 ();
Expand Down

0 comments on commit 6b282ac

Please sign in to comment.