// Update is called once per frame void FixedUpdate() { // Check if control points changed List <Vector4> pointsNew = Convert_Vec3_toVec4(FromGO_toVectorList(CPList)); bool pointsChanged = false; for (int i = 0; i < pointsNew.Count; i++) { pointsChanged = points[i] != pointsNew[i]; if (pointsChanged == true) { points = pointsNew; break; } } Vector4 delta14 = GetDelta(points[1], points[4]); Vector4 delta12 = GetDelta(points[1], points[2]); Vector4 delta34 = GetDelta(points[3], points[4]); Vector4 delta32 = GetDelta(points[3], points[2]); Vector4 delta41 = GetDelta(points[4], points[1]); Vector4 delta43 = GetDelta(points[4], points[3]); Vector4 delta10 = GetDelta(points[1], points[0]); Vector4 delta30 = GetDelta(points[3], points[0]); weights[1] = GenerateWeight(-9.0f, -3.0f, 9.0f, -1.0f, delta14, delta12, delta34, delta32, delta41, delta10, delta43, delta30); weights[2] = GenerateWeight(-1.0f, -3.0f, -3.0f, -1.0f, delta12, delta14, delta32, delta34, delta12, delta10, delta32, delta30); curve = GenerateCurve(); LM.UpdateCurve(Convert_Vec4_toVec3(curve)); }
// Update is called once per frame void FixedUpdate() { // Check if control points changed List <Vector4> pointsNew = Convert_Vec3_toVec4(FromGO_toVectorList(CPList)); bool pointsChanged = false; for (int i = 0; i < pointsNew.Count; i++) { pointsChanged = points[i] != pointsNew[i]; if (pointsChanged == true) { points = pointsNew; break; } } bool vecChanged = false; List <Vector4> vectorsNew = Convert_Vec3_toVec4(FromGO_toVectorList(VecPointers)); vecChanged = (vectorsNew[0] != vectors[0]) || (vectorsNew[1] != vectors[1]); if (vecChanged) { vectors = vectorsNew; } if (pointsChanged || vecChanged) { vecRot1 = vectors[0] - points[0]; vecRot2 = vectors[1] - points.Last(); Quaternion rotation = Quaternion.LookRotation(vecRot1); begVectorArrow.transform.rotation = rotation; begVectorArrow.transform.position = points[0]; rotation = Quaternion.LookRotation(vecRot2); endVectorArrow.transform.rotation = rotation; endVectorArrow.transform.position = points.Last(); Vector4 delta40 = GetDelta(points[2], points[0]); Vector4 delta20 = GetDelta(points[1], points[0]); Vector4 delta24 = GetDelta(points[1], points[2]); weights[1] = GenerateWeight(-8.0f, -2.0f, 16.0f, -1.0f, delta40, delta20, vectors[1], delta24, delta40, vectors[0], vectors[1], delta40); weights[2] = GenerateWeight(-1.0f, -4.0f, 4.0f, 1.0f, delta20, delta40, delta24, vectors[1], delta20, vectors[0], delta24, delta40); curve = GenerateCurve(); LM.UpdateCurve(Convert_Vec4_toVec3(curve)); } }