Browse Source

Revamped Game/Draw groups to split stuff and help spreading tick

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 9 years ago
parent
commit
0e09074d33
16 changed files with 100 additions and 40 deletions
  1. +5
    -5
      doc/samples/physics/lolbtphysicsintegration.h
  2. +17
    -0
      doc/tutorial/07_input.cpp
  3. +1
    -1
      src/camera.cpp
  4. +1
    -1
      src/debug/stats.cpp
  5. +2
    -2
      src/entity.cpp
  6. +37
    -19
      src/entity.h
  7. +1
    -1
      src/font.cpp
  8. +2
    -2
      src/imgui/lolimgui.cpp
  9. +17
    -1
      src/input/controller.cpp
  10. +9
    -0
      src/input/controller.h
  11. +2
    -2
      src/light.cpp
  12. +1
    -1
      src/platform/d3d9/d3d9input.cpp
  13. +1
    -1
      src/platform/sdl/sdlinput.cpp
  14. +1
    -1
      src/platform/xbox/xboxinput.cpp
  15. +2
    -2
      src/sys/file.cpp
  16. +1
    -1
      src/textureimage.cpp

+ 5
- 5
doc/samples/physics/lolbtphysicsintegration.h View File

@@ -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


+ 17
- 0
doc/tutorial/07_input.cpp View File

@@ -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;


+ 1
- 1
src/camera.cpp View File

@@ -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.


+ 1
- 1
src/debug/stats.cpp View File

@@ -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)


+ 2
- 2
src/entity.cpp View File

@@ -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);
}



+ 37
- 19
src/entity.h View File

@@ -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 */


+ 1
- 1
src/font.cpp View File

@@ -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()


+ 2
- 2
src/imgui/lolimgui.cpp View File

@@ -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);


+ 17
- 1
src/input/controller.cpp View File

@@ -224,11 +224,12 @@ float AxisBinding::RetrieveCurrentValue()
// Controller

array<Controller*> 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)


+ 9
- 0
src/input/controller.h View File

@@ -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<KeyBinding> m_keys;
array<AxisBinding> m_axis;

static uint32_t m_active_layer; //All active by default
static array<Controller*> controllers;
String m_name;
bool m_activate_nextframe;


+ 2
- 2
src/light.cpp View File

@@ -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);
}


+ 1
- 1
src/platform/d3d9/d3d9input.cpp View File

@@ -81,7 +81,7 @@ D3d9Input::D3d9Input()
}
#endif

m_gamegroup = GAMEGROUP_BEFORE;
m_gamegroup = GAMEGROUP_INPUT;
}

D3d9Input::~D3d9Input()


+ 1
- 1
src/platform/sdl/sdlinput.cpp View File

@@ -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()


+ 1
- 1
src/platform/xbox/xboxinput.cpp View File

@@ -55,7 +55,7 @@ XboxInput::XboxInput()
}
#endif

m_gamegroup = GAMEGROUP_BEFORE;
m_gamegroup = GAMEGROUP_INPUT;
}

XboxInput::~XboxInput()


+ 2
- 2
src/sys/file.cpp View File

@@ -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


+ 1
- 1
src/textureimage.cpp View File

@@ -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)


Loading…
Cancel
Save