public void morph(Avatar av) { if (av.VisualParameters == null) return; ThreadPool.QueueUserWorkItem(sync => { int x = 0; // We need a lock here as we may get multiple packets thrown at us and we should at least // process them in turn not 1/2 process one then start to process the next. // That said av might not be the best lock object, but it will do for the moment lock (av) { if (av.VisualParameters.Length > 123) { if (av.VisualParameters[31] > 127) { msex = VisualParamEx.EparamSex.SEX_MALE; } else { msex = VisualParamEx.EparamSex.SEX_FEMALE; } } foreach (GLMesh mesh in _meshes.Values) { mesh.resetallmorphs(); } skel.resetbonescales(); foreach (byte vpvalue in av.VisualParameters) { if (x >= VisualParamEx.tweakable_params.Count) { //Logger.Log("Two many visual paramaters in Avatar appearance", Helpers.LogLevel.Warning); break; } VisualParamEx vpe = (VisualParamEx)VisualParamEx.tweakable_params.GetByIndex(x); if (vpe.sex != VisualParamEx.EparamSex.SEX_BOTH && vpe.sex != msex) { x++; continue; } VisualAppearanceParameters[x] = vpvalue; float value = (vpvalue / 255.0f); this.applyMorph(av, vpe.ParamID, value); x++; } vpsent = true; this.skel.mNeedsMeshRebuild = true; // Don't update actual meshes here anymore, we do it every frame because of animation anyway } }); }
public void morph(Avatar av) { if (av.VisualParameters == null) return; ThreadPool.QueueUserWorkItem(sync => { int x = 0; if (av.VisualParameters.Length > 123) { if (av.VisualParameters[31] > 127) { msex = VisualParamEx.EparamSex.SEX_MALE; } else { msex = VisualParamEx.EparamSex.SEX_FEMALE; } } foreach (GLMesh mesh in _meshes.Values) { mesh.resetallmorphs(); } foreach (byte vpvalue in av.VisualParameters) { /* if (vpsent == true && VisualAppearanceParameters[x] == vpvalue) { x++; continue; } */ VisualAppearanceParameters[x] = vpvalue; if (x >= VisualParamEx.tweakable_params.Count) { //Logger.Log("Two many visual paramaters in Avatar appearance", Helpers.LogLevel.Warning); break; } VisualParamEx vpe = (VisualParamEx)VisualParamEx.tweakable_params.GetByIndex(x); if (vpe.sex != VisualParamEx.EparamSex.SEX_BOTH && vpe.sex != msex) { x++; continue; } float value = (vpvalue / 255.0f); this.morphtest(av, vpe.ParamID, value); x++; // if (x > 100) // break; } vpsent = true; foreach (GLMesh mesh in _meshes.Values) { mesh.applyjointweights(); } }); }