private void calculate_morph(string morph_name, float val, bool add_vertices_to_update) { Morph morph = Morph.GetFromListByName(this.morph_data, morph_name); if (morph != null) { float real_val = val - Morph.GetFromListByName(this.morph_data, morph_name).morph_values; //if (this.morph_values.ContainsKey(real_val)) if (real_val != 0.0f) { foreach (KeyValuePair <uint, Vector3> kv in morph.morph_data) { int i = Convert.ToInt32(kv.Key); Vector3 delta = kv.Value; this.m_engine.final_form[i] = this.m_engine.final_form[i] + delta * real_val; } if (add_vertices_to_update) { this.m_engine.verts_to_update = this.m_engine.verts_to_update.Union(morph.morph_modified_verts).ToList <uint>(); } Morph.GetFromListByName(this.morph_data, morph_name).morph_values = val; //this.morph_values[morph_name] = val; } } }
private void combine_morphings(HumanModifier modifier, bool refresh_only, bool add_vertices_to_update) { //Dictionary<float, float> values = new Dictionary<float, float>(); List <KeyValuePair <float, float> > values = new List <KeyValuePair <float, float> >(); foreach (string prop in modifier.properties) { float val = this.character_data[prop]; if (val > 1.0f) { val = 1.0f; } if (val < 0f) { val = 0f; } float val1 = function_modifier_a(val); float val2 = function_modifier_b(val); values.Add(new KeyValuePair <float, float> (val1, val2)); } List <float> weights; List <string> names; smart_combo(modifier.name, values, out names, out weights); for (int i = 0; i < names.Count; i++) { if (refresh_only) { Morph.GetFromListByName(this.morph_data, names[i]).morph_values = weights[i]; } else { this.calculate_morph(names[i], weights[i], true); } } }