Common update:
-added multiple new function to allocate template and add entity -updated README.md (complete initial version) -empty components now don't take memory -fixedd small bug with TestRunner -added many new tests (HashMap, Vector, EntityMeta, ...) -added default hashing function to HashMap -fixed critical bug with adding entities -fixed small bug with adding entity with remplacement components -added asserts into code to better bug detection -small performance improvement for events -added ComponentRef structure which contain data pointer and componentID -remove EntityID from Event structure -now events are handled before removing entiteis -fixed GDC compilation -fixed rendering of rotated sprites -added weapons as separate entities to space ship and others -added Tower enemy to SpaceInvaders demo -added Boss to SpaceInvaders demo (boss has four tower attached to it) -Boss towers shoot multiple bullets upon death -fixed critical bug with demos switching -fixed critical bug related to adding/removing entities form inside onAdd/onRemove entity callback -added animation support -added particles sypport and particles for firing and explostions, and more -multithreaded rendering now has same rendering order as singlethreaded -application automaticallu detect host CPU threads count -added upgrades to SPaceInvaders demo -fixed texture memory freeing -improved documentation -improved multithreaded performance -improve shader code -fixed registration issue -some additional performance improvements -added depth and colors to rendering parameters -jobs now has names corresponding to their systems -change execute() -> willExecute() -added EntityMeta structure to speedup getting fetching components form entity -improved multithreading rendering -added possibility tio change number of threads runtime -added bullets collision detection in SpaceInvaders demo -some CI changes -added VBO batch rendering (current default, no render mode switch yet) -fixed camera positioning calculation -fixed buffer issue with WebGL -added viewport scalling (at least 300 pixels height). Pixels are scalled if screen is bigger. -center demos gameplay area -added fullpage html template for Emscripten build -added many new sprites to atlas -fixed critical bug with CPU usage in multithreaded mode -snake render tile coresponding to body part -snake is destroyed after collision and emit some particles -added some functionality to vectors -fixed documentation issue in Manager.d -more minor code changes and cleanup
This commit is contained in:
parent
2ddb97e9ce
commit
024356df9b
62 changed files with 5918 additions and 1673 deletions
|
|
@ -6,9 +6,9 @@ import cimgui.cimgui;
|
|||
|
||||
import game_core.job_updater;
|
||||
|
||||
import ecs.manager;
|
||||
import ecs.core;
|
||||
import ecs.std;
|
||||
import bubel.ecs.manager;
|
||||
import bubel.ecs.core;
|
||||
import bubel.ecs.std;
|
||||
|
||||
import ecs_utils.gfx.renderer;
|
||||
import ecs_utils.imgui_bind;
|
||||
|
|
@ -58,6 +58,7 @@ struct Launcher
|
|||
uint style = 3;
|
||||
uint entities_count;
|
||||
bool multithreading;
|
||||
int threads = 1;
|
||||
ulong timer_freq;
|
||||
double delta_time;
|
||||
uint fps;
|
||||
|
|
@ -95,6 +96,7 @@ struct Launcher
|
|||
void switchDemo(void function() start, bool function() loop, void function() end, void function(SDL_Event*) event, void function(vec2, Tool, int) tool, const (char)* tips)
|
||||
{
|
||||
gui_manager.clear();
|
||||
//launcher.ent
|
||||
|
||||
if(this.end)this.end();
|
||||
|
||||
|
|
@ -102,6 +104,14 @@ struct Launcher
|
|||
manager.update("clean");
|
||||
manager.end();
|
||||
|
||||
foreach(ref system; manager.systems)
|
||||
{
|
||||
if(system.id != CountSystem.system_id && system.id != CleanSystem.system_id)system.disable();
|
||||
}
|
||||
|
||||
/*launcher.manager.getSystem(CountSystem.system_id).enable();
|
||||
launcher.manager.getSystem(CleanSystem.system_id).enable();//*/
|
||||
|
||||
if(start)start();
|
||||
this.loop = loop;
|
||||
this.end = end;
|
||||
|
|
@ -259,7 +269,6 @@ void mainLoop(void* arg)
|
|||
launcher.repeat_time -= range;
|
||||
launcher.tool((launcher.mouse.position*launcher.scalling)-launcher.render_position, launcher.used_tool, launcher.tool_size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
version(WebAssembly)
|
||||
|
|
@ -316,6 +325,22 @@ void mainLoop(void* arg)
|
|||
if(igMenuItemBool("Multithreading", null, launcher.multithreading, true))
|
||||
{
|
||||
launcher.multithreading = !launcher.multithreading;
|
||||
if(launcher.multithreading)
|
||||
{
|
||||
launcher.job_updater.pool.setThreadsNum(launcher.threads);
|
||||
}
|
||||
else
|
||||
{
|
||||
launcher.job_updater.pool.setThreadsNum(1);
|
||||
}
|
||||
}
|
||||
igSetNextItemWidth(0);
|
||||
igLabelText("Threads:",null);
|
||||
igSameLine(0,4);
|
||||
if(igSliderInt("##Threads",&launcher.threads, 1, 32, null))//"Multithreading", null, launcher.multithreading, true))
|
||||
{
|
||||
launcher.job_updater.pool.setThreadsNum(launcher.threads);
|
||||
//launcher.threads = !launcher.multithreading;
|
||||
}
|
||||
if(igBeginMenu("Show",true))
|
||||
{
|
||||
|
|
@ -439,7 +464,7 @@ void mainLoop(void* arg)
|
|||
if(launcher.show_demo_wnd)
|
||||
{
|
||||
igSetNextWindowPos(ImVec2(launcher.window_size.x - 260, 30), ImGuiCond_Once, ImVec2(0,0));
|
||||
igSetNextWindowSize(ImVec2(250, 250), ImGuiCond_Once);
|
||||
igSetNextWindowSize(ImVec2(250, 500), ImGuiCond_Once);
|
||||
if(igBegin("Demo",&launcher.show_demo_wnd,0))
|
||||
{
|
||||
ImDrawList* draw_list = igGetWindowDrawList();
|
||||
|
|
@ -539,11 +564,14 @@ void mainLoop(void* arg)
|
|||
launcher.renderer.clear();
|
||||
|
||||
double loop_time = launcher.getTime();
|
||||
launcher.job_updater.pool.tryWaitCount = 10000;
|
||||
if(launcher.loop && !launcher.loop())
|
||||
{
|
||||
quit();
|
||||
*cast(bool*)arg = false;
|
||||
}
|
||||
launcher.job_updater.pool.tryWaitCount = 0;
|
||||
|
||||
loop_time = launcher.getTime() - loop_time;
|
||||
|
||||
double draw_time = launcher.getTime();
|
||||
|
|
@ -686,10 +714,10 @@ int main(int argc, char** argv)
|
|||
|
||||
setStyle(3);
|
||||
|
||||
launcher.job_updater = Mallocator.make!ECSJobUpdater(12);
|
||||
launcher.job_updater = Mallocator.make!ECSJobUpdater(1);
|
||||
//launcher.job_updater.onCreate();
|
||||
|
||||
EntityManager.initialize(12);
|
||||
EntityManager.initialize(32, 1<<16);
|
||||
launcher.manager = EntityManager.instance;
|
||||
|
||||
//launcher.manager.m_thread_id_func = &launcher.job_updater.getThreadID;
|
||||
|
|
@ -709,10 +737,16 @@ int main(int argc, char** argv)
|
|||
|
||||
launcher.renderer.initialize();
|
||||
|
||||
import mmutils.thread_pool : ThreadPool;
|
||||
launcher.threads = ThreadPool.getCPUCoresCount();
|
||||
if(launcher.threads < 2)launcher.threads = 2;
|
||||
|
||||
launcher.gui_manager = Mallocator.make!GUIManager();
|
||||
|
||||
{
|
||||
import demos.simple;
|
||||
import demos.space_invaders;
|
||||
// launcher.switchDemo(&spaceInvadersStart,&spaceInvadersLoop,&spaceInvadersEnd,&spaceInvadersEvent,&spaceInvadersTool,SpaceInvaders.tips);
|
||||
launcher.switchDemo(&simpleStart,&simpleLoop,&simpleEnd,&simpleEvent,&simpleTool,Simple.tips);
|
||||
}
|
||||
|
||||
|
|
@ -741,6 +775,8 @@ int main(int argc, char** argv)
|
|||
}
|
||||
}
|
||||
|
||||
EntityManager.destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -785,7 +821,15 @@ void loadGFX()
|
|||
GfxConfig.materials[0].compile();
|
||||
GfxConfig.materials[0].bindAttribLocation("positions",0);
|
||||
GfxConfig.materials[0].bindAttribLocation("tex_coords",1);
|
||||
GfxConfig.materials[0].bindAttribLocation("depth",2);
|
||||
GfxConfig.materials[0].bindAttribLocation("vcolor",3);
|
||||
GfxConfig.materials[0].link();
|
||||
|
||||
/* import std.stdio;
|
||||
writeln("positions ",glGetAttribLocation(GfxConfig.materials[0].data.modules[0].gl_handle,"positions"));
|
||||
writeln("tex_coords ",glGetAttribLocation(GfxConfig.materials[0].data.modules[0].gl_handle,"tex_coords"));
|
||||
writeln("depth ",glGetAttribLocation(GfxConfig.materials[0].data.modules[0].gl_handle,"depth"));
|
||||
writeln("vcolor ",glGetAttribLocation(GfxConfig.materials[0].data.modules[0].gl_handle,"vcolor"));*/
|
||||
|
||||
GfxConfig.materials[0].data.uniforms = Mallocator.makeArray!(Material.Uniform)(3);
|
||||
GfxConfig.materials[0].data.uniforms[0] = Material.Uniform(Material.Type.float4, GfxConfig.materials[0].getLocation("matrix_1"), 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue