Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

初期値との差分を使うようにロジックを変更 #1209

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void InitializeMaterialMap(Dictionary<ExpressionKey, VRM10Expression> clipMap, T
item = new PreviewMaterialItem(material);
m_materialMap.Add(binding.MaterialName, item);
}
// color default value
var propName = GetProperty(binding.BindType);
if (!item.PropMap.ContainsKey(binding.BindType))
{
Expand Down Expand Up @@ -148,8 +149,6 @@ public int GetHashCode(MaterialColorBinding obj)
/// </summary>
Dictionary<string, Vector4> m_materialUVMap = new Dictionary<string, Vector4>();

static readonly Vector4 DefaultUVScaleOffset = new Vector4(1, 1, 0, 0);

public void AccumulateValue(VRM10Expression clip, float value)
{
// material color
Expand All @@ -169,14 +168,20 @@ public void AccumulateValue(VRM10Expression clip, float value)
// maetrial uv
foreach (var binding in clip.MaterialUVBindings)
{
Vector4 acc;
if (!m_materialUVMap.TryGetValue(binding.MaterialName, out acc))
if (m_materialMap.TryGetValue(binding.MaterialName, out PreviewMaterialItem item))
{
acc = DefaultUVScaleOffset;
}
var delta = binding.ScalingOffset - item.DefaultUVScaleOffset;

var delta = binding.ScalingOffset - DefaultUVScaleOffset;
m_materialUVMap[binding.MaterialName] = acc + delta * value;
Vector4 acc;
if (m_materialUVMap.TryGetValue(binding.MaterialName, out acc))
{
m_materialUVMap[binding.MaterialName] = acc + delta * value;
}
else
{
m_materialUVMap[binding.MaterialName] = item.DefaultUVScaleOffset + delta * value;
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ public sealed class PreviewMaterialItem
public PreviewMaterialItem(Material material)
{
Material = material;

// uv default value
DefaultUVScaleOffset = material.GetVector(UV_PROPERTY);
}

public Dictionary<UniGLTF.Extensions.VRMC_vrm.MaterialColorType, PropItem> PropMap = new Dictionary<UniGLTF.Extensions.VRMC_vrm.MaterialColorType, PropItem>();

public Vector4 DefaultUVScaleOffset = new Vector4(1, 1, 0, 0);

public string[] PropNames
{
get;
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRM10/Samples/VRM10Viewer/VRM10AutoExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ IEnumerator Routine()
{
yield return new WaitForSeconds(1.0f);

var velocity = 0.1f;
var velocity = 0.01f;

yield return RoutineNest(ExpressionPreset.happy, velocity, m_wait);
yield return RoutineNest(ExpressionPreset.angry, velocity, m_wait);
Expand Down