Demos update
-fixed critical bug with demos switching -change multithreaded rendering method (now draw order is keeped even witch multithreading there is no popping) -added particle emitter components and systems (WIP) -bullets (laser) now sending EBullet event insead of EDamage which gives possibility to not destroy bullet if shooted entity is already killed
This commit is contained in:
parent
233f4abd47
commit
3d98b0ee5e
4 changed files with 284 additions and 87 deletions
|
|
@ -114,7 +114,7 @@ struct Renderer
|
|||
|
||||
void freeBlocks()
|
||||
{
|
||||
block_stack_mutex.lock();
|
||||
/*block_stack_mutex.lock();
|
||||
render_blocks = 0;
|
||||
current_block = 0;
|
||||
foreach(VertexBlock block; blocks)
|
||||
|
|
@ -124,13 +124,38 @@ struct Renderer
|
|||
blocks.clear;
|
||||
prepared_items=0;
|
||||
draw_list.clear();
|
||||
block_stack_mutex.unlock();
|
||||
block_stack_mutex.unlock();*/
|
||||
foreach(ref Thread thread; threads)
|
||||
{
|
||||
foreach(VertexBlock block; thread.blocks)
|
||||
{
|
||||
allocator.freeBlock(block.memory);
|
||||
}
|
||||
thread.blocks.clear();
|
||||
}
|
||||
render_blocks = 0;
|
||||
current_block = 0;
|
||||
prepared_items = 0;
|
||||
draw_list.clear();
|
||||
}
|
||||
|
||||
void pushData()
|
||||
{
|
||||
foreach(ref Thread thread; threads)
|
||||
{
|
||||
foreach(VertexBlock block; thread.blocks)
|
||||
{
|
||||
uint items = block.items;
|
||||
if(items + item_id >= MaxObjects)items = MaxObjects - item_id;
|
||||
batch_vbo[0].bufferSubData(Buffer.BindTarget.array,items*4*14,item_id*4*14,block.batch_vertices.ptr);
|
||||
batch_ibo[0].bufferSubData(Buffer.BindTarget.element_array,items*2*6,item_id*2*6,block.batch_indices.ptr);
|
||||
draw_list.add(DrawCall(item_id,items));
|
||||
item_id += items;
|
||||
}
|
||||
//thread.blocks.clear();
|
||||
}
|
||||
//if(!isRemainingBlocks())return;
|
||||
while(isRemainingBlocks())
|
||||
/* while(isRemainingBlocks())
|
||||
{
|
||||
VertexBlock block = fetchBlock();
|
||||
uint items = block.items;
|
||||
|
|
@ -139,14 +164,15 @@ struct Renderer
|
|||
batch_ibo[0].bufferSubData(Buffer.BindTarget.element_array,items*2*6,item_id*2*6,block.batch_indices.ptr);
|
||||
draw_list.add(DrawCall(item_id,items));
|
||||
item_id += items;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void pushThreadsBlocks()
|
||||
{
|
||||
foreach(i, ref Thread thread; threads)
|
||||
{
|
||||
pushBlock(thread.block);
|
||||
//pushBlock(thread.block);
|
||||
thread.blocks.add(thread.block);
|
||||
thread.block = getBlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -156,6 +182,7 @@ struct Renderer
|
|||
//Vector!VertexBlock block;
|
||||
RenderData[] render_list;
|
||||
VertexBlock block;
|
||||
Vector!VertexBlock blocks;
|
||||
}
|
||||
Thread[] threads;
|
||||
|
||||
|
|
@ -609,7 +636,8 @@ struct Renderer
|
|||
threads[thread_id].block.items++;
|
||||
if(threads[thread_id].block.items >= VertexBlock.max_items)
|
||||
{
|
||||
pushBlock(threads[thread_id].block);
|
||||
//pushBlock(threads[thread_id].block);
|
||||
threads[thread_id].blocks.add(threads[thread_id].block);
|
||||
threads[thread_id].block = getBlock();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue