void RebuildColorTargets(SplatWeight blend, float strength) { if (blend == null || splat_cache == null || splat_target == null) { return; } m_MinWeights = splat_target.GetMinWeights(); splat_target.LerpWeights(splat_cache, blend, strength); // get index of texture that is being painted var attrib = meshAttributes[selectedAttributeIndex]; int index = blend.GetAttributeIndex(attrib); var baseTexture = attrib.isBaseTexture? attrib : GetBaseTexture(); int baseTexIndex = -1; if (baseTexture != null) { baseTexIndex = blend.GetAttributeIndex(baseTexture); } splat_erase.LerpWeightOnSingleChannel(splat_cache, m_MinWeights, strength, index, baseTexIndex); }
internal override void OnEnable() { base.OnEnable(); m_CurrentPanelView = PanelView.Paint; m_LikelySupportsTextureBlending = false; m_MeshAttributesContainer = null; brushColor = null; if (meshAttributes != null) { OnMaterialSelected(); } foreach (GameObject go in Selection.gameObjects) { m_LikelySupportsTextureBlending = CheckForTextureBlendSupport(go); if (m_LikelySupportsTextureBlending) { break; } } }
// Called when the mouse begins hovering an editable object. internal override void OnBrushEnter(EditableObject target, BrushSettings settings) { base.OnBrushEnter(target, settings); if (target.editMesh == null) { return; } bool refresh = (m_CacheTarget != null && !m_CacheTarget.Equals(target)) || m_CacheTarget == null; if (m_CacheTarget != null && m_CacheTarget.Equals(target.gameObjectAttached)) { var targetMaterials = target.gameObjectAttached.GetMaterials(); refresh = !AreListsEqual(targetMaterials, m_CacheMaterials); } if (refresh) { m_CacheTarget = target; m_CacheMaterials = target.gameObjectAttached.GetMaterials(); m_MeshAttributesContainer = null; currentMeshACIndex = 0; ArrayUtility.Clear(ref m_AvailableMaterialsAsString); m_LikelySupportsTextureBlending = CheckForTextureBlendSupport(target.gameObjectAttached); RebuildCaches(target.editMesh); } if (m_LikelySupportsTextureBlending && (brushColor == null || !brushColor.MatchesAttributes(meshAttributes))) { brushColor = new SplatWeight(SplatWeight.GetChannelMap(meshAttributes)); SetBrushColorWithAttributeIndex(selectedAttributeIndex); } RebuildColorTargets(brushColor, settings.strength); }
void RebuildColorTargets(EditableObject target, SplatWeight blend, float strength) { if (target == null) { return; } var data = m_EditableObjectsData[target]; if (blend == null || data.SplatCache == null || data.SplatTarget == null) { return; } m_MinWeights = data.SplatTarget.GetMinWeights(); data.SplatTarget.LerpWeights(data.SplatCache, blend, strength); // get index of texture that is being painted var attrib = meshAttributes[selectedAttributeIndex]; var baseTexture = attrib.isBaseTexture? attrib : GetBaseTexture(); var baseTexIndex = baseTexture != null ? (int)baseTexture.index : -1; data.SplatErase.LerpWeightOnSingleChannel(data.SplatCache, m_MinWeights, strength, attrib.channel, (int)attrib.index, baseTexIndex); }
// Called when the mouse begins hovering an editable object. internal override void OnBrushEnter(EditableObject target, BrushSettings settings) { base.OnBrushEnter(target, settings); if (target.editMesh == null) { return; } bool refresh = (m_MainCacheTarget != null && !m_MainCacheTarget.Equals(target)) || m_MainCacheTarget == null; if (m_MainCacheTarget != null && m_MainCacheTarget.Equals(target)) { var targetMaterials = target.gameObjectAttached.GetMaterials(); refresh = !targetMaterials.SequenceEqual(m_MainCacheMaterials); } if (refresh) { SetActiveObject(target); RebuildMaterialCaches(); PolybrushEditor.instance.Repaint(); } if (m_LikelySupportsTextureBlending && (brushColor == null || !brushColor.MatchesAttributes(meshAttributes))) { brushColor = new SplatWeight(SplatWeight.GetChannelMap(meshAttributes)); SetBrushColorWithAttributeIndex(selectedAttributeIndex); } RebuildColorTargets(target, brushColor, settings.strength); }
void RebuildColorTargets(SplatWeight blend, float strength) { if (blend == null || splat_cache == null || splat_target == null) { return; } m_MinWeights = splat_target.GetMinWeights(); splat_target.LerpWeights(splat_cache, blend, strength); splat_erase.LerpWeights(splat_cache, m_MinWeights, strength); }
/// <summary> /// Editor for blend. Returns true if blend has been modified. /// </summary> /// <param name="index"></param> /// <param name="blend"></param> /// <param name="attribs"></param> /// <returns></returns> internal static int OnInspectorGUI(int index, ref SplatWeight blend, AttributeLayout[] attribs) { // if(blend == null && attribs != null) // blend = new SplatWeight( SplatWeight.GetChannelMap(attribs) ); // bool mismatchedOrNullAttributes = blend == null || !blend.MatchesAttributes(attribs); Rect r = GUILayoutUtility.GetLastRect(); int yPos = (int)Mathf.Ceil(r.y + r.height); index = PolyGUILayout.ChannelField(index, attribs, thumbSize, yPos); return(index); }
internal override void OnEnable() { base.OnEnable(); m_LikelySupportsTextureBlending = false; m_MeshAttributesContainer = null; brushColor = null; foreach (GameObject go in Selection.gameObjects) { m_LikelySupportsTextureBlending = CheckForTextureBlendSupport(go); if (m_LikelySupportsTextureBlending) { break; } } }