@@ -21,11 +21,11 @@ namespace lol | |||||
//Override Gamegroups names for Physic-usage | //Override Gamegroups names for Physic-usage | ||||
//"_ENT_" means that this is a group for Entities that use EasyPhysic primitives. | //"_ENT_" means that this is a group for Entities that use EasyPhysic primitives. | ||||
//"_EZP_" means that this is a group for 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 LOL2BT_UNIT 1.0f | ||||
#define BT2LOL_UNIT 1.0f | #define BT2LOL_UNIT 1.0f | ||||
@@ -25,6 +25,8 @@ public: | |||||
InputTutorial() | InputTutorial() | ||||
{ | { | ||||
m_controller = new Controller("Default"); | m_controller = new Controller("Default"); | ||||
# ifdef OLD_SCHOOL | |||||
m_controller->SetInputCount(KEY_MAX, AXIS_MAX); | m_controller->SetInputCount(KEY_MAX, AXIS_MAX); | ||||
m_keyboard = InputDevice::Get("Keyboard"); | m_keyboard = InputDevice::Get("Keyboard"); | ||||
@@ -45,6 +47,20 @@ public: | |||||
m_controller->GetAxis(AXIS_PITCH).Bind("Joystick1", "Axis2"); | m_controller->GetAxis(AXIS_PITCH).Bind("Joystick1", "Axis2"); | ||||
m_controller->GetAxis(AXIS_YAW).Bind("Joystick1", "Axis1"); | 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_pitch_angle = 0; | ||||
m_yaw_angle = 0; | m_yaw_angle = 0; | ||||
@@ -213,6 +229,7 @@ private: | |||||
InputDevice *m_keyboard, *m_mouse, *m_joystick; | InputDevice *m_keyboard, *m_mouse, *m_joystick; | ||||
Controller *m_controller; | Controller *m_controller; | ||||
InputProfile m_profile; | |||||
bool m_autorot; | bool m_autorot; | ||||
float m_pitch_angle; | float m_pitch_angle; | ||||
@@ -25,7 +25,7 @@ namespace lol | |||||
Camera::Camera() | Camera::Camera() | ||||
{ | { | ||||
m_gamegroup = GAMEGROUP_BEFORE; | |||||
m_gamegroup = GAMEGROUP_CAMERA; | |||||
m_drawgroup = DRAWGROUP_CAMERA; | m_drawgroup = DRAWGROUP_CAMERA; | ||||
//Arbitrary values when g_renderer is not ready. | //Arbitrary values when g_renderer is not ready. | ||||
@@ -38,7 +38,7 @@ DebugStats::DebugStats(char const *path) | |||||
{ | { | ||||
data->fp = fopen(path, "w+"); | data->fp = fopen(path, "w+"); | ||||
m_gamegroup = GAMEGROUP_AFTER; | |||||
m_gamegroup = GAMEGROUP_STATS; | |||||
} | } | ||||
void DebugStats::TickGame(float seconds) | void DebugStats::TickGame(float seconds) | ||||
@@ -27,8 +27,8 @@ Entity::Entity() : | |||||
#if !LOL_BUILD_RELEASE | #if !LOL_BUILD_RELEASE | ||||
m_tickstate = STATE_IDLE; | m_tickstate = STATE_IDLE; | ||||
#endif | #endif | ||||
m_gamegroup = GAMEGROUP_DEFAULT; | |||||
m_drawgroup = DRAWGROUP_DEFAULT; | |||||
m_gamegroup = GAMEGROUP_ENTITY; | |||||
m_drawgroup = DRAWGROUP_ENTITY; | |||||
Ticker::Register(this); | Ticker::Register(this); | ||||
} | } | ||||
@@ -64,35 +64,53 @@ protected: | |||||
enum | 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; | m_gamegroup; | ||||
enum | 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_HUD, | ||||
DRAWGROUP_IMGUI, | |||||
DRAWGROUP_CAPTURE, | DRAWGROUP_CAPTURE, | ||||
// Must be the last element | |||||
DRAWGROUP_END | |||||
DRAWGROUP_END //Must be the last element | |||||
} | } | ||||
m_drawgroup; | 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; | static int const ALLGROUP_END = DRAWGROUP_END; | ||||
/* The initialisation state */ | /* The initialisation state */ | ||||
@@ -43,7 +43,7 @@ Font::Font(char const *path) | |||||
data->tileset = Tiler::Register(path, ivec2::zero, ivec2(16)); | data->tileset = Tiler::Register(path, ivec2::zero, ivec2(16)); | ||||
data->size = data->tileset->GetTileSize(0); | data->size = data->tileset->GetTileSize(0); | ||||
m_drawgroup = DRAWGROUP_BEFORE; | |||||
m_drawgroup = DRAWGROUP_TEXTURE; | |||||
} | } | ||||
Font::~Font() | Font::~Font() | ||||
@@ -19,8 +19,8 @@ using namespace lol; | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
LolImGui::LolImGui() | LolImGui::LolImGui() | ||||
{ | { | ||||
m_gamegroup = GAMEGROUP_BEFORE; | |||||
m_drawgroup = DRAWGROUP_HUD; | |||||
m_gamegroup = GAMEGROUP_IMGUI; | |||||
m_drawgroup = DRAWGROUP_IMGUI; | |||||
//Build shader code ------------------------------------------------------- | //Build shader code ------------------------------------------------------- | ||||
ShaderVar out_vertex = ShaderVar::GetShaderOut(ShaderProgram::Vertex); | ShaderVar out_vertex = ShaderVar::GetShaderOut(ShaderProgram::Vertex); | ||||
@@ -224,11 +224,12 @@ float AxisBinding::RetrieveCurrentValue() | |||||
// Controller | // Controller | ||||
array<Controller*> Controller::controllers; | array<Controller*> Controller::controllers; | ||||
uint32_t Controller::m_active_layer = ~((uint32_t)0); | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
Controller::Controller(String const &name) | Controller::Controller(String const &name) | ||||
{ | { | ||||
m_gamegroup = GAMEGROUP_BEFORE; | |||||
m_gamegroup = GAMEGROUP_INPUT; | |||||
m_name = name; | m_name = name; | ||||
m_activate_nextframe = true; | m_activate_nextframe = true; | ||||
m_deactivate_nextframe = false; | m_deactivate_nextframe = false; | ||||
@@ -277,9 +278,24 @@ void Controller::SetInputCount(int nb_keys, int nb_axis) | |||||
m_axis.Resize(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 ---------------------------------------------------------- | //GetKeys/Axis stuff ---------------------------------------------------------- | ||||
KeyBinding& Controller::GetKey(int index) | KeyBinding& Controller::GetKey(int index) | ||||
{ | { | ||||
//#error do something better IsLayerActive() | |||||
return m_keys[index]; | return m_keys[index]; | ||||
} | } | ||||
AxisBinding& Controller::GetAxis(int index) | AxisBinding& Controller::GetAxis(int index) | ||||
@@ -339,6 +339,13 @@ public: | |||||
/** Init mode 2: By hand, key/axis by key/axis */ | /** Init mode 2: By hand, key/axis by key/axis */ | ||||
void SetInputCount(int nb_keys, int nb_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 */ | /** GetKeys/Axis stuff */ | ||||
KeyBinding& GetKey(int index); | KeyBinding& GetKey(int index); | ||||
AxisBinding& GetAxis(int index); | AxisBinding& GetAxis(int index); | ||||
@@ -351,9 +358,11 @@ protected: | |||||
void BindProfile(InputProfile const& setup); | void BindProfile(InputProfile const& setup); | ||||
private: | private: | ||||
uint32_t m_layer_mask = 1; //plugged on the first by default | |||||
array<KeyBinding> m_keys; | array<KeyBinding> m_keys; | ||||
array<AxisBinding> m_axis; | array<AxisBinding> m_axis; | ||||
static uint32_t m_active_layer; //All active by default | |||||
static array<Controller*> controllers; | static array<Controller*> controllers; | ||||
String m_name; | String m_name; | ||||
bool m_activate_nextframe; | bool m_activate_nextframe; | ||||
@@ -20,8 +20,8 @@ Light::Light() | |||||
: m_color(1.f), | : m_color(1.f), | ||||
m_type(LightType::Directional) | m_type(LightType::Directional) | ||||
{ | { | ||||
m_gamegroup = GAMEGROUP_BEFORE; | |||||
m_drawgroup = DRAWGROUP_CAMERA; | |||||
m_gamegroup = GAMEGROUP_LIGHT; | |||||
m_drawgroup = DRAWGROUP_LIGHT; | |||||
SetPosition(vec3::zero); | SetPosition(vec3::zero); | ||||
} | } | ||||
@@ -81,7 +81,7 @@ D3d9Input::D3d9Input() | |||||
} | } | ||||
#endif | #endif | ||||
m_gamegroup = GAMEGROUP_BEFORE; | |||||
m_gamegroup = GAMEGROUP_INPUT; | |||||
} | } | ||||
D3d9Input::~D3d9Input() | D3d9Input::~D3d9Input() | ||||
@@ -198,7 +198,7 @@ SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h) | |||||
# endif //EMSCRIPTEN | # endif //EMSCRIPTEN | ||||
#endif | #endif | ||||
m_gamegroup = GAMEGROUP_BEFORE; | |||||
m_gamegroup = GAMEGROUP_INPUT; | |||||
} | } | ||||
SdlInput::~SdlInput() | SdlInput::~SdlInput() | ||||
@@ -55,7 +55,7 @@ XboxInput::XboxInput() | |||||
} | } | ||||
#endif | #endif | ||||
m_gamegroup = GAMEGROUP_BEFORE; | |||||
m_gamegroup = GAMEGROUP_INPUT; | |||||
} | } | ||||
XboxInput::~XboxInput() | XboxInput::~XboxInput() | ||||
@@ -421,7 +421,7 @@ class DirectoryData | |||||
} | } | ||||
} | } | ||||
//Go for next one | //Go for next one | ||||
file_valid = (bool)FindNextFile(m_handle, &find_data); | |||||
file_valid = !!FindNextFile(m_handle, &find_data); | |||||
} | } | ||||
#elif HAVE_STDIO_H | #elif HAVE_STDIO_H | ||||
/* FIXME: not implemented */ | /* FIXME: not implemented */ | ||||
@@ -604,7 +604,7 @@ bool Directory::SetCurrent(String directory) | |||||
#elif defined(_WIN32) | #elif defined(_WIN32) | ||||
String result = directory; | String result = directory; | ||||
result.Replace('/', '\\', true); | result.Replace('/', '\\', true); | ||||
return (bool)SetCurrentDirectory(result.C()); | |||||
return !!SetCurrentDirectory(result.C()); | |||||
#elif HAVE_STDIO_H | #elif HAVE_STDIO_H | ||||
/* FIXME: not implemented */ | /* FIXME: not implemented */ | ||||
#endif | #endif | ||||
@@ -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), | m_data->m_texture_size = ivec2(PotUp(m_data->m_image_size.x), | ||||
PotUp(m_data->m_image_size.y)); | PotUp(m_data->m_image_size.y)); | ||||
m_drawgroup = DRAWGROUP_BEFORE; | |||||
m_drawgroup = DRAWGROUP_TEXTURE; | |||||
} | } | ||||
void TextureImage::TickDraw(float seconds, Scene &scene) | void TextureImage::TickDraw(float seconds, Scene &scene) | ||||