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

Method generateRawDataAsset

Source/Engine/CSG/CSGBuilder.cpp:391–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389}
390
391bool CSGBuilderImpl::generateRawDataAsset(Scene* scene, RawData& meshData, Guid& assetId, const String& assetPath)
392{
393 // Prepare data
394 MemoryWriteStream stream(4096);
395 {
396 // Header (with version number)
397 stream.WriteInt32(1);
398 const int32 brushesCount = meshData.Brushes.Count();
399 stream.WriteInt32(brushesCount);
400
401 // Surfaces data locations
402 int32 surfacesDataOffset = sizeof(int32) * 2 + (sizeof(Guid) + sizeof(int32)) * brushesCount;
403 for (auto brush = meshData.Brushes.Begin(); brush.IsNotEnd(); ++brush)
404 {
405 auto& surfaces = brush->Value.Surfaces;
406
407 stream.Write(brush->Key);
408 stream.WriteInt32(surfacesDataOffset);
409
410 // Calculate offset in data storage to the next brush data
411 int32 brushDataSize = 0;
412 for (int32 i = 0; i < surfaces.Count(); i++)
413 {
414 brushDataSize += sizeof(int32) + sizeof(RawData::SurfaceTriangle) * surfaces[i].Triangles.Count();
415 }
416 surfacesDataOffset += brushDataSize;
417 }
418
419 // Surfaces data
420 for (auto brush = meshData.Brushes.Begin(); brush.IsNotEnd(); ++brush)
421 {
422 auto& surfaces = brush->Value.Surfaces;
423
424 for (int32 i = 0; i < surfaces.Count(); i++)
425 {
426 auto& triangles = surfaces[i].Triangles;
427
428 stream.WriteInt32(triangles.Count());
429 stream.WriteBytes(triangles.Get(), triangles.Count() * sizeof(RawData::SurfaceTriangle));
430 }
431 }
432 }
433
434 // Serialize
435 BytesContainer bytesContainer;
436 bytesContainer.Link(ToSpan(stream));
437 return AssetsImportingManager::Create(AssetsImportingManager::CreateRawDataTag, assetPath, assetId, (void*)&bytesContainer);
438}
439
440#endif

Callers

nothing calls this directly

Calls 10

ToSpanFunction · 0.50
CreateFunction · 0.50
WriteInt32Method · 0.45
CountMethod · 0.45
BeginMethod · 0.45
IsNotEndMethod · 0.45
WriteMethod · 0.45
WriteBytesMethod · 0.45
GetMethod · 0.45
LinkMethod · 0.45

Tested by

no test coverage detected