Ejemplo n.º 1
0
        private bool RaycastDeformedMesh(Mesh mesh, Vector3 start, Vector3 direction, Matrix4x4 world, float cameraZ, out float hitDistance, out Vector3 hitPos, out Vector3 hitPosReal)
        {
            hitDistance = float.MaxValue;
            hitPos      = Vector3.get_zero();
            hitPosReal  = Vector3.get_zero();
            Vector3[] vertices  = mesh.get_vertices();
            int[]     triangles = mesh.get_triangles();
            int       index     = 0;

            while (index < triangles.Length)
            {
                Vector3 vector3_1 = vertices[triangles[index]];
                Vector3 vector3_2 = vertices[triangles[index + 1]];
                Vector3 vector3_3 = vertices[triangles[index + 2]];
                // ISSUE: explicit reference operation
                Vector3 pos1 = ((Matrix4x4)@world).MultiplyPoint(vector3_1);
                // ISSUE: explicit reference operation
                Vector3 pos2 = ((Matrix4x4)@world).MultiplyPoint(vector3_2);
                // ISSUE: explicit reference operation
                Vector3 pos3      = ((Matrix4x4)@world).MultiplyPoint(vector3_3);
                Vector3 vector3_4 = GameUtility.DeformPosition(pos1, cameraZ);
                Vector3 vector3_5 = GameUtility.DeformPosition(pos2, cameraZ);
                Vector3 vector3_6 = GameUtility.DeformPosition(pos3, cameraZ);
                Vector3 vector3_7 = Vector3.op_Subtraction(vector3_5, vector3_4);
                // ISSUE: explicit reference operation
                Vector3 normalized1 = ((Vector3)@vector3_7).get_normalized();
                Vector3 vector3_8   = Vector3.op_Subtraction(vector3_6, vector3_4);
                // ISSUE: explicit reference operation
                Vector3 vector3_9 = Vector3.Cross(((Vector3)@vector3_8).get_normalized(), normalized1);
                // ISSUE: explicit reference operation
                Vector3 normalized2 = ((Vector3)@vector3_9).get_normalized();
                float   num1        = Vector3.Dot(normalized2, direction);
                if ((double)num1 > 0.0)
                {
                    float num2 = Vector3.Dot(Vector3.op_Subtraction(vector3_4, start), normalized2) / num1;
                    if ((double)num2 < (double)hitDistance)
                    {
                        Vector3 vector3_10 = Vector3.op_Addition(start, Vector3.op_Multiply(direction, num2));
                        Vector3 vector3_11 = Vector3.op_Subtraction(vector3_4, vector3_10);
                        // ISSUE: explicit reference operation
                        Vector3 normalized3 = ((Vector3)@vector3_11).get_normalized();
                        Vector3 vector3_12  = Vector3.op_Subtraction(vector3_5, vector3_10);
                        // ISSUE: explicit reference operation
                        Vector3 normalized4 = ((Vector3)@vector3_12).get_normalized();
                        Vector3 vector3_13  = Vector3.op_Subtraction(vector3_6, vector3_10);
                        // ISSUE: explicit reference operation
                        Vector3 normalized5 = ((Vector3)@vector3_13).get_normalized();
                        if ((double)(Mathf.Acos(Mathf.Clamp(Vector3.Dot(normalized3, normalized4), -1f, 1f)) + Mathf.Acos(Mathf.Clamp(Vector3.Dot(normalized4, normalized5), -1f, 1f)) + Mathf.Acos(Mathf.Clamp(Vector3.Dot(normalized5, normalized3), -1f, 1f))) > 6.27318525314331)
                        {
                            hitDistance = num2;
                            hitPos      = vector3_10;
                            Vector3 vector3_14 = Vector3.op_Subtraction(vector3_10, vector3_4);
                            Vector3 vector3_15 = Vector3.op_Subtraction(vector3_6, vector3_5);
                            Vector3 vector3_16 = Vector3.op_Subtraction(vector3_4, vector3_5);
                            float   num3       = Vector3.Dot(vector3_14, vector3_14);
                            float   num4       = Vector3.Dot(vector3_14, vector3_15);
                            float   num5       = Vector3.Dot(vector3_15, vector3_15);
                            float   num6       = (float)((double)num3 * (double)num5 - (double)num4 * (double)num4);
                            float   num7       = Vector3.Dot(vector3_14, vector3_16);
                            float   num8       = Vector3.Dot(vector3_15, vector3_16);
                            float   num9       = (float)((double)num4 * (double)num8 - (double)num7 * (double)num5) / num6;
                            Vector3 vector3_17 = Vector3.op_Addition(vector3_4, Vector3.op_Multiply(vector3_14, num9));
                            Vector3 vector3_18 = Vector3.op_Subtraction(vector3_17, vector3_4);
                            float   num10      = Vector3.Dot(Vector3.op_Subtraction(vector3_17, vector3_5), vector3_15) / Vector3.Dot(vector3_15, vector3_15);
                            float   num11      = Vector3.Dot(Vector3.op_Subtraction(vector3_10, vector3_4), vector3_18) / Vector3.Dot(vector3_18, vector3_18);
                            hitPosReal = Vector3.Lerp(pos1, Vector3.Lerp(pos2, pos3, num10), num11);
                        }
                    }
                }
                index += 3;
            }
            return((double)hitDistance < 3.40282346638529E+38);
        }