MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Blast / serialize

Method serialize

sdk/lowlevel/source/NvBlastActorSerializationBlock.cpp:255–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253//////// Actor member methods for serialization ////////
254
255uint32_t Actor::serialize(void* buffer, uint32_t bufferSize, NvBlastLog logFn) const
256{
257 // Set up pointers and such
258 const Asset* asset = getAsset();
259 const SupportGraph& graph = asset->m_graph;
260 const uint32_t* graphChunkIndices = graph.getChunkIndices();
261 const uint32_t* graphAdjacencyPartition = graph.getAdjacencyPartition();
262 const uint32_t* graphAdjacentNodeIndices = graph.getAdjacentNodeIndices();
263 const uint32_t* graphAdjacentBondIndices = graph.getAdjacentBondIndices();
264 const FamilyHeader* header = getFamilyHeader();
265 const uint32_t* chunkActorIndices = header->getChunkActorIndices();
266 const uint32_t thisActorIndex = getIndex();
267 const bool boundToWorld = isBoundToWorld();
268
269 // Make sure there are no dirty nodes
270 if (m_graphNodeCount)
271 {
272 const uint32_t* firstDirtyNodeIndices = header->getFamilyGraph()->getFirstDirtyNodeIndices();
273 if (!isInvalidIndex(firstDirtyNodeIndices[thisActorIndex]))
274 {
275 NVBLASTLL_LOG_ERROR(logFn, "Nv::Blast::Actor::serialize: instance graph has dirty nodes. Call Nv::Blast::Actor::findIslands before serializing.");
276 return 0;
277 }
278 }
279
280 uint64_t offset = 0;
281
282 // Header
283 ActorSerializationHeader* serHeader = reinterpret_cast<ActorSerializationHeader*>(buffer);
284 offset = align16(sizeof(ActorSerializationHeader));
285 if (offset > bufferSize)
286 {
287 return 0; // Buffer size insufficient
288 }
289 serHeader->m_formatVersion = ActorSerializationFormat::Current;
290 serHeader->m_size = 0; // Will be updated below
291 serHeader->m_index = thisActorIndex;
292 serHeader->m_visibleChunkCount = m_visibleChunkCount;
293 serHeader->m_graphNodeCount = m_graphNodeCount;
294 serHeader->m_leafChunkCount = m_leafChunkCount;
295
296 // Visible chunk indices
297 {
298 serHeader->m_visibleChunkIndicesOffset = (uint32_t)offset;
299 offset = align16(offset + m_visibleChunkCount*sizeof(uint32_t));
300 if (offset > bufferSize)
301 {
302 NVBLASTLL_LOG_ERROR(logFn, "Nv::Blast::Actor::Actor::serialize: buffer size exceeded.");
303 return 0; // Buffer size insufficient
304 }
305 uint32_t* serVisibleChunkIndices = serHeader->getVisibleChunkIndices();
306 uint32_t serVisibleChunkCount = 0;
307 for (Actor::VisibleChunkIt i = *this; (bool)i; ++i)
308 {
309 NVBLAST_ASSERT(serVisibleChunkCount < m_visibleChunkCount);
310 serVisibleChunkIndices[serVisibleChunkCount++] = (uint32_t)i;
311 }
312 NVBLAST_ASSERT(serVisibleChunkCount == m_visibleChunkCount);

Callers 1

NvBlastActorSerializeFunction · 0.45

Calls 13

isInvalidIndexFunction · 0.85
align16Function · 0.85
getChunkIndicesMethod · 0.80
getFamilyGraphMethod · 0.80
getGraphNodeIndicesMethod · 0.80
getBondHealthsMethod · 0.45
fillMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected