<commit_before>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using AssetGenerator.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AssetGenerator.Runtime.Tests
{
    [TestClass()]
    public class MeshPrimitiveTests
    {
        [TestMethod()]
        public void GetMinMaxNormalsTest()
        {
            List<Vector3> normals = new List<Vector3>
            {
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f)
            };
            MeshPrimitive meshPrim = new MeshPrimitive();
            meshPrim.Normals = normals;
            Vector3[] minMaxNormals = meshPrim.GetMinMaxNormals();
            Assert.AreEqual(new Vector3(0.0f, 0.0f, -1.0f), minMaxNormals[0]);
            Assert.AreEqual(new Vector3(0.0f, 0.0f, 1.0f), minMaxNormals[1]);
        }

        [TestMethod()]
        public void GetMinMaxPositionsTest()
        {
            List<Vector3> positions = new List<Vector3>
            {
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f)
            };
            MeshPrimitive meshPrim = new MeshPrimitive();
            meshPrim.Positions = positions;
            Vector3[] minMaxPositions = meshPrim.GetMinMaxPositions();
            Assert.AreEqual(new Vector3(0.0f, 0.0f, -1.0f), minMaxPositions[0]);
            Assert.AreEqual(new Vector3(0.0f, 0.0f, 1.0f), minMaxPositions[1]);
        }

        [TestMethod()]
        public void GetMinMaxTextureCoordsTest()
        {
            List<List<Vector2>> triangleTextureCoordSets = new List<List<Vector2>>
            {
                new List<Vector2>
                {
                    new Vector2(0.0f, 1.0f),
                    new Vector2(0.5f, 1.0f),
                    new Vector2(0.25f, 0.0f)
                },
                new List<Vector2>
                {
                    new Vector2(0.5f, 1.0f),
                    new Vector2(1.0f, 1.0f),
                    new Vector2(0.75f, 0.0f)
                }

            };

            MeshPrimitive meshPrim = new MeshPrimitive();
            meshPrim.TextureCoordSets = triangleTextureCoordSets;
            List<Vector2[]> minMaxTextureCoordSets = meshPrim.GetMinMaxTextureCoords();

            Assert.AreEqual(minMaxTextureCoordSets[0][0], new Vector2(0.0f, 0.0f));
            Assert.AreEqual(minMaxTextureCoordSets[0][1], new Vector2(0.5f, 1.0f));

            Assert.AreEqual(minMaxTextureCoordSets[1][0], new Vector2(0.5f, 0.0f));
            Assert.AreEqual(minMaxTextureCoordSets[1][1], new Vector2(1.0f, 1.0f));
        }

        [TestMethod()]
        public void ConvertToMeshPrimitiveTest()
        {
            List<glTFLoader.Schema.BufferView> bufferViews = new List<glTFLoader.Schema.BufferView>();
            List<glTFLoader.Schema.Accessor> accessors = new List<glTFLoader.Schema.Accessor>();
            List<glTFLoader.Schema.Texture> textures = new List<glTFLoader.Schema.Texture>();
            List<glTFLoader.Schema.Material> materials = new List<glTFLoader.Schema.Material>();
            List<glTFLoader.Schema.Sampler> samplers = new List<glTFLoader.Schema.Sampler>();
            List<glTFLoader.Schema.Image> images = new List<glTFLoader.Schema.Image>();
            glTFLoader.Schema.Buffer buffer = new glTFLoader.Schema.Buffer();
            Data geometryData = new Data("test.bin");
            int buffer_index = 0, buffer_offset = 0;
            glTFLoader.Schema.Buffer bufer = new glTFLoader.Schema.Buffer();

            MeshPrimitive meshPrim = new MeshPrimitive();
            meshPrim.ConvertToMeshPrimitive(bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, buffer_index, buffer_offset, true, false, false);
        }

        [TestMethod()]
        public void GetMorphTargetsTest()
        {
            var positions = new List<Vector3>
            {
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(-1.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f),
            };

            var positions2 = new List<Vector3>
            {
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(-1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f),
            };

            var normals = new List<Vector3>
            {
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f)
            };

            List<glTFLoader.Schema.BufferView> bufferViews = new List<glTFLoader.Schema.BufferView>();
            List<glTFLoader.Schema.Accessor> accessors = new List<glTFLoader.Schema.Accessor>();
            List<glTFLoader.Schema.Texture> textures = new List<glTFLoader.Schema.Texture>();
            List<glTFLoader.Schema.Material> materials = new List<glTFLoader.Schema.Material>();
            List<glTFLoader.Schema.Sampler> samplers = new List<glTFLoader.Schema.Sampler>();
            List<glTFLoader.Schema.Image> images = new List<glTFLoader.Schema.Image>();
            glTFLoader.Schema.Buffer buffer = new glTFLoader.Schema.Buffer();
            Data geometryData = new Data("test.bin");
            int buffer_index = 0, buffer_offset = 0;
            

            MeshPrimitive meshPrim = new MeshPrimitive
            {
                Positions = positions,
                Normals = normals
            };
            MeshPrimitive morphTarget = new MeshPrimitive
            {
                Positions = positions2,
                Normals = normals
            };
            List<MeshPrimitive> morphTargets = new List<MeshPrimitive>();
            morphTargets.Add(morphTarget);

            meshPrim.MorphTargets = morphTargets;
            meshPrim.morphTargetWeight = 0;
            Mesh mesh = new Mesh();
            mesh.AddPrimitive(meshPrim);
            glTFLoader.Schema.Mesh m = mesh.ConvertToMesh(bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, buffer_index, buffer_offset);
            Assert.IsTrue(m.Primitives[0].Targets.Count() > 0);

        }
    }
}<commit_msg>added weights to unittests<commit_after>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using AssetGenerator.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AssetGenerator.Runtime.Tests
{
    [TestClass()]
    public class MeshPrimitiveTests
    {
        [TestMethod()]
        public void GetMinMaxNormalsTest()
        {
            List<Vector3> normals = new List<Vector3>
            {
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f)
            };
            MeshPrimitive meshPrim = new MeshPrimitive();
            meshPrim.Normals = normals;
            Vector3[] minMaxNormals = meshPrim.GetMinMaxNormals();
            Assert.AreEqual(new Vector3(0.0f, 0.0f, -1.0f), minMaxNormals[0]);
            Assert.AreEqual(new Vector3(0.0f, 0.0f, 1.0f), minMaxNormals[1]);
        }

        [TestMethod()]
        public void GetMinMaxPositionsTest()
        {
            List<Vector3> positions = new List<Vector3>
            {
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f)
            };
            MeshPrimitive meshPrim = new MeshPrimitive();
            meshPrim.Positions = positions;
            Vector3[] minMaxPositions = meshPrim.GetMinMaxPositions();
            Assert.AreEqual(new Vector3(0.0f, 0.0f, -1.0f), minMaxPositions[0]);
            Assert.AreEqual(new Vector3(0.0f, 0.0f, 1.0f), minMaxPositions[1]);
        }

        [TestMethod()]
        public void GetMinMaxTextureCoordsTest()
        {
            List<List<Vector2>> triangleTextureCoordSets = new List<List<Vector2>>
            {
                new List<Vector2>
                {
                    new Vector2(0.0f, 1.0f),
                    new Vector2(0.5f, 1.0f),
                    new Vector2(0.25f, 0.0f)
                },
                new List<Vector2>
                {
                    new Vector2(0.5f, 1.0f),
                    new Vector2(1.0f, 1.0f),
                    new Vector2(0.75f, 0.0f)
                }

            };

            MeshPrimitive meshPrim = new MeshPrimitive();
            meshPrim.TextureCoordSets = triangleTextureCoordSets;
            List<Vector2[]> minMaxTextureCoordSets = meshPrim.GetMinMaxTextureCoords();

            Assert.AreEqual(minMaxTextureCoordSets[0][0], new Vector2(0.0f, 0.0f));
            Assert.AreEqual(minMaxTextureCoordSets[0][1], new Vector2(0.5f, 1.0f));

            Assert.AreEqual(minMaxTextureCoordSets[1][0], new Vector2(0.5f, 0.0f));
            Assert.AreEqual(minMaxTextureCoordSets[1][1], new Vector2(1.0f, 1.0f));
        }

        [TestMethod()]
        public void ConvertToMeshPrimitiveTest()
        {
            List<glTFLoader.Schema.BufferView> bufferViews = new List<glTFLoader.Schema.BufferView>();
            List<glTFLoader.Schema.Accessor> accessors = new List<glTFLoader.Schema.Accessor>();
            List<glTFLoader.Schema.Texture> textures = new List<glTFLoader.Schema.Texture>();
            List<glTFLoader.Schema.Material> materials = new List<glTFLoader.Schema.Material>();
            List<glTFLoader.Schema.Sampler> samplers = new List<glTFLoader.Schema.Sampler>();
            List<glTFLoader.Schema.Image> images = new List<glTFLoader.Schema.Image>();
            glTFLoader.Schema.Buffer buffer = new glTFLoader.Schema.Buffer();
            Data geometryData = new Data("test.bin");
            int buffer_index = 0, buffer_offset = 0;
            glTFLoader.Schema.Buffer bufer = new glTFLoader.Schema.Buffer();

            MeshPrimitive meshPrim = new MeshPrimitive();
            meshPrim.ConvertToMeshPrimitive(bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, buffer_index, buffer_offset, true, false, false);
        }

        [TestMethod()]
        public void GetMorphTargetsTest()
        {
            var positions = new List<Vector3>
            {
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(-1.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f),
            };

            var positions2 = new List<Vector3>
            {
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(-1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f),
            };

            var normals = new List<Vector3>
            {
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f)
            };

            List<glTFLoader.Schema.BufferView> bufferViews = new List<glTFLoader.Schema.BufferView>();
            List<glTFLoader.Schema.Accessor> accessors = new List<glTFLoader.Schema.Accessor>();
            List<glTFLoader.Schema.Texture> textures = new List<glTFLoader.Schema.Texture>();
            List<glTFLoader.Schema.Material> materials = new List<glTFLoader.Schema.Material>();
            List<glTFLoader.Schema.Sampler> samplers = new List<glTFLoader.Schema.Sampler>();
            List<glTFLoader.Schema.Image> images = new List<glTFLoader.Schema.Image>();
            glTFLoader.Schema.Buffer buffer = new glTFLoader.Schema.Buffer();
            Data geometryData = new Data("test.bin");
            int buffer_index = 0, buffer_offset = 0;
            

            MeshPrimitive meshPrim = new MeshPrimitive
            {
                Positions = positions,
                Normals = normals
            };
            MeshPrimitive morphTarget = new MeshPrimitive
            {
                Positions = positions2,
                Normals = normals
            };
            List<MeshPrimitive> morphTargets = new List<MeshPrimitive>();
            morphTargets.Add(morphTarget);

            meshPrim.MorphTargets = morphTargets;
            meshPrim.morphTargetWeight = 0;
            Mesh mesh = new Mesh();
            mesh.AddPrimitive(meshPrim);
            glTFLoader.Schema.Mesh m = mesh.ConvertToMesh(bufferViews, accessors, samplers, images, textures, materials, geometryData, ref buffer, buffer_index, buffer_offset);
            Assert.IsTrue(m.Primitives[0].Targets.Count() > 0);
            Assert.IsTrue(m.Weights.Count() > 0);
        }
    }
}
{'fraction_non_alphanumeric': 0.11444549464398236, 'fraction_numerical': 0.03473534971644612, 'mean_word_length': 1.8915964472785243, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 86, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3311467', 'n_tokens_mistral': 4099, 'n_tokens_neox': 3935, 'n_words': 705}