소스 검색

SplineMesh: fix mesh that were broken when rotated

lviguier 3 달 전
부모
커밋
7043aaca19
1개의 변경된 파일4개의 추가작업 그리고 5개의 파일을 삭제
  1. 4 5
      hrt/prefab/l3d/SplineMesh.hx

+ 4 - 5
hrt/prefab/l3d/SplineMesh.hx

@@ -202,13 +202,12 @@ class SplineMesh extends hrt.prefab.Object3D {
 				var absPos = spline.globalToLocal(samples[i].pos);
 				var curPos = absPos.clone();
 				uv += curPos.distance(prevPos);
-				var tangent = samples[i].tangentOut.normalized();
-				var angle = hxd.Math.acos( tangent.dot(new h3d.Vector(1.0, 0.0, 0.0)) );
-				if (tangent.dot(new h3d.Vector(0.0, 1.0, 0.0)) < 0.0)
-					angle *= -1.0;
+				var tangent = samples[i].tangentOut.transformed3x3(spline.getAbsPos(true).getInverse()).normalized();
+				var q = new h3d.Quat();
+				q.initDirection(tangent);
 				var trs = new h3d.Matrix();
 				trs.initTranslation(0.0, spacing, 0.0);
-				trs.rotateAxis(new h3d.Vector(0.0, 0.0, 1.0), angle);
+				trs.rotate(q.toEuler().x, q.toEuler().y, q.toEuler().z);
 				trs.translate(absPos.x, absPos.y, absPos.z);
 				fillPoint(vertexData, dataPos, localPoints, trs, uv, bounds);
 				dataPos += vertexDataStride * vertexPerPoint;