<commit_before>﻿using CSharpGL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GridViewer
{
    /// <summary>
    /// scale model and its children models recursively.
    /// </summary>
    public class ModelScaleScript : Script
    {
        /// <summary>
        /// scale model and its children models recursively.
        /// </summary>
        [Category("Desc")]
        [Description("scale model and its children models recursively.")]
        public string Desc { get { return "scale model and its children models recursively."; } }

        private vec3 scale = new vec3(1, 1, 1);
        /// <summary>
        /// Invoke SetScale(vec3 factor) by modifing this property.
        /// 
        /// </summary>
        [Browsable(true)]
        [Description("Invoke SetScale(vec3 factor) by modifing this property.")]
        public vec3 Scale
        {
            get { return scale; }
            set
            {
                scale = value;
                this.SetScale(value);
            }
        }
        public bool SetScale(vec3 factor)
        {
            bool updated = false;

            var stack = new Stack<SceneObject>();
            vec3 rootPosition;
            {
                SceneObject obj = this.BindingObject;
                if (obj == null) { throw new Exception(); }
                var transform = obj.Renderer as IModelSpace;
                if (transform == null) { throw new Exception(); }
                rootPosition = transform.WorldPosition;
                stack.Push(obj);
            }

            while (stack.Count > 0)
            {
                SceneObject obj = stack.Pop();
                var transform = obj.Renderer as IModelSpace;
                if (transform != null)
                {
                    vec3 distance = transform.WorldPosition - rootPosition;
                    mat4 model = glm.translate(mat4.identity(), rootPosition);
                    model = glm.scale(model, factor);
                    model = glm.translate(model, distance);
                    transform.WorldPosition = model.GetTranslate();
                    transform.Scale = model.GetScale();

                    updated = true;
                }

                foreach (var item in obj.Children) { stack.Push(item); }
            }

            return updated;
        }
    }
}<commit_msg>clean<commit_after>﻿using CSharpGL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GridViewer
{
    /// <summary>
    /// scale model and its children models recursively.
    /// </summary>
    public class ModelScaleScript : Script
    {
        /// <summary>
        /// scale model and its children models recursively.
        /// </summary>
        [Category("Desc")]
        [Description("scale model and its children models recursively.")]
        public string Desc { get { return "scale model and its children models recursively."; } }

        private vec3 scale = new vec3(1, 1, 1);
        /// <summary>
        /// Invoke SetScale(vec3 factor) by modifing this property.
        /// 
        /// </summary>
        [Browsable(true)]
        [Description("Invoke SetScale(vec3 factor) by modifing this property.")]
        public vec3 Scale
        {
            get { return scale; }
            set
            {
                scale = value;
                this.SetScale(value);
            }
        }
        public bool SetScale(vec3 factor)
        {
            bool updated = false;

            var stack = new Stack<SceneObject>();
            vec3 rootPosition;
            {
                SceneObject obj = this.BindingObject;
                if (obj == null) { throw new Exception(); }
                var transform = obj.Renderer as IModelSpace;
                if (transform == null) { throw new Exception(); }
                rootPosition = transform.WorldPosition;
                stack.Push(obj);
            }

            while (stack.Count > 0)
            {
                SceneObject obj = stack.Pop();
                var transform = obj.Renderer as IModelSpace;
                if (transform != null)
                {
                    vec3 distance = transform.WorldPosition - rootPosition;
                    mat4 model = glm.translate(mat4.identity(), rootPosition);
                    model = glm.scale(model, factor);
                    model = glm.translate(model, distance);
                    transform.WorldPosition = model.GetTranslate();
                    transform.Scale = factor;

                    updated = true;
                }

                foreach (var item in obj.Children) { stack.Push(item); }
            }

            return updated;
        }
    }
}
{'fraction_non_alphanumeric': 0.09779501837484687, 'fraction_numerical': 0.0057166190281747655, 'mean_word_length': 1.451951951951952, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '3225578', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1156, 'n_words': 340}