Skip to content
Snippets Groups Projects
Unverified Commit 791f7ca3 authored by Alexander Rose's avatar Alexander Rose Committed by GitHub
Browse files

Merge pull request #245 from sukolsak/optimize-setCylinderMat

parents fc2765d3 c14d50e4
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,6 @@ const tmpCylinderCenter = Vec3(); ...@@ -21,7 +21,6 @@ const tmpCylinderCenter = Vec3();
const tmpCylinderMat = Mat4(); const tmpCylinderMat = Mat4();
const tmpCylinderMatRot = Mat4(); const tmpCylinderMatRot = Mat4();
const tmpCylinderScale = Vec3(); const tmpCylinderScale = Vec3();
const tmpCylinderMatScale = Mat4();
const tmpCylinderStart = Vec3(); const tmpCylinderStart = Vec3();
const tmpUp = Vec3(); const tmpUp = Vec3();
...@@ -32,9 +31,9 @@ function setCylinderMat(m: Mat4, start: Vec3, dir: Vec3, length: number, matchDi ...@@ -32,9 +31,9 @@ function setCylinderMat(m: Mat4, start: Vec3, dir: Vec3, length: number, matchDi
// direction so the triangles of adjacent cylinder will line up // direction so the triangles of adjacent cylinder will line up
if (matchDir) Vec3.matchDirection(tmpUp, up, tmpCylinderMatDir); if (matchDir) Vec3.matchDirection(tmpUp, up, tmpCylinderMatDir);
else Vec3.copy(tmpUp, up); else Vec3.copy(tmpUp, up);
Mat4.fromScaling(tmpCylinderMatScale, Vec3.set(tmpCylinderScale, 1, length, 1)); Vec3.set(tmpCylinderScale, 1, length, 1);
Vec3.makeRotation(tmpCylinderMatRot, tmpUp, tmpCylinderMatDir); Vec3.makeRotation(tmpCylinderMatRot, tmpUp, tmpCylinderMatDir);
Mat4.mul(m, tmpCylinderMatRot, tmpCylinderMatScale); Mat4.scale(m, tmpCylinderMatRot, tmpCylinderScale);
return Mat4.setTranslation(m, tmpCylinderCenter); return Mat4.setTranslation(m, tmpCylinderCenter);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment