MCPcopy Create free account
hub / github.com/crownengine/crown / allocate

Method allocate

src/world/scene_graph.cpp:68–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void SceneGraph::allocate(u32 num)
69{
70 CE_ASSERT(num > _data.size, "num > _data.size");
71
72 const u32 bytes = 0
73 + num*sizeof(UnitId) + alignof(UnitId)
74 + num*sizeof(Matrix4x4) + alignof(Matrix4x4)
75 + num*sizeof(Pose) + alignof(Pose)
76 + num*sizeof(TransformId) * 4 + alignof(TransformId)
77 + num*sizeof(bool) + alignof(bool)
78 ;
79
80 InstanceData new_data;
81 new_data.size = _data.size;
82 new_data.capacity = num;
83 new_data.buffer = _allocator->allocate(bytes);
84
85 new_data.unit = (UnitId * )memory::align_top(new_data.buffer, alignof(UnitId));
86 new_data.world = (Matrix4x4 * )memory::align_top(new_data.unit + num, alignof(Matrix4x4));
87 new_data.local = (Pose * )memory::align_top(new_data.world + num, alignof(Pose));
88 new_data.parent = (TransformId *)memory::align_top(new_data.local + num, alignof(TransformId));
89 new_data.first_child = (TransformId *)memory::align_top(new_data.parent + num, alignof(TransformId));
90 new_data.next_sibling = (TransformId *)memory::align_top(new_data.first_child + num, alignof(TransformId));
91 new_data.prev_sibling = (TransformId *)memory::align_top(new_data.next_sibling + num, alignof(TransformId));
92 new_data.changed = (bool * )memory::align_top(new_data.prev_sibling + num, alignof(bool));
93
94 memcpy(new_data.unit, _data.unit, _data.size * sizeof(UnitId));
95 memcpy(new_data.world, _data.world, _data.size * sizeof(Matrix4x4));
96 memcpy(new_data.local, _data.local, _data.size * sizeof(Pose));
97 memcpy(new_data.parent, _data.parent, _data.size * sizeof(TransformId));
98 memcpy(new_data.first_child, _data.first_child, _data.size * sizeof(TransformId));
99 memcpy(new_data.next_sibling, _data.next_sibling, _data.size * sizeof(TransformId));
100 memcpy(new_data.prev_sibling, _data.prev_sibling, _data.size * sizeof(TransformId));
101 memcpy(new_data.changed, _data.changed, _data.size * sizeof(bool));
102
103 _allocator->deallocate(_data.buffer);
104 _data = new_data;
105}
106
107void SceneGraph::unit_destroyed_callback(UnitId unit)
108{

Callers 15

loadFunction · 0.45
loadFunction · 0.45
loadFunction · 0.45
compile_render_stateMethod · 0.45
loadFunction · 0.45
parseFunction · 0.45
loadFunction · 0.45
scan_and_restoreMethod · 0.45
compute_state_offsetsMethod · 0.45
spawn_unitMethod · 0.45
aligned_alloc_funcFunction · 0.45
alloc_funcFunction · 0.45

Calls 2

memcpyFunction · 0.85
deallocateMethod · 0.45

Tested by

no test coverage detected