public void MultithreadTransformBasis(object newThisToVesselMatrixObj)
        {
            lock (this)
            {
                try
                {
                    Matrix4x4 tempMatrix = thisToVesselMatrix.inverse;

                    thisToVesselMatrix = (Matrix4x4)newThisToVesselMatrixObj * meshLocalToWorld;

                    tempMatrix = thisToVesselMatrix * tempMatrix;

                    bounds = TransformBounds(bounds, tempMatrix);

                    for (int i = 0; i < vertices.Length; i++)
                    {
                        //vertices[i] = tempMatrix.MultiplyPoint3x4(vertices[i]);
                        Vector3 v    = vertices[i];
                        Vector3 vert = Vector3.zero;
                        vert.x = tempMatrix.m00 * v.x + tempMatrix.m01 * v.y + tempMatrix.m02 * v.z + tempMatrix.m03;
                        vert.y = tempMatrix.m10 * v.x + tempMatrix.m11 * v.y + tempMatrix.m12 * v.z + tempMatrix.m13;
                        vert.z = tempMatrix.m20 * v.x + tempMatrix.m21 * v.y + tempMatrix.m22 * v.z + tempMatrix.m23;

                        vertices[i] = vert;
                    }

                    module.DecrementMeshesToUpdate();
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
        }
Beispiel #2
0
        public void TransformBasis(Matrix4x4 newThisToVesselMatrix)
        {
            Matrix4x4 tempMatrix = newThisToVesselMatrix * meshLocalToWorld;
            //Matrix4x4 tempMatrix = thisToVesselMatrix.inverse;
            //thisToVesselMatrix = newThisToVesselMatrix * meshLocalToWorld;

            //tempMatrix = thisToVesselMatrix * tempMatrix;

            //bounds = TransformBounds(bounds, tempMatrix);

            Vector3 low, high;

            low  = Vector3.one * float.PositiveInfinity;
            high = Vector3.one * float.NegativeInfinity;

            for (int i = 0; i < vertices.Length; i++)
            {
                Vector3 vert = tempMatrix.MultiplyPoint3x4(meshLocalVerts[i]);// = Vector3.zero;

                float tmpTestVert = vert.x + vert.y + vert.z;
                if (float.IsNaN(tmpTestVert) || float.IsInfinity(tmpTestVert))
                {
                    ThreadSafeDebugLogger.Instance.RegisterMessage("Transform error in " + module.part.partInfo.title);
                    valid = false;
                }
                else
                {
                    valid = true;
                }

                vertices[i] = vert;
                low         = Vector3.Min(low, vert);
                high        = Vector3.Max(high, vert);
            }

            bounds = new Bounds(0.5f * (high + low), high - low);
            module.DecrementMeshesToUpdate();
        }
Beispiel #3
0
        public void MultithreadTransformBasis(object newThisToVesselMatrixObj)
        {
            lock (this)
            {
                try
                {
                    Matrix4x4 tempMatrix = (Matrix4x4)newThisToVesselMatrixObj * meshLocalToWorld;
                    //Matrix4x4 tempMatrix = thisToVesselMatrix.inverse;
                    //thisToVesselMatrix = (Matrix4x4)newThisToVesselMatrixObj * meshLocalToWorld;

                    //tempMatrix = thisToVesselMatrix * tempMatrix;

                    Vector3 low, high;
                    low  = Vector3.one * float.PositiveInfinity;
                    high = Vector3.one * float.NegativeInfinity;

                    for (int i = 0; i < vertices.Length; i++)
                    {
                        //vertices[i] = tempMatrix.MultiplyPoint3x4(vertices[i]);
                        //Vector3 v = meshLocalVerts[i];
                        Vector3 vert = tempMatrix.MultiplyPoint3x4(meshLocalVerts[i]);// = Vector3.zero;

                        /*vert.x = tempMatrix.m00 * v.x + tempMatrix.m01 * v.y + tempMatrix.m02 * v.z + tempMatrix.m03;
                        *  vert.y = tempMatrix.m10 * v.x + tempMatrix.m11 * v.y + tempMatrix.m12 * v.z + tempMatrix.m13;
                        *  vert.z = tempMatrix.m20 * v.x + tempMatrix.m21 * v.y + tempMatrix.m22 * v.z + tempMatrix.m23;*/

                        float tmpTestVert = vert.x + vert.y + vert.z;
                        if (float.IsNaN(tmpTestVert) || float.IsInfinity(tmpTestVert))
                        {
                            ThreadSafeDebugLogger.Instance.RegisterMessage("Transform error in " + module.part.partInfo.title);
                        }

                        vertices[i] = vert;
                        low         = Vector3.Min(low, vert);
                        high        = Vector3.Max(high, vert);
                    }

                    bounds = new Bounds(0.5f * (high + low), high - low);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
                finally
                {
                    module.DecrementMeshesToUpdate();
                }
            }
        }
        public void TransformBasis(Matrix4x4 newThisToVesselMatrix)
        {
            try
            {
                // ReSharper disable once InconsistentlySynchronizedField
                Matrix4x4 tempMatrix = newThisToVesselMatrix * meshLocalToWorld;

                Vector3 low  = Vector3.one * float.PositiveInfinity;
                Vector3 high = Vector3.one * float.NegativeInfinity;

                for (int i = 0; i < vertices.Length; i++)
                {
                    Vector3 vert = tempMatrix.MultiplyPoint3x4(meshLocalVerts[i]);

                    float tmpTestVert = vert.x + vert.y + vert.z;
                    if (float.IsNaN(tmpTestVert) || float.IsInfinity(tmpTestVert))
                    {
                        ThreadSafeDebugLogger.Instance.RegisterMessage("Transform error in " +
                                                                       module.part.partInfo.title);
                        valid = false;
                    }
                    else
                    {
                        valid = true;
                    }

                    vertices[i] = vert;
                    low         = Vector3.Min(low, vert);
                    high        = Vector3.Max(high, vert);
                }

                bounds = new Bounds(0.5f * (high + low), high - low);
            }
            catch (Exception e)
            {
                FARLogger.Exception(e);
            }
            finally
            {
                module.DecrementMeshesToUpdate();
            }
        }
Beispiel #5
0
        public void MultithreadTransformBasis(object newThisToVesselMatrixObj)
        {
            lock (this)
            {
                try
                {
                    Matrix4x4 tempMatrix = thisToVesselMatrix.inverse;
                    thisToVesselMatrix = (Matrix4x4)newThisToVesselMatrixObj * meshLocalToWorld;

                    tempMatrix = thisToVesselMatrix * tempMatrix;

                    Vector3 low, high;
                    low  = Vector3.one * float.PositiveInfinity;
                    high = Vector3.one * float.NegativeInfinity;

                    for (int i = 0; i < vertices.Length; i++)
                    {
                        //vertices[i] = tempMatrix.MultiplyPoint3x4(vertices[i]);
                        Vector3 v    = vertices[i];
                        Vector3 vert = Vector3.zero;
                        vert.x = tempMatrix.m00 * v.x + tempMatrix.m01 * v.y + tempMatrix.m02 * v.z + tempMatrix.m03;
                        vert.y = tempMatrix.m10 * v.x + tempMatrix.m11 * v.y + tempMatrix.m12 * v.z + tempMatrix.m13;
                        vert.z = tempMatrix.m20 * v.x + tempMatrix.m21 * v.y + tempMatrix.m22 * v.z + tempMatrix.m23;

                        vertices[i] = vert;
                        low         = Vector3.Min(low, vert);
                        high        = Vector3.Max(high, vert);
                    }

                    bounds = new Bounds(0.5f * (high + low), high - low);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
                finally
                {
                    module.DecrementMeshesToUpdate();
                }
            }
        }