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

Method DownloadBuffer

Source/Engine/Graphics/Models/SkinnedMesh.cpp:429–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427};
428
429MArray* SkinnedMesh::DownloadBuffer(bool forceGpu, MTypeObject* resultType, int32 typeI)
430{
431 // [Deprecated in v1.10]
432 ScopeLock lock(GetModelBase()->Locker);
433
434 // Get vertex buffers data from the mesh (CPU or GPU)
435 MeshAccessor accessor;
436 MeshBufferType bufferTypes[1] = { MeshBufferType::Vertex0 };
437 if (accessor.LoadMesh(this, forceGpu, ToSpan(bufferTypes, 1)))
438 return nullptr;
439 auto positionStream = accessor.Position();
440 auto texCoordStream = accessor.TexCoord();
441 auto normalStream = accessor.Normal();
442 auto tangentStream = accessor.Tangent();
443 auto blendIndicesStream = accessor.BlendIndices();
444 auto BlendWeightsStream = accessor.BlendWeights();
445 auto count = GetVertexCount();
446
447 // Convert into managed array
448 MArray* result = MCore::Array::New(MCore::Type::GetClass(INTERNAL_TYPE_OBJECT_GET(resultType)), count);
449 void* managedArrayPtr = MCore::Array::GetAddress(result);
450 switch ((InternalBufferType)typeI)
451 {
452 PRAGMA_DISABLE_DEPRECATION_WARNINGS
453 case InternalBufferType::VB0:
454 for (int32 i = 0; i < count; i++)
455 {
456 auto& dst = ((VB0SkinnedElementType*)managedArrayPtr)[i];
457 dst.Position = positionStream.GetFloat3(i);
458 if (texCoordStream.IsValid())
459 dst.TexCoord = texCoordStream.GetFloat2(i);
460 if (normalStream.IsValid())
461 dst.Normal = normalStream.GetFloat3(i);
462 if (tangentStream.IsValid())
463 dst.Tangent = tangentStream.GetFloat4(i);
464 if (blendIndicesStream.IsValid())
465 dst.BlendIndices = Color32(blendIndicesStream.GetFloat4(i));
466 if (BlendWeightsStream.IsValid())
467 dst.BlendWeights = Half4(BlendWeightsStream.GetFloat4(i));
468 }
469 break;
470 PRAGMA_ENABLE_DEPRECATION_WARNINGS
471 }
472
473 return result;
474}
475
476#endif

Callers

nothing calls this directly

Calls 15

GetModelBaseFunction · 0.85
GetAddressFunction · 0.85
PositionMethod · 0.80
TexCoordMethod · 0.80
NormalMethod · 0.80
TangentMethod · 0.80
BlendIndicesMethod · 0.80
BlendWeightsMethod · 0.80
GetVertexCountFunction · 0.70
ToSpanFunction · 0.50
NewFunction · 0.50
GetClassFunction · 0.50

Tested by

no test coverage detected