MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / DownloadVertexBuffer

Method DownloadVertexBuffer

Source/Engine/Graphics/Models/Mesh.cs:505–538  ·  view source on GitHub ↗

Downloads the raw vertex buffer that contains mesh vertices data. To download data from GPU set to true and call this method from the thread other than main thread (see ). [Deprecated in v1.10] If set to true the data will be downloaded from the GPU, otherwise it can be loaded from t

(bool forceGpu = false)

Source from the content-addressed store, hash-verified

503 /// <param name="forceGpu">If set to <c>true</c> the data will be downloaded from the GPU, otherwise it can be loaded from the drive (source asset file) or from memory (if cached). Downloading mesh from GPU requires this call to be made from the other thread than main thread. Virtual assets are always downloaded from GPU memory due to lack of dedicated storage container for the asset data.</param>
504 /// <returns>The gathered data.</returns>
505 [Obsolete("Use new MeshAccessor and depend on GPUVertexLayout when accessing mesh data.")]
506 public Vertex[] DownloadVertexBuffer(bool forceGpu = false)
507 {
508 var vb0 = DownloadVertexBuffer0(forceGpu);
509 var vb1 = DownloadVertexBuffer1(forceGpu);
510 var vb2 = DownloadVertexBuffer2(forceGpu);
511
512 var vertices = vb0.Length;
513 var result = new Vertex[vertices];
514 for (int i = 0; i < vertices; i++)
515 {
516 ref var v0 = ref vb0[i];
517 ref var v1 = ref vb1[i];
518 float bitangentSign = v1.Tangent.A > Mathf.Epsilon ? -1.0f : +1.0f;
519
520 result[i].Position = v0.Position;
521 result[i].TexCoord = (Float2)v1.TexCoord;
522 result[i].Normal = v1.Normal.ToFloat3() * 2.0f - 1.0f;
523 result[i].Tangent = v1.Tangent.ToFloat3() * 2.0f - 1.0f;
524 result[i].Bitangent = Float3.Cross(result[i].Normal, result[i].Tangent) * bitangentSign;
525 result[i].LightmapUVs = (Float2)v1.LightmapUVs;
526 result[i].Color = Color.Black;
527 }
528
529 if (vb2 != null)
530 {
531 for (int i = 0; i < vertices; i++)
532 {
533 result[i].Color = vb2[i].Color;
534 }
535 }
536
537 return result;
538 }
539
540#if FLAX_EDITOR
541 /// <summary>

Callers 1

DownloadMeshDataMethod · 0.45

Calls 2

ToFloat3Method · 0.45
CrossMethod · 0.45

Tested by

no test coverage detected