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

Function destruct_impl

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

Source from the content-addressed store, hash-verified

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{
69 char* src = view.chunk->data() + (size_t)offset + (size_t)size * view.start;
70 auto patchResources = [&](char* data)
71 {
72 forloop(k, 0, resourceFields.count)
73 {
74 auto field = ((intptr_t*)resourceFields.offsets)[k];
75 auto* resource = (skr_resource_handle_t*)(data + field);
76 if(resource->is_resolved())
77 resource->reset();
78 }
79 };
80 if (type.is_buffer())
81 forloop (j, 0, view.count)
82 {
83 auto array = (sugoi_array_comp_t*)((size_t)j * size + src);
84 if (destructor)
85 for_buffer(curr, array, elemSize)
86 destructor(view.chunk, view.start + j, curr);
87 else if(resourceFields.count > 0)
88 for_buffer(curr, array, elemSize)
89 patchResources(curr);
90 if (!is_array_small(array))
91 sugoi_array_comp_t::free(array->BeginX);
92 }
93 else if (destructor)
94 forloop (j, 0, view.count)
95 destructor(view.chunk, view.start + j, (size_t)j * size + src);
96 else if (resourceFields.count > 0)
97 {
98 forloop (j, 0, view.count)
99 patchResources((size_t)j * size + src);
100 }
101}
102
103static void move_impl(sugoi_chunk_view_t dstV, const sugoi_chunk_t* srcC, uint32_t srcStart, type_index_t type, EIndex srcOffset, EIndex dstOffset, uint32_t size, uint32_t align, uint32_t elemSize, void (*move)(sugoi_chunk_t* chunk, EIndex index, char* dst, sugoi_chunk_t* schunk, EIndex sindex, char* src))
104{

Callers 3

destruct_viewFunction · 0.70
destruct_chunkFunction · 0.70
cast_viewFunction · 0.70

Calls 7

destructorClass · 0.85
is_array_smallFunction · 0.85
is_resolvedMethod · 0.80
is_bufferMethod · 0.80
freeFunction · 0.50
dataMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected