diff --git a/doc/samples/physics/lolbtphysicsintegration.h b/doc/samples/physics/lolbtphysicsintegration.h index ccf73273..bf94e49f 100644 --- a/doc/samples/physics/lolbtphysicsintegration.h +++ b/doc/samples/physics/lolbtphysicsintegration.h @@ -21,11 +21,11 @@ namespace lol //Override Gamegroups names for Physic-usage //"_ENT_" means that this is a group for Entities that use EasyPhysic primitives. //"_EZP_" means that this is a group for EasyPhysic primitives. -#define GAMEGROUP_ENT_INPUT GAMEGROUP_BEFORE -#define GAMEGROUP_ENT_PLATFORM GAMEGROUP_DEFAULT -#define GAMEGROUP_ENT_MAIN GAMEGROUP_AFTER -#define GAMEGROUP_EZP_CHAR_CTRLR GAMEGROUP_AFTER_0 -#define GAMEGROUP_SIMULATION GAMEGROUP_AFTER_1 +#define GAMEGROUP_ENT_INPUT GAMEGROUP_INPUT +#define GAMEGROUP_ENT_PLATFORM GAMEGROUP_ENTITY +#define GAMEGROUP_ENT_MAIN GAMEGROUP_OTHER_1 +#define GAMEGROUP_EZP_CHAR_CTRLR GAMEGROUP_OTHER_2 +#define GAMEGROUP_SIMULATION GAMEGROUP_OTHER_3 #define LOL2BT_UNIT 1.0f #define BT2LOL_UNIT 1.0f diff --git a/doc/tutorial/07_input.cpp b/doc/tutorial/07_input.cpp index 0312a650..af4884be 100644 --- a/doc/tutorial/07_input.cpp +++ b/doc/tutorial/07_input.cpp @@ -25,6 +25,8 @@ public: InputTutorial() { m_controller = new Controller("Default"); + +# ifdef OLD_SCHOOL m_controller->SetInputCount(KEY_MAX, AXIS_MAX); m_keyboard = InputDevice::Get("Keyboard"); @@ -45,6 +47,20 @@ public: m_controller->GetAxis(AXIS_PITCH).Bind("Joystick1", "Axis2"); m_controller->GetAxis(AXIS_YAW).Bind("Joystick1", "Axis1"); } +# else + m_profile + << InputProfile::Keyboard(KEY_MANUAL_ROTATION, "Space") + << InputProfile::MouseKey(KEY_DRAG_MESH, "Left") + << InputProfile::JoystickAxis(1, AXIS_PITCH, "Axis2") + << InputProfile::JoystickAxis(1, AXIS_YAW, "Axis1") + << InputProfile::MouseAxis(AXIS_DRAG_PITCH, "Y") + << InputProfile::MouseAxis(AXIS_DRAG_YAW, "X"); + + m_controller->Init(m_profile); + m_keyboard = InputDevice::GetKeyboard(); + m_mouse = InputDevice::GetMouse(); + m_joystick = InputDevice::GetJoystick(1); +# endif //OLD_SCHOOL m_pitch_angle = 0; m_yaw_angle = 0; @@ -213,6 +229,7 @@ private: InputDevice *m_keyboard, *m_mouse, *m_joystick; Controller *m_controller; + InputProfile m_profile; bool m_autorot; float m_pitch_angle; diff --git a/src/camera.cpp b/src/camera.cpp index cc1aaca7..12f2ef81 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -25,7 +25,7 @@ namespace lol Camera::Camera() { - m_gamegroup = GAMEGROUP_BEFORE; + m_gamegroup = GAMEGROUP_CAMERA; m_drawgroup = DRAWGROUP_CAMERA; //Arbitrary values when g_renderer is not ready. diff --git a/src/debug/stats.cpp b/src/debug/stats.cpp index 258f8103..33f4efc9 100644 --- a/src/debug/stats.cpp +++ b/src/debug/stats.cpp @@ -38,7 +38,7 @@ DebugStats::DebugStats(char const *path) { data->fp = fopen(path, "w+"); - m_gamegroup = GAMEGROUP_AFTER; + m_gamegroup = GAMEGROUP_STATS; } void DebugStats::TickGame(float seconds) diff --git a/src/entity.cpp b/src/entity.cpp index 0c7627a6..fea10ac0 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -27,8 +27,8 @@ Entity::Entity() : #if !LOL_BUILD_RELEASE m_tickstate = STATE_IDLE; #endif - m_gamegroup = GAMEGROUP_DEFAULT; - m_drawgroup = DRAWGROUP_DEFAULT; + m_gamegroup = GAMEGROUP_ENTITY; + m_drawgroup = DRAWGROUP_ENTITY; Ticker::Register(this); } diff --git a/src/entity.h b/src/entity.h index 4114f847..140ba7ad 100644 --- a/src/entity.h +++ b/src/entity.h @@ -64,35 +64,53 @@ protected: enum { - GAMEGROUP_BEFORE = 0, - GAMEGROUP_DEFAULT, - GAMEGROUP_AFTER, - GAMEGROUP_AFTER_0, - GAMEGROUP_AFTER_1, - - // Must be the last element - GAMEGROUP_END + GAMEGROUP_BEGIN = 0, //Must be the first element + + GAMEGROUP_INPUT, //Input should be polled before everything else + GAMEGROUP_IMGUI, //Debug update needs to be called before the rest for init purposes + GAMEGROUP_ENTITY, //Default entity update + //------------------//Split entity update: + GAMEGROUP_PLAYER, //Player updates before AI to ensure player actions is prevalent + GAMEGROUP_AI, //AI update + GAMEGROUP_OTHER_0, //Other misc updates here + GAMEGROUP_OTHER_1, //Same ------------------ + GAMEGROUP_OTHER_2, //Same ------------------ + GAMEGROUP_OTHER_3, //Same ------------------ + //------------------//Primitives updates + GAMEGROUP_MESH, //Update Mesh/Animation to ensure correct sync with PLY/AI + GAMEGROUP_FX, //Update FX/other to ensure correct sync with WorldPos and Meshes + GAMEGROUP_LIGHT, //Update after FX because it could some + GAMEGROUP_CAMERA, //Update camera at the end of the frame, once everything is settled + GAMEGROUP_STATS, //Stats updates + + GAMEGROUP_END //Must be the last element } m_gamegroup; enum { - DRAWGROUP_BEFORE = GAMEGROUP_END, - DRAWGROUP_LIGHT, - DRAWGROUP_CAMERA, - DRAWGROUP_DEFAULT, - DRAWGROUP_AFTER, - DRAWGROUP_AFTER_0, - DRAWGROUP_AFTER_1, + DRAWGROUP_BEGIN = GAMEGROUP_END, + + DRAWGROUP_CAMERA, //Update camera first for rendering + DRAWGROUP_TEXTURE, //Texture + DRAWGROUP_LIGHT, // + DRAWGROUP_WORLD, //Other misc updates here + DRAWGROUP_ENTITY, // + DRAWGROUP_FX, // + DRAWGROUP_OTHER_0, //Other misc updates here + DRAWGROUP_OTHER_1, //Same ------------------ + DRAWGROUP_OTHER_2, //Same ------------------ + DRAWGROUP_OTHER_3, //Same ------------------ DRAWGROUP_HUD, + DRAWGROUP_IMGUI, DRAWGROUP_CAPTURE, - // Must be the last element - DRAWGROUP_END + + DRAWGROUP_END //Must be the last element } m_drawgroup; - static int const GAMEGROUP_BEGIN = 0; - static int const DRAWGROUP_BEGIN = GAMEGROUP_END; + //static int const GAMEGROUP_BEGIN = 0; + //static int const DRAWGROUP_BEGIN = GAMEGROUP_END; static int const ALLGROUP_END = DRAWGROUP_END; /* The initialisation state */ diff --git a/src/font.cpp b/src/font.cpp index 708d5ffd..4bebff56 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -43,7 +43,7 @@ Font::Font(char const *path) data->tileset = Tiler::Register(path, ivec2::zero, ivec2(16)); data->size = data->tileset->GetTileSize(0); - m_drawgroup = DRAWGROUP_BEFORE; + m_drawgroup = DRAWGROUP_TEXTURE; } Font::~Font() diff --git a/src/imgui/lolimgui.cpp b/src/imgui/lolimgui.cpp index d114681f..0f7515bd 100644 --- a/src/imgui/lolimgui.cpp +++ b/src/imgui/lolimgui.cpp @@ -19,8 +19,8 @@ using namespace lol; //----------------------------------------------------------------------------- LolImGui::LolImGui() { - m_gamegroup = GAMEGROUP_BEFORE; - m_drawgroup = DRAWGROUP_HUD; + m_gamegroup = GAMEGROUP_IMGUI; + m_drawgroup = DRAWGROUP_IMGUI; //Build shader code ------------------------------------------------------- ShaderVar out_vertex = ShaderVar::GetShaderOut(ShaderProgram::Vertex); diff --git a/src/input/controller.cpp b/src/input/controller.cpp index 90c9e710..3706a0ae 100644 --- a/src/input/controller.cpp +++ b/src/input/controller.cpp @@ -224,11 +224,12 @@ float AxisBinding::RetrieveCurrentValue() // Controller array Controller::controllers; +uint32_t Controller::m_active_layer = ~((uint32_t)0); //----------------------------------------------------------------------------- Controller::Controller(String const &name) { - m_gamegroup = GAMEGROUP_BEFORE; + m_gamegroup = GAMEGROUP_INPUT; m_name = name; m_activate_nextframe = true; m_deactivate_nextframe = false; @@ -277,9 +278,24 @@ void Controller::SetInputCount(int nb_keys, int nb_axis) m_axis.Resize(nb_axis); } +//Layer mask stuff ------------------------------------------------------------ +void Controller::SetLayerMask(uint32_t layer_mask) +{ + m_layer_mask = layer_mask; +} +uint32_t Controller::GetLayerMask() +{ + return m_layer_mask; +} +bool Controller::IsLayerActive() +{ + return !!(m_layer_mask & m_active_layer); +} + //GetKeys/Axis stuff ---------------------------------------------------------- KeyBinding& Controller::GetKey(int index) { +//#error do something better IsLayerActive() return m_keys[index]; } AxisBinding& Controller::GetAxis(int index) diff --git a/src/input/controller.h b/src/input/controller.h index 3f6b05a7..decc36dc 100644 --- a/src/input/controller.h +++ b/src/input/controller.h @@ -339,6 +339,13 @@ public: /** Init mode 2: By hand, key/axis by key/axis */ void SetInputCount(int nb_keys, int nb_axis); + /** layer mask stuff */ + void SetLayerMask(uint32_t layer_mask); + uint32_t GetLayerMask(); +protected: + bool IsLayerActive(); +public: + /** GetKeys/Axis stuff */ KeyBinding& GetKey(int index); AxisBinding& GetAxis(int index); @@ -351,9 +358,11 @@ protected: void BindProfile(InputProfile const& setup); private: + uint32_t m_layer_mask = 1; //plugged on the first by default array m_keys; array m_axis; + static uint32_t m_active_layer; //All active by default static array controllers; String m_name; bool m_activate_nextframe; diff --git a/src/light.cpp b/src/light.cpp index db1d3446..38e35283 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -20,8 +20,8 @@ Light::Light() : m_color(1.f), m_type(LightType::Directional) { - m_gamegroup = GAMEGROUP_BEFORE; - m_drawgroup = DRAWGROUP_CAMERA; + m_gamegroup = GAMEGROUP_LIGHT; + m_drawgroup = DRAWGROUP_LIGHT; SetPosition(vec3::zero); } diff --git a/src/platform/d3d9/d3d9input.cpp b/src/platform/d3d9/d3d9input.cpp index 58159391..98ea8ebe 100644 --- a/src/platform/d3d9/d3d9input.cpp +++ b/src/platform/d3d9/d3d9input.cpp @@ -81,7 +81,7 @@ D3d9Input::D3d9Input() } #endif - m_gamegroup = GAMEGROUP_BEFORE; + m_gamegroup = GAMEGROUP_INPUT; } D3d9Input::~D3d9Input() diff --git a/src/platform/sdl/sdlinput.cpp b/src/platform/sdl/sdlinput.cpp index a21c7fc7..af94edc3 100644 --- a/src/platform/sdl/sdlinput.cpp +++ b/src/platform/sdl/sdlinput.cpp @@ -198,7 +198,7 @@ SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h) # endif //EMSCRIPTEN #endif - m_gamegroup = GAMEGROUP_BEFORE; + m_gamegroup = GAMEGROUP_INPUT; } SdlInput::~SdlInput() diff --git a/src/platform/xbox/xboxinput.cpp b/src/platform/xbox/xboxinput.cpp index f5c08a7e..21827571 100644 --- a/src/platform/xbox/xboxinput.cpp +++ b/src/platform/xbox/xboxinput.cpp @@ -55,7 +55,7 @@ XboxInput::XboxInput() } #endif - m_gamegroup = GAMEGROUP_BEFORE; + m_gamegroup = GAMEGROUP_INPUT; } XboxInput::~XboxInput() diff --git a/src/sys/file.cpp b/src/sys/file.cpp index 25dc0554..74d71023 100644 --- a/src/sys/file.cpp +++ b/src/sys/file.cpp @@ -421,7 +421,7 @@ class DirectoryData } } //Go for next one - file_valid = (bool)FindNextFile(m_handle, &find_data); + file_valid = !!FindNextFile(m_handle, &find_data); } #elif HAVE_STDIO_H /* FIXME: not implemented */ @@ -604,7 +604,7 @@ bool Directory::SetCurrent(String directory) #elif defined(_WIN32) String result = directory; result.Replace('/', '\\', true); - return (bool)SetCurrentDirectory(result.C()); + return !!SetCurrentDirectory(result.C()); #elif HAVE_STDIO_H /* FIXME: not implemented */ #endif diff --git a/src/textureimage.cpp b/src/textureimage.cpp index bf76cf70..e51e6d8d 100644 --- a/src/textureimage.cpp +++ b/src/textureimage.cpp @@ -74,7 +74,7 @@ void TextureImage::Init(char const *path, Image* image) m_data->m_texture_size = ivec2(PotUp(m_data->m_image_size.x), PotUp(m_data->m_image_size.y)); - m_drawgroup = DRAWGROUP_BEFORE; + m_drawgroup = DRAWGROUP_TEXTURE; } void TextureImage::TickDraw(float seconds, Scene &scene)