Skip to content

Commit

Permalink
Merge pull request #343 from umasteeringgroup/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Jaimi authored Jan 13, 2021
2 parents 34b17c3 + c91db56 commit bcb7f86
Show file tree
Hide file tree
Showing 38 changed files with 175,446 additions and 174,093 deletions.
798 changes: 501 additions & 297 deletions UMAProject/Assets/UMA/Core/Editor/Scripts/UMAAvatarLoadSaveMenuItems.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class UMAGeneratorBuiltinEditor : UMAGeneratorBaseEditor
SerializedProperty NoCoroutines;
SerializedProperty EditorInitialScaleFactor;
SerializedProperty editorAtlasResolution;
SerializedProperty collectGarbage;


#pragma warning disable 0108
Expand All @@ -32,7 +33,7 @@ public override void OnEnable()
NoCoroutines = serializedObject.FindProperty("NoCoroutines");
EditorInitialScaleFactor = serializedObject.FindProperty("editorInitialScaleFactor");
editorAtlasResolution = serializedObject.FindProperty("editorAtlasResolution");

collectGarbage = serializedObject.FindProperty("collectGarbage");
}
#pragma warning restore 0108

Expand All @@ -45,6 +46,7 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(InitialScaleFactor);
EditorGUILayout.PropertyField(fastGeneration);
EditorGUILayout.PropertyField(IterationCount);
EditorGUILayout.PropertyField(collectGarbage);
EditorGUILayout.PropertyField(garbageCollectionRate);
EditorGUILayout.PropertyField(processAllPending);
GUILayout.Space(20);
Expand All @@ -54,7 +56,6 @@ public override void OnInspectorGUI()


GUILayout.Space(20);
EditorGUILayout.HelpBox("Edit time generation options. Keep the atlas size down and the scale factor high to address possible problems loading large scene files.", MessageType.None);
EditorGUILayout.LabelField("Advanced Configuration", centeredLabel);
EditorGUILayout.PropertyField(NoCoroutines);
EditorGUILayout.PropertyField(textureMerge);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace UMA
public class UmaAboutWindow : EditorWindow
{
public static string umaVersion { get { return _version; } }
private static readonly string _version = "2.11.4";
private static readonly string _version = "2.11.5";
private string windowTitle = "UMA About";
private string wikiLink = "http://umadocs.secretanorak.com/doku.php";
private string githubLink = "https://github.com/umasteeringgroup";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ private SlotDataAsset CreateSlot_Internal()
KeepList.Add(b.strValue);
}

Debug.Log("Slot Mesh: " + slotMesh.name, slotMesh.gameObject);
SlotDataAsset slot = UMASlotProcessingUtil.CreateSlotData(AssetDatabase.GetAssetPath(slotFolder), GetAssetFolder(), GetAssetName(),GetSlotName(slotMesh),nameAfterMaterial, slotMesh, material, normalReferenceMesh,KeepList, RootBone, binarySerialization);
slot.tags = Tags.ToArray();
return slot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,7 @@ public void Awake()
isAddressableSystem = true;
}
#endif
#if UNITY_EDITOR
EditorUMAContextBase = GameObject.Find("UMAEditorContext");
if (EditorUMAContextBase != null)
{
EditorUMAContextBase.hideFlags = HideFlags.DontSave | HideFlags.NotEditable;
EditorApplication.update -= CheckEditorContextNeeded;
EditorApplication.update += CheckEditorContextNeeded;
}
#endif

cacheStates = new Dictionary<string, string>();
this.context = UMAContextBase.Instance;
}
Expand All @@ -453,11 +445,20 @@ private static void OnScriptsReloaded()
// Use this for initialization
public override void Start()
{
#if UNITY_EDITOR
if (UMAContextBase.Instance == null)
{
CreateEditorContext();
}
#endif
lastHide = !hide;

if (umaGenerator == null)
{
umaGenerator = UMAContextBase.Instance.GetComponent<UMAGeneratorBase>();
if (UMAContextBase.Instance != null)
{
umaGenerator = UMAContextBase.Instance.GetComponent<UMAGeneratorBase>();
}
}
#if SUPER_LOGGING
Debug.Log("Start on DynamicCharacterAvatar: " + gameObject.name);
Expand Down Expand Up @@ -538,7 +539,13 @@ public void InitializeFromPreset(string presetstring)
#if UNITY_EDITOR
public void GenerateSingleUMA()
{
UMAGenerator ugb = UMAContext.Instance.gameObject.GetComponentInChildren<UMAGenerator>();
UMAGenerator ugb = umaGenerator as UMAGenerator;
if (umaGenerator == null)
{
if (UMAContext.Instance == null)
return;
ugb = UMAContext.Instance.gameObject.GetComponentInChildren<UMAGenerator>();
}
if (ugb != null)
{
if (UnityEditor.PrefabUtility.IsPartOfPrefabInstance(gameObject.transform))
Expand Down Expand Up @@ -625,13 +632,15 @@ void Update()

void OnDisable()
{

#if UNITY_EDITOR
DestroyEditorUMAContextBase();
#endif
}

void OnDestroy()
{

#if UNITY_EDITOR
DestroyEditorUMAContextBase();
#endif
Expand Down Expand Up @@ -1637,11 +1646,7 @@ void ApplyCurrentWardrobeToNewRace(List<WardrobeSettings> fallbackSet = null)
var thisContext = UMAContextBase.Instance;
if (thisContext == null)
{
#if UNITY_EDITOR
thisContext = CreateEditorContext();
#else
return;
#endif
}
//var thisDCS = thisContext.dynamicCharacterSystem as DynamicCharacterSystem;
Dictionary<string, UMATextRecipe> wrBU = new Dictionary<string, UMATextRecipe>(_wardrobeRecipes);
Expand Down Expand Up @@ -2336,7 +2341,6 @@ public void SetAnimatorController(bool addAnimator = false)
{
if (thisAnimator != null)
{
Debug.LogWarning("Nulling out runtimeanimator Controller");
thisAnimator.runtimeAnimatorController = null;
}
}
Expand Down Expand Up @@ -3836,9 +3840,20 @@ void AddCharacterStateCache(string cacheStateName = "")
/// </summary>
public UMAContextBase CreateEditorContext()
{
EditorUMAContextBase = UMAContextBase.CreateEditorContext();
EditorUMAContextBase = GameObject.Find("UMAEditorContext");
if (EditorUMAContextBase == null)
{
var glib = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/UMA/Getting Started/UMA_GLIB.prefab");
if (glib != null)
{
glib.name = "UMAEditorContext";
EditorUMAContextBase = (GameObject)PrefabUtility.InstantiatePrefab(glib);
}
EditorUMAContextBase.hideFlags = HideFlags.DontSave | HideFlags.NotEditable;
}
EditorApplication.update -= CheckEditorContextNeeded;
EditorApplication.update += CheckEditorContextNeeded;
UMAContextBase.Instance = EditorUMAContextBase.GetComponent<UMAContextBase>();
return UMAContextBase.Instance;
}

Expand All @@ -3852,8 +3867,6 @@ private void DestroyEditorUMAContextBase()
}
DestroyImmediate(EditorUMAContextBase);
EditorApplication.update -= CheckEditorContextNeeded;
if (Debug.isDebugBuild)
Debug.Log("UMAEditorContext was removed");
}
}

Expand Down
3 changes: 0 additions & 3 deletions UMAProject/Assets/UMA/Core/Scripts/UMAAssetIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,12 @@ public void CheckCache()
CachedOp c = LoadedItems[i];
if (c.Expired)
{
Debug.Log("Cleaning up: " + c.Info);
Addressables.Release(c.Operation);
Cleanup.Add(c);
}
}
if (Cleanup.Count > 0)
{
Debug.Log("Freeing " + Cleanup.Count + " Items");
LoadedItems.RemoveAll(x => Cleanup.Contains(x));
}
}
Expand Down Expand Up @@ -1256,7 +1254,6 @@ public void Unload(AsyncOperationHandle<IList<UnityEngine.Object>> AssetOperatio

public void UnloadAll(bool forceResourceUnload)
{
Debug.Log("Unloading ALL AsyncOperationHandle in Indexer.UnloadAll()");

foreach (CachedOp op in LoadedItems)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ public static GameObject ClonePrefab(GameObject other, string newName = "")
return prefab;
}

public static string UnityFriendlyPath(string path)
{
if (path.ToLower().StartsWith("assets") == false)
{
int assetloc = path.ToLower().IndexOf("assets/");
path = path.Substring(assetloc);
}
return path;
}

/// <summary>
/// Saves the passed asset to the path. The path should include the filename with extension.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj"></param>
/// <param name="path"></param>
public static void SaveAsset<T>(Object obj, string path)
{
path = UnityFriendlyPath(path);
AssetDatabase.CreateAsset(obj, path);
AssetDatabase.SaveAssets();
}


//public static string GetAssetPathAndName();
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ protected static void InitializeDynamicDNADictionary()

DynamicDNADictionary = new Dictionary<string, DynamicUMADnaAsset>();

List<DynamicUMADnaAsset> AllDNA = UMAContext.Instance.GetAllDNA();
List<DynamicUMADnaAsset> AllDNA;// = UMAContext.Instance.GetAllDNA();

if (UMAContext.Instance == null)
{
AllDNA = UMAAssetIndexer.Instance.GetAllAssets<DynamicUMADnaAsset>();
}
else
{
AllDNA = UMAContext.Instance.GetAllDNA();
}

foreach (DynamicUMADnaAsset uda in AllDNA)
{
if (uda != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public SlotDataAsset asset
_assetSlotName = value.slotName;
else
{
Debug.Log("Cleared Asset Slot Name");
_assetSlotName = "";
}
}
Expand Down Expand Up @@ -220,7 +219,6 @@ public void OnAfterDeserialize()
//We're not logging an error here because we'll get spammed by it for empty/not-set assets.
if (_asset == null && string.IsNullOrEmpty(_assetSlotName))
{
Debug.Log("No reference and no name on MeshHideAsset!");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,28 @@ public static GameObject CreateEditorContext()
//Make this GameObject not show up in the scene or save
EditorUMAContextBase.hideFlags = HideFlags.DontSave | HideFlags.NotEditable;
//if this gameobject does not contain an UMAContextBase add it - we have to call it UMAContextBase because UMAContextBase.FindInstance searches for that game object
var thisUMAContextBase = UMAContextBase.Instance = EditorUMAContextBase.GetComponentInChildren<UMAContextBase>();
var context = UMAContextBase.Instance = EditorUMAContextBase.GetComponentInChildren<UMAContextBase>();
if (UMAContextBase.Instance == null)
{
var thisUMAContextBaseGO = new GameObject();
thisUMAContextBaseGO.name = "UMAContext";
thisUMAContextBaseGO.transform.parent = EditorUMAContextBase.transform;
thisUMAContextBase = thisUMAContextBaseGO.AddComponent<UMAGlobalContext>();
UMAContextBase.Instance = thisUMAContextBase;
var GO = new GameObject();
GO.name = "UMAContext";
GO.transform.parent = EditorUMAContextBase.transform;
context = GO.AddComponent<UMAGlobalContext>();
GO.AddComponent<UMADefaultMeshCombiner>();

var gen = GO.AddComponent<UMAGenerator>();
gen.fitAtlas = true;
gen.SharperFitTextures = true;
gen.AtlasOverflowFitMethod = UMAGeneratorBase.FitMethod.BestFitSquare;
gen.convertRenderTexture = false;
gen.editorAtlasResolution = 1024;
gen.InitialScaleFactor = 2;
gen.collectGarbage = false;
gen.IterationCount = 1;
gen.fastGeneration = true;
gen.processAllPending = false;
gen.NoCoroutines = true;
UMAContextBase.Instance = context;
}
return EditorUMAContextBase;
}
Expand Down
29 changes: 5 additions & 24 deletions UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/UMAData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,18 +487,11 @@ public Color GetMultiplier(int overlay, int textureType)
{
if (textureType < channelMask[overlay].Length)
{
try
{
c = channelMask[overlay][textureType];
c.r = Mathf.Clamp((c.r + overlayData[overlay].GetComponentAdjustmentsForChannel(c.r, textureType, 0)), 0, 1);
c.g = Mathf.Clamp((c.g + overlayData[overlay].GetComponentAdjustmentsForChannel(c.g, textureType, 1)), 0, 1);
c.b = Mathf.Clamp((c.b + overlayData[overlay].GetComponentAdjustmentsForChannel(c.b, textureType, 2)), 0, 1);
c.a = Mathf.Clamp((c.a + overlayData[overlay].GetComponentAdjustmentsForChannel(c.a, textureType, 3)), 0, 1);
}
catch(Exception ex)
{
Debug.Log("overlay = " + overlay + "; textureType = " + textureType);
}
c = channelMask[overlay][textureType];
c.r = Mathf.Clamp((c.r + overlayData[overlay].GetComponentAdjustmentsForChannel(c.r, textureType, 0)), 0, 1);
c.g = Mathf.Clamp((c.g + overlayData[overlay].GetComponentAdjustmentsForChannel(c.g, textureType, 1)), 0, 1);
c.b = Mathf.Clamp((c.b + overlayData[overlay].GetComponentAdjustmentsForChannel(c.b, textureType, 2)), 0, 1);
c.a = Mathf.Clamp((c.a + overlayData[overlay].GetComponentAdjustmentsForChannel(c.a, textureType, 3)), 0, 1);
}
return c;
}
Expand Down Expand Up @@ -1518,10 +1511,6 @@ public void CleanTextures()
if (tempTexture is RenderTexture)
{
RenderTexture tempRenderTexture = tempTexture as RenderTexture;
if (RenderTexture.active == tempRenderTexture)
{
Debug.Log("RenderTexture is ACTIVE!!!! Name = " + tempRenderTexture.name);
}
tempRenderTexture.Release();
UMAUtils.DestroySceneObject(tempRenderTexture);
}
Expand Down Expand Up @@ -1902,14 +1891,6 @@ public void RemoveBlendShapeData(string name, bool rebuild = false)
/// <param name="allowRebuild">Triggers a rebuild of the uma character if the blendshape is baked</param>
public void SetBlendShape(string name, float weight, bool allowRebuild = false)
{
#if !UNITY_2018_3_OR_NEWER
if (weight < 0.0f || weight > 1.0f)
{
if (Debug.isDebugBuild)
Debug.LogWarning("SetBlendShape: Weight is out of range, clamping...");
}
weight = Mathf.Clamp01(weight);
#endif
BlendShapeData data;
if (blendShapeSettings.blendShapes.TryGetValue(name, out data))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,14 @@ protected void RecalculateUV(UMAMeshData umaMesh)

if (generatedMaterial.umaMaterial.materialType != UMAMaterial.MaterialType.Atlas)
{
var fragment = generatedMaterial.materialFragments[0];
int vertexCount = fragment.slotData.asset.meshData.vertices.Length;
idx += vertexCount;
foreach (var fragment in generatedMaterial.materialFragments)
{
int vertexCount = fragment.slotData.asset.meshData.vertices.Length;
idx += vertexCount;
}
continue;
}




for (int materialDefinitionIndex = 0; materialDefinitionIndex < generatedMaterial.materialFragments.Count; materialDefinitionIndex++)
{
var fragment = generatedMaterial.materialFragments[materialDefinitionIndex];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public abstract class UMAGeneratorBuiltin : UMAGeneratorBase
[Tooltip("Number of character updates before triggering garbage collection.")]
[Range(0.0f, 128.0f)]
public int garbageCollectionRate = 8;

public bool collectGarbage = true;
private System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();

[Tooltip("Generates a single UMA immediately with no coroutines. This is the fastest possible path.")]
Expand Down Expand Up @@ -94,12 +96,12 @@ public virtual void Awake()
}
}

public virtual void LateUpdate()
public virtual void Update()
{
if (CheckRenderTextures())
return; // if render textures needs rebuild we'll not do anything else

if (forceGarbageCollect > garbageCollectionRate)
if (collectGarbage && (forceGarbageCollect > garbageCollectionRate))
{
GC.Collect();
forceGarbageCollect = 0;
Expand Down Expand Up @@ -523,7 +525,7 @@ public virtual void UpdateUMABody(UMAData umaData)
if (umaData)
{
umaData.FirePreUpdateUMABody();
umaData.skeleton.ResetAll();
// umaData.skeleton.ResetAll(); // I don't think this needs to be called, because we overwrite all that in the next call.
// Put the skeleton into TPose so rotations will be valid for generating avatar
umaData.GotoTPose();
umaData.ApplyDNA();
Expand Down
Loading

0 comments on commit bcb7f86

Please sign in to comment.