Remove unused.

This commit is contained in:
ousttrue 2022-02-14 13:35:20 +09:00
parent 21ac603a31
commit 570b56a52c
6 changed files with 2 additions and 429 deletions

View File

@ -169,18 +169,6 @@ namespace UniGLTF
return Glb.Create(json, BinBytes).ToBytes();
}
// public byte[] ToBytes()
// {
// GLTF.buffers[0].byteLength = _buffer.Bytes.Count;
// var f = new JsonFormatter();
// UniGLTF.GltfSerializer.Serialize(f, GLTF);
// var json = f.GetStoreBytes();
// var glb = UniGLTF.Glb.Create(json, _buffer.Bytes);
// return glb.ToBytes();
// }
/// <summary>
/// glTF 形式で出力する?
/// </summary>

View File

@ -218,108 +218,5 @@ namespace VrmLib
return m_root;
}
}
// /// <summary>
// /// モーションの基本姿勢を basePose ベースに再計算する
// ///
// /// basePose は Humanoid.CopyNodes が必用 !
// /// </summary>
// public Animation RebaseAnimation(Humanoid basePose)
// {
// var map = NodeMap.ToDictionary(kv => kv.Key, kv => new List<Quaternion>());
// var hipsPositions = new List<Vector3>();
// foreach (var (seconds, keyframes) in KeyFramesGroupBySeconds())
// {
// // モーション適用
// SetTime(seconds);
// Root.CalcWorldMatrix();
// foreach (var keyframe in keyframes)
// {
// if (!keyframe.Node.HumanoidBone.HasValue
// || keyframe.Node.HumanoidBone.Value == HumanoidBones.unknown)
// {
// continue;
// }
// // ローカル回転を算出する
// var t = basePose[keyframe.Node].Rotation;
// var w = keyframe.Node.Rotation;
// var w_from_t = w * Quaternion.Inverse(t);
// // parent
// var key = keyframe.Node.HumanoidBone.Value;
// var curve = map[keyframe.Node];
// if (key != HumanoidBones.hips)
// {
// if (basePose[key].Parent == null)
// {
// throw new Exception();
// }
// var parent_t = basePose[key].Parent.Rotation;
// var parent_w = keyframe.Node.Parent.Rotation;
// var parent_w_from_t = parent_w * Quaternion.Inverse(parent_t);
// var r = Quaternion.Inverse(parent_w_from_t) * w_from_t;
// curve.Add(r);
// }
// else
// {
// // hips
// curve.Add(w_from_t);
// hipsPositions.Add(keyframe.Node.Translation);
// }
// }
// }
// var dst = new Animation(Name + ".tpose");
// foreach (var kv in map)
// {
// if (!kv.Value.Any())
// {
// continue;
// }
// var bone = kv.Key.HumanoidBone.Value;
// var inCurve = NodeMap[kv.Key].Curves[AnimationPathType.Rotation].In;
// if (inCurve.Count != kv.Value.Count)
// {
// throw new Exception();
// }
// var nodeAnimation = new NodeAnimation();
// nodeAnimation.Curves.Add(AnimationPathType.Rotation, new CurveSampler
// {
// In = inCurve,
// Out = BufferAccessor.Create(kv.Value.ToArray()),
// });
// if (bone == HumanoidBones.hips)
// {
// nodeAnimation.Curves.Add(AnimationPathType.Translation, new CurveSampler
// {
// In = inCurve,
// Out = BufferAccessor.Create(hipsPositions.ToArray()),
// });
// }
// dst.AddCurve(kv.Key, nodeAnimation);
// }
// return dst;
// }
// /// <summary>
// /// 指定された数のフレームを先頭から取り除く
// /// </summary>
// public void SkipFrame(int skipFrames)
// {
// foreach (var kv in NodeMap)
// {
// foreach (var curve in kv.Value.Curves)
// {
// curve.Value.SkipFrame(skipFrames);
// }
// }
// }
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using UniGLTF;
@ -164,40 +163,6 @@ namespace VrmLib
return Bytes.Reinterpret<T>(1);
}
// /// <summary>
// /// バッファをNativeArrayに変換して返す
// /// 開放の責務は使い手側にある点に注意
// /// </summary>
// public unsafe NativeArray<T> AsNativeArray<T>(Allocator allocator) where T : struct
// {
// if (Stride == Marshal.SizeOf(typeof(T)))
// {
// fixed (byte* byteArray = Bytes.Array)
// {
// var nativeArray = new NativeArray<T>(Bytes.Count / Marshal.SizeOf<T>(), allocator);
// UnsafeUtility.MemCpy(nativeArray.GetUnsafePtr(), byteArray + Bytes.Offset, Bytes.Count);
// return nativeArray;
// }
// }
// else
// {
// if (typeof(T) == typeof(SkinJoints) && Stride == 4)
// {
// // 例えば SkinJoints を使う JOINTS_0 は UNSIGNED_BYTE と UNSIGNED_SHORT の2種類がありえる。
// fixed (UShort4* p = GetAsUShort4())
// {
// var nativeArray = new NativeArray<T>(Count, allocator);
// UnsafeUtility.MemCpy(nativeArray.GetUnsafePtr(), p, Bytes.Count);
// return nativeArray;
// }
// }
// else
// {
// throw new Exception($"Stride:{Stride}!= sizeof({typeof(T).Name}:{Marshal.SizeOf(typeof(T))}");
// }
// }
// }
/// <summary>
/// バッファをNativeSliceへと書き込む
/// </summary>
@ -262,92 +227,6 @@ namespace VrmLib
}
}
// public List<int> GetAsIntList()
// {
// if (AccessorType != AccessorVectorType.SCALAR)
// {
// throw new InvalidOperationException("not scalar");
// }
// switch (ComponentType)
// {
// case AccessorValueType.UNSIGNED_SHORT:
// {
// var span = SpanLike.Wrap<UInt16>(Bytes);
// var array = new List<int>(Count);
// if (span.Length != Count)
// {
// for (int i = 0; i < Count; ++i)
// {
// array.Add(span[i]);
// }
// }
// else
// {
// // Spanが動かないWorkAround
// var bytes = Bytes.ToArray();
// var offset = 0;
// for (int i = 0; i < Count; ++i)
// {
// array.Add(BitConverter.ToUInt16(bytes, offset));
// offset += 2;
// }
// }
// return array;
// }
// case AccessorValueType.UNSIGNED_INT:
// return SpanLike.Wrap<Int32>(Bytes).ToArray().ToList();
// default:
// throw new NotImplementedException();
// }
// }
// // Joints用
// public UShort4[] GetAsUShort4()
// {
// if (AccessorType != AccessorVectorType.VEC4)
// {
// throw new InvalidOperationException("not vec4");
// }
// switch (ComponentType)
// {
// case AccessorValueType.UNSIGNED_SHORT:
// return SpanLike.Wrap<UShort4>(Bytes).ToArray();
// case AccessorValueType.UNSIGNED_BYTE:
// {
// var array = new UShort4[Count];
// var span = SpanLike.Wrap<Byte4>(Bytes);
// for (int i = 0; i < span.Length; ++i)
// {
// array[i] = new UShort4(span[i].x, span[i].y, span[i].z, span[i].w);
// }
// return array;
// }
// default:
// throw new NotImplementedException();
// }
// }
// // Weigt用
// public Vector4[] GetAsVector4()
// {
// if (AccessorType != AccessorVectorType.VEC4)
// {
// throw new InvalidOperationException("not vec4");
// }
// switch (ComponentType)
// {
// case AccessorValueType.FLOAT:
// return SpanLike.Wrap<Vector4>(Bytes).ToArray();
// default:
// throw new NotImplementedException();
// }
// }
public void Resize(int count)
{
if (count < Count)

View File

@ -223,58 +223,6 @@ namespace VrmLib
this.Nodes.Remove(remove);
}
// /// <summary>
// /// Nodeを置き換える。参照を置換する。
// /// </summary>
// public void NodeReplace(Node src, Node dst)
// {
// if (src == null)
// {
// throw new ArgumentNullException();
// }
// if (dst == null)
// {
// throw new ArgumentNullException();
// }
// // add dst same parent
// src.Parent.Add(dst, ChildMatrixMode.KeepWorld);
// // remove all child
// foreach (var child in src.Children.ToArray())
// {
// dst.Add(child, ChildMatrixMode.KeepWorld);
// }
// // remove from parent
// src.Parent.Remove(src);
// this.Nodes.Remove(src);
// // remove from skinning
// foreach (var skin in this.Skins)
// {
// skin.Replace(src, dst);
// }
// // fix animation reference
// foreach (var animation in this.Animations)
// {
// if (animation.NodeMap.TryGetValue(src, out NodeAnimation nodeAnimation))
// {
// animation.NodeMap.Remove(src);
// animation.NodeMap.Add(dst, nodeAnimation);
// }
// }
// if (this.Nodes.Contains(dst))
// {
// throw new Exception("already exists");
// }
// this.Nodes.Add(dst);
// // TODO: SpringBone
// }
#endregion
public string SkinningBake(NativeArrayManager arrayManager)

View File

@ -276,39 +276,5 @@ namespace VrmLib
index = (ushort)indexMap[index];
}
}
// /// <summary>
// /// nullになったjointを除去して、boneweightを前に詰める
// /// </summary>
// public void FixBoneWeight(BufferAccessor jointsAccessor, BufferAccessor weightsAccessor)
// {
// var map = Joints.Select((x, i) => ValueTuple.Create(i, x)).Where(x => x.Item2 != null).ToArray();
// var indexMap = Enumerable.Repeat(-1, Joints.Count).ToArray();
// {
// for (int i = 0; i < map.Length; ++i)
// {
// indexMap[map[i].Item1] = i;
// }
// }
// Joints.RemoveAll(x => x == null);
// var joints = jointsAccessor.GetSpan<SkinJoints>();
// var weights = weightsAccessor.GetSpan<Vector4>();
// for (int i = 0; i < joints.Length; ++i)
// {
// var j = joints[i];
// var w = weights[i];
// Update(ref w.X, ref j.Joint0, indexMap);
// Update(ref w.Y, ref j.Joint1, indexMap);
// Update(ref w.Z, ref j.Joint2, indexMap);
// Update(ref w.W, ref j.Joint3, indexMap);
// joints[i] = j;
// weights[i] = w;
// }
// CalcInverseMatrices();
// }
}
}
}

View File

@ -2,9 +2,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using UniGLTF;
namespace VrmLib
{
@ -185,107 +182,5 @@ namespace VrmLib
public VertexBuffer()
{
}
public VertexBuffer CloneWithOffset(int offsetCount)
{
var vb = new VertexBuffer();
foreach (var kv in VertexBuffers)
{
vb.VertexBuffers[kv.Key] = kv.Value.CloneWithOffset(offsetCount);
}
return vb;
}
// public SpanLike<SkinJoints> GetOrCreateJoints()
// {
// var buffer = Joints;
// if (buffer == null)
// {
// buffer = new BufferAccessor(
// new ArraySegment<byte>(new byte[Marshal.SizeOf(typeof(SkinJoints)) * Count]),
// AccessorValueType.UNSIGNED_SHORT,
// AccessorVectorType.VEC4, Count);
// Add(JointKey, buffer);
// }
// return SpanLike.Wrap<SkinJoints>(buffer.Bytes);
// }
// public SpanLike<Vector4> GetOrCreateWeights()
// {
// var buffer = Weights;
// if (buffer == null)
// {
// buffer = new BufferAccessor(
// new ArraySegment<byte>(new byte[Marshal.SizeOf(typeof(Vector4)) * Count]),
// AccessorValueType.FLOAT,
// AccessorVectorType.VEC4, Count);
// Add(WeightKey, buffer);
// }
// return SpanLike.Wrap<Vector4>(buffer.Bytes);
// }
static bool HasSameKeys<T>(Dictionary<string, T> lhs, Dictionary<string, T> rhs)
{
if (lhs.Count != rhs.Count) return false;
foreach (var (l, r) in Enumerable.Zip(lhs.Keys.OrderBy(x => x), rhs.Keys.OrderBy(x => x), (l, r) => (l, r)))
{
if (l != r)
{
return false;
}
}
return true;
}
// public void Append(VertexBuffer v)
// {
// var keys = VertexBuffers.Keys.ToList();
// var lastCount = Count;
// // v から VertexBufferfs に足す
// foreach (var kv in v.VertexBuffers)
// {
// if (VertexBuffers.TryGetValue(kv.Key, out BufferAccessor buffer))
// {
// // used
// keys.Remove(kv.Key);
// if (buffer.Count != lastCount)
// {
// throw new ArgumentException();
// }
// }
// else
// {
// // add empty
// var byteLength = lastCount * kv.Value.Stride;
// buffer = new BufferAccessor(new ArraySegment<byte>(new byte[byteLength]), kv.Value.ComponentType, kv.Value.AccessorType, lastCount);
// if (buffer.Count != lastCount)
// {
// throw new ArgumentException();
// }
// VertexBuffers.Add(kv.Key, buffer);
// }
// buffer.Append(kv.Value);
// }
// // 足されなかったキーに同じ長さを詰める
// foreach (var key in keys)
// {
// var dst = VertexBuffers[key];
// dst.Extend(v.Positions.Count);
// }
// ValidateLength();
// }
public void Resize(int n)
{
foreach (var kv in VertexBuffers)
{
kv.Value.Resize(n);
}
}
}
}
}