public override void SetMesh(Mesh mesh) { if (usePointCache) { if (mesh.isReadable) { pCache = PointCacheGenerator.ComputePCacheFromMesh(mesh, pointCacheMapSize, pointCachePointCount, pointCacheSeed, pointCacheDistribution, pointCacheBakeMode); vfx.SetTexture("PositionMap", pCache.positionMap); if (vfx.HasTexture("NormalMap")) { vfx.SetTexture("NormalMap", pCache.normalMap); } if (!pointCacheSkinnedMeshUpdate) { pCache.Dispose(); pCache = null; } } else { Debug.LogError("Cannot access vertices on mesh " + mesh.name + " for generating point cache (isReadable is false; Read/Write must be enabled in import settings)"); } } else if (vfx.HasMesh("Mesh")) { vfx.SetMesh("Mesh", mesh); } }
public override void SetRenderer(Renderer renderer, bool secondary) { if ((useSecondaryRenderer && secondary) || (!useSecondaryRenderer && !secondary)) { Mesh mesh = renderer is SkinnedMeshRenderer ? (renderer as SkinnedMeshRenderer).sharedMesh : renderer.GetComponent <MeshFilter>().sharedMesh; if (usePointCache) { if (mesh.isReadable) { if (renderer is SkinnedMeshRenderer) { mesh = new Mesh(); (renderer as SkinnedMeshRenderer).BakeMesh(mesh); pointCacheSkinnedMeshRenderer = renderer as SkinnedMeshRenderer; } pCache = PointCacheGenerator.ComputePCacheFromMesh(mesh, pointCacheMapSize, pointCachePointCount, pointCacheSeed, pointCacheDistribution, pointCacheBakeMode); vfx.SetTexture("PositionMap", pCache.positionMap); if (vfx.HasTexture("NormalMap")) { vfx.SetTexture("NormalMap", pCache.normalMap); } if (!pointCacheSkinnedMeshUpdate) { pCache.Dispose(); pCache = null; } } else { Debug.LogError("Cannot access vertices on mesh " + mesh.name + " for generating point cache (isReadable is false; Read/Write must be enabled in import settings)"); } } else { vfx.SetMesh("Mesh", mesh); } } }