/// <summary> /// ApplyToMeshAsSubtract, with MeshCache version, /// </summary> public void ApplyToMeshAsSubtract(Mesh m, MeshCacheRT cache) { // vertices { int vcnt = indV.Count; Vector3[] newVerts = cache.GetVertices(m); for (int i = 0; i < vcnt; ++i) { int vidx = indV[i]; newVerts[vidx] += vertices[i]; } cache.SetVertices(m, newVerts); } //// normals //{ // int ncnt = indN.Count; // Vector3[] newNormals = cache.GetNormals(m); // for (int i = 0; i < ncnt; ++i) // { // int nidx = indN[i]; // newNormals[nidx] += normals[i]; // } // cache.SetNormals(m, newNormals); //} //// tangents //{ // int tcnt = indT.Count; // Vector4[] newTangents = cache.GetTangents(m); // for (int i = 0; i < tcnt; ++i) // { // int tidx = indT[i]; // newTangents[tidx] += tangents[i]; // } // cache.SetTangents(m, newTangents); //} if (evtShapeKeyModifyMesh != null) { evtShapeKeyModifyMesh(basisSO); } }
/// <summary> /// ApplyToMeshAsDiff, with MeshCache version, /// </summary> public void ApplyToMeshAsDiff(Mesh m, MeshCacheRT cache) { int vcnt = m.vertexCount; // vertices Vector3[] newVerts = cache.GetVertices(m); for (int i = 0; i < vcnt; ++i) { newVerts[i] += vertices[i]; } cache.SetVertices(m, newVerts); // normals Vector3[] cacheNormals = cache.GetNormals(); if (cacheNormals != null && cacheNormals.Length == vcnt && HasNormals()) { Vector3[] newNormals = cache.GetNormals(m); for (int i = 0; i < vcnt; ++i) { newNormals[i] += normals[i]; } cache.SetNormals(m, newNormals); } // tangents Vector4[] cacheTangents = cache.GetTangents(); if (cacheTangents != null && cacheTangents.Length == vcnt && HasTangents()) { Vector4[] newTangents = cache.GetTangents(m); for (int i = 0; i < vcnt; ++i) { newTangents[i] += tangents[i]; } cache.SetTangents(m, newTangents); } }