MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / construct_impl

Function construct_impl

modules/engine/runtime/src/ecs/chunk_view.cpp:35–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 for (char* i = (char*)array->BeginX; i != array->EndX; i += size)
34
35static void construct_impl(sugoi_chunk_view_t view, type_index_t type, EIndex offset, uint32_t size, uint32_t align, uint32_t elemSize, uint32_t maskValue, void (*constructor)(sugoi_chunk_t* chunk, EIndex index, char* data))
36{
37 char* dst = view.chunk->data() + (size_t)offset + (size_t)size * view.start;
38 if (type.is_buffer())
39 forloop (j, 0, view.count)
40 {
41 char* buf = (size_t)j * size + dst;
42 auto array = new_array(buf, size, elemSize, align);
43 if (constructor)
44 for_buffer(curr, array, elemSize)
45 constructor(view.chunk, view.start + j, curr);
46 }
47 else if (type == kMaskComponent)
48 forloop (j, 0, view.count)
49 ((mask_t*)dst)[j] = maskValue;
50 else if (type == kDirtyComponent)
51 memset(dst, 0xFFFFFFFF, (size_t)size * view.count);
52 // else if (type == kGuidComponent)
53 // {
54 // auto guidDst = (guid_t*)dst;
55 // auto& registry = type_registry_t::get();
56 // forloop (j, 0, view.count)
57 // guidDst[j] = registry.make_guid();
58 // return;
59 // }
60 else if (constructor)
61 forloop (j, 0, view.count)
62 constructor(view.chunk, view.start + j, (size_t)j * size + dst);
63 else
64 memset(dst, 0, (size_t)size * view.count);
65}
66
67static void destruct_impl(sugoi_chunk_view_t view, type_index_t type, EIndex offset, uint32_t size, uint32_t elemSize, resource_fields_t resourceFields, void (*destructor)(sugoi_chunk_t* chunk, EIndex index, char* data))
68{

Callers 5

construct_viewFunction · 0.85
construct_chunkFunction · 0.85
cast_viewFunction · 0.85
duplicate_viewFunction · 0.85
constructMethod · 0.85

Calls 5

new_arrayFunction · 0.85
memsetFunction · 0.85
is_bufferMethod · 0.80
constructorClass · 0.50
dataMethod · 0.45

Tested by

no test coverage detected