Skip to content

Commit 39846b1

Browse files
authored
Merge pull request #149 from GP-Engine-team/develop
GOLD
2 parents 259236e + b1a03ff commit 39846b1

File tree

87 files changed

+2362
-827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2362
-827
lines changed

README.md

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Green Portal Engine
22

3+
![](https://i.postimg.cc/PqK3mQgT/engine.png)
4+
![](https://i.postimg.cc/xdtknXz6/game.png)
5+
6+
37
## Documents
48
[Production Pipeline document](https://docs.google.com/document/d/16_K5LYEYgaHoLp3JxO0UqVd54PJbOMVTss-FqXLqL3I/)
59
[Architecture diagrams](https://drive.google.com/drive/folders/1BV3M4kYvesof0PHtpZnjXgYIOzirfpd5)
6-
[Google Drive](https://drive.google.com/drive/folders/13uqdCMKSp5BYv3FkD2sflDcJ6F_QaaVE)
10+
[Google Drive](https://drive.google.com/drive/folders/13uqdCMKSp5BYv3FkD2sflDcJ6F_QaaVE)
711

812

913
## Getting started
@@ -12,35 +16,64 @@
1216
```batch
1317
git clone --recurse-submodules https://github.com/GP-Engine-team/GP_Engine.git
1418
```
15-
2. Download the assets [from the Drive](https://drive.google.com/drive/folders/1ElLiWl6cP_Z3WOdevMU3CpLjCIND17XD) and extract them from the root of your local copy of this repository (individually, or
19+
If you already cloned the repository, you can use:
20+
```
21+
git submodule update
22+
```
23+
24+
2. Download the assets [from the Drive](https://drive.google.com/drive/folders/1ElLiWl6cP_Z3WOdevMU3CpLjCIND17XD) (`projects` folder or `project.zip`) and extract them from the root of your local copy of this repository
1625
3. Open [projects/GPGame/GPGame.sln](projects/GPGame/GPGame.sln) in Visual Studio
1726
4. **Either set the "GPLauncher" or "GPEditor" project as startup project** to launch the game alone, or with the editor, respectively
1827
5. Choose either Debug or Release mode, and hit F5 to compile
1928

20-
21-
## Controls, features
22-
23-
| Key | Action |
24-
|-------|------------------|
25-
| S | Move backward |
26-
| Z | Move forward |
27-
| Q | Strafe left |
28-
| D | Strafe right |
29-
| Space | Jump |
30-
| Shift | Toggle sprint |
31-
| Esc | Exit the program |
29+
Here is a [link toward a build](https://drive.google.com/file/d/1dIkGqgNC_5oT-BVQ8gtu9o-6xPqjjMRD/view?usp=sharing).
30+
31+
32+
## Features
33+
- [x] Fully-fledged game editor with various edition tools
34+
- [x] Game launcher
35+
- [x] Serialization
36+
- [x] Reflexion
37+
- [x] Resource manager
38+
- [x] Custom resource and resource importation under multiple formats (.fbx, .obj, .wav, .jpeg, ...)
39+
- [x] Custom prefab exportation and importation
40+
- [x] Sound (Stereo, mono, spatialized)
41+
- [x] In-game UI
42+
- [x] Lights
43+
- [x] Shadows
44+
- [x] Scripts
45+
- [x] Hot reload with Visual Studio
46+
- [x] Particle system
47+
- [x] Animation system
48+
- [x] PhysX-based physics
49+
- [x] Custom math library implemented with unit tests (see the [GPM repository](https://github.com/GP-Engine-team/gpm))
50+
- [x] A game made entirely with the engine's editor
51+
52+
53+
## Game controls
54+
55+
| Key | Action |
56+
|-------------|------------------|
57+
| S | Move backward |
58+
| Z | Move forward |
59+
| Q | Strafe left |
60+
| D | Strafe right |
61+
| R | Reload |
62+
| Space | Jump |
63+
| Shift | Toggle sprint |
64+
| Right-click | Aim |
65+
| Left-click | Fire |
66+
| Esc | Exit the program |
3267

3368

3469
## Known bugs
35-
- Sounds are sometimes played with lags, in a fragmented way
36-
- Inputs declared in game-code collide with inputs declared in editor-code
37-
- When the editor's window is minimized, OpenGL errors are raised and visible in the console
38-
- The `ResourceManager` can't take a single template argument
70+
- Sounds sometimes stutter when there are several sources playing sound simultaneously
71+
- On older/low-end machines, FPS drops may sometimes be experienced
3972

40-
## Repository folders architecture
4173

74+
## Repository folders architecture
4275
- `editor/`: code relative to the editor
43-
- `engine/`: the heart of the C++ API
76+
- `engine/`: the heart of the engine's C++ API
4477
- `generator/`: reflexion with Refureku
4578
- `launcher/`: game-only launcher code
4679
- `projects/`: where the games made with the engine are edited
@@ -50,7 +83,7 @@ git clone --recurse-submodules https://github.com/GP-Engine-team/GP_Engine.git
5083
The following diagram, as well as other more specific UML diagrams, are [available on the project's Google Drive](https://drive.google.com/drive/folders/1BV3M4kYvesof0PHtpZnjXgYIOzirfpd5).
5184

5285
Click the image to get a zoomable version of it.
53-
[![Global architecture diagram](https://i.postimg.cc/2ynPdCtG/Global-project-architecture.png)](https://postimg.cc/1V5Cs1sV)
86+
[![Global architecture diagram](https://i.postimg.cc/yYQ1561h/Global-project-architecture.png)](https://postimg.cc/bsnfSh2d)
5487

5588
## Dependencies
5689

@@ -63,6 +96,6 @@ Click the image to get a zoomable version of it.
6396
- [glad](https://github.com/Dav1dde/glad) with [GL_KHR_Debug](https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt)
6497
- [stb_image](https://github.com/nothings/stb/blob/master/stb_image.h)
6598
- [stb_image_write](https://github.com/nothings/stb/blob/master/stb_image_write.h)
66-
- [stb_perlin](https://github.com/nothings/stb/blob/master/stb_perlin.h)
6799
- [Refureku](https://github.com/jsoysouvanh/Refureku)
68100
- [RapidXML](http://rapidxml.sourceforge.net/manual.html)
101+
- [ImGuizmo](https://github.com/CedricGuillemet/ImGuizmo)

editor/include/Editor/Editor.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ class Editor
3737
GLFWwindow* m_window;
3838

3939
public:
40-
std::string paperPress;
4140
SceneEditor sceneEditor;
4241
GameViewer gameViewer;
4342
LogInspector logInspector;
4443
ProjectContent projectContent;
4544
SceneGraph sceneGraph;
4645
GameControlBar gameControlBar;
46+
std::string paperPress;
4747
std::string saveFolder;
4848
GPE::IInspectable* inspectedObject;
4949
GPE::ReloadableCpp* reloadableCpp;
@@ -56,6 +56,7 @@ class Editor
5656

5757
private:
5858
void setupDearImGui();
59+
void setupWindowIcon();
5960

6061
void renderLog();
6162
void renderStyleEditor();

editor/include/Editor/GameViewer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class GameViewer
2727
bool cursorTrackingStateInGame = false;
2828
bool setMouseInWindow = false;
2929

30+
void checkInputs(EditorStartup& startup);
31+
3032
public:
3133
GameViewer(int width = 1, int height = 1);
3234

editor/include/Editor/ProjectContent.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ struct DirectoryInfo
6161
}
6262
return rst;
6363
}
64+
65+
size_t computeSize() const
66+
{
67+
size_t rst = 0;
68+
69+
for (auto&& it = files.cbegin(); it != files.cend(); ++it)
70+
{
71+
rst += it->size;
72+
}
73+
74+
for (auto&& it = directories.cbegin(); it != directories.cend(); ++it)
75+
{
76+
rst += it->computeSize();
77+
}
78+
return rst;
79+
}
6480
};
6581

6682
class ProjectContent
67.5 KB
Loading

editor/src/Editor.cpp

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <imgui/backends/imgui_impl_glfw.h>
2424
#include <imgui/backends/imgui_impl_opengl3.h>
2525
#include <imgui/imgui.h>
26+
#include <stb/stb_image.h>
2627

2728
using namespace GPE;
2829

@@ -50,6 +51,20 @@ void Editor::setupDearImGui()
5051
ImGuiLoadStyle(PATH_UI_STYLE, ImGui::GetStyle());
5152
}
5253

54+
55+
void Editor::setupWindowIcon()
56+
{
57+
GLFWimage icon;
58+
59+
icon.pixels = stbi_load("..\\..\\editor\\resources\\icone\\green_portal.png",
60+
&icon.width, &icon.height, nullptr, 4);
61+
62+
glfwSetWindowIcon(m_window, 1, &icon);
63+
64+
stbi_image_free(icon.pixels);
65+
}
66+
67+
5368
void Editor::renderStyleEditor()
5469
{
5570
if (showAppStyleEditor)
@@ -78,6 +93,8 @@ void Editor::renderMenuBar()
7893
//{
7994
// sceneEditor.view.unbindScene();
8095
// Scene& scene = Engine::getInstance()->sceneManager.setCurrentScene(fileName);
96+
// if (Engine::getInstance()->sceneManager.OnSceneChange)
97+
// Engine::getInstance()->sceneManager.OnSceneChange();
8198
// loadScene(&scene, path.c_str());
8299
//}
83100

@@ -304,7 +321,8 @@ void Editor::renderShadowMap()
304321
const ImVec2 size{ImGui::GetContentRegionAvail()};
305322
ImGui::Image((void*)(intptr_t)Engine::getInstance()
306323
->sceneManager.getCurrentScene()
307-
->sceneRenderer.getShadowMap()->depthMap,
324+
->sceneRenderer.getShadowMap()
325+
->depthMap,
308326
size, {.0f, 1.f}, {1.f, .0f});
309327
}
310328
else
@@ -391,11 +409,24 @@ void Editor::unbindCurrentScene()
391409

392410
/* ========================== Constructor & destructor ========================== */
393411
Editor::Editor(GLFWwindow* window, GPE::Scene& editedScene)
394-
: sceneEditor(editedScene), gameViewer{}, logInspector{}, projectContent(*this),
395-
sceneGraph(*this), gameControlBar{}, saveFolder{}, m_window{window}, inspectedObject{nullptr},
396-
showAppStyleEditor{false}, showImGuiDemoWindows{false}
412+
: sceneEditor (editedScene),
413+
gameViewer {},
414+
logInspector {},
415+
projectContent (*this),
416+
sceneGraph (*this),
417+
gameControlBar {},
418+
paperPress {},
419+
saveFolder {},
420+
m_window {window},
421+
inspectedObject {nullptr},
422+
reloadableCpp {nullptr},
423+
showAppStyleEditor {false},
424+
showImGuiDemoWindows{false},
425+
showShadowMap {false},
426+
OnUIBeginFrame {}
397427
{
398428
setupDearImGui();
429+
setupWindowIcon();
399430
}
400431

401432
void Editor::setSceneInEdition(GPE::Scene& scene)
@@ -447,14 +478,14 @@ void Editor::updateKeyboardShorthand(EditorStartup& startup)
447478
if (!sceneEditor.view.capturingInputs() && ImGui::IsKeyPressed(GLFW_KEY_S) &&
448479
(ImGui::IsKeyDown(GLFW_KEY_LEFT_CONTROL) || ImGui::IsKeyDown(GLFW_KEY_RIGHT_CONTROL)))
449480
{
450-
if (startup.game().state == EGameState::STOPPED
451-
|| (ImGui::IsKeyDown(GLFW_KEY_RIGHT_SHIFT) || ImGui::IsKeyDown(GLFW_KEY_LEFT_SHIFT)))
481+
if (startup.game().state == EGameState::STOPPED ||
482+
(ImGui::IsKeyDown(GLFW_KEY_RIGHT_SHIFT) || ImGui::IsKeyDown(GLFW_KEY_LEFT_SHIFT)))
452483
{
453484
saveCurrentScene();
454485
}
455486
}
456487

457-
if (!sceneEditor.view.capturingInputs() && ImGui::IsKeyPressed(GLFW_KEY_C) &&
488+
if (!sceneEditor.view.capturingInputs() && !ImGui::IsAnyItemActive() && ImGui::IsKeyPressed(GLFW_KEY_C) &&
458489
(ImGui::IsKeyDown(GLFW_KEY_LEFT_CONTROL) || ImGui::IsKeyDown(GLFW_KEY_RIGHT_CONTROL)))
459490
{
460491
if (GameObject* inspectedGo = dynamic_cast<GameObject*>(inspectedObject))
@@ -464,7 +495,7 @@ void Editor::updateKeyboardShorthand(EditorStartup& startup)
464495
}
465496
}
466497

467-
if (!sceneEditor.view.capturingInputs() && ImGui::IsKeyPressed(GLFW_KEY_V) &&
498+
if (!sceneEditor.view.capturingInputs() && !ImGui::IsAnyItemActive() && ImGui::IsKeyPressed(GLFW_KEY_V) &&
468499
(ImGui::IsKeyDown(GLFW_KEY_LEFT_CONTROL) || ImGui::IsKeyDown(GLFW_KEY_RIGHT_CONTROL)))
469500
{
470501
if (paperPress.size())

editor/src/EditorStartup.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ void EditorStartup::openGame()
150150
io.setCursorTrackingState(false);
151151
}
152152

153-
// Ending the game must not close the whole engine when the editor is opened
154-
// The editor handles exiting the whole application itself
155-
m_engine->exit = [&]() { m_editor.releaseGameInputs(); };
156-
157153
// If the editor was not already shown, show it after the game is fully instanciated
158154
glfwMaximizeWindow(GPE::Engine::getInstance()->window.getGLFWWindow());
159155
}
@@ -175,22 +171,18 @@ void EditorStartup::closeGame()
175171

176172
// TODO: are the scenes previously loaded removed by m_game's destructor?
177173
m_editor.setSceneInEdition(m_engine->sceneManager.setCurrentScene("Default scene"));
178-
179-
// There is no more active game, replace m_engine->exit to something not dependant on m_game
180-
m_engine->exit = [&]() { m_engine->window.close(); };
181174
}
182175

183176
void EditorStartup::playGame()
184177
{
185-
m_engine->sceneManager.getCurrentScene()->behaviourSystem.onGameAssert = [&](const char* msg)
186-
{
178+
m_engine->sceneManager.getCurrentScene()->behaviourSystem.onGameAssert = [&](const char* msg) {
187179
Log::getInstance()->logError(msg);
188180
stopGame();
189181
};
190182

191183
Engine::getInstance()->sceneManager.OnSceneChange = std::bind(&EditorStartup::startScene, this);
192184

193-
//m_editor.gameViewer.lockInputToGame();
185+
// m_editor.gameViewer.lockInputToGame();
194186

195187
if (m_game->state == EGameState::STOPPED)
196188
{
@@ -201,10 +193,10 @@ void EditorStartup::playGame()
201193
m_fixedUpdate = [&](double fixedUnscaledDeltaTime, double fixedDeltaTime) {
202194
if (m_game->state == EGameState::PLAYING)
203195
{
204-
m_engine->physXSystem.advance(fixedDeltaTime);
205196
m_engine->sceneManager.getCurrentScene()->behaviourSystem.fixedUpdate(fixedDeltaTime);
206-
207197
m_game->fixedUpdate(fixedUnscaledDeltaTime, fixedDeltaTime);
198+
m_engine->physXSystem.updateController(fixedDeltaTime);
199+
m_engine->physXSystem.advance(fixedDeltaTime);
208200
}
209201
};
210202

@@ -244,6 +236,10 @@ void EditorStartup::playGame()
244236
m_engine->inputManager.setCursorLockState(false);
245237
m_engine->inputManager.setCursorTrackingState(false);
246238
m_engine->inputManager.setCursorMode(GLFW_CURSOR);
239+
240+
// Ending the game must not close the whole engine when the editor is opened
241+
// The editor handles exiting the whole application itself
242+
m_engine->exit = [&]() { m_editor.releaseGameInputs(); };
247243
}
248244

249245
void EditorStartup::pauseGame()
@@ -277,6 +273,9 @@ void EditorStartup::stopGame()
277273
if (m_game->state == EGameState::STOPPED)
278274
return;
279275

276+
// reset time scale
277+
m_engine->timeSystem.setTimeScale(1.f);
278+
280279
m_engine->soundSystem.stopAllComponents();
281280
m_engine->sceneManager.getCurrentScene()->behaviourSystem.startOnBehaviourAdd = false;
282281
m_engine->sceneManager.getCurrentScene()->behaviourSystem.onGameAssert = nullptr;
@@ -302,6 +301,9 @@ void EditorStartup::stopGame()
302301
}
303302
};
304303

304+
// There is no more active game, replace m_engine->exit to something not dependant on m_game
305+
m_engine->exit = [&]() { m_engine->window.close(); };
306+
305307
m_editor.reloadCurrentScene();
306308
m_game->state = EGameState::STOPPED;
307309
}
@@ -334,6 +336,7 @@ void EditorStartup::update()
334336

335337
void EditorStartup::startScene()
336338
{
339+
m_editor.inspectedObject = nullptr;
337340
m_editor.setSceneInEdition(*GPE::Engine::getInstance()->sceneManager.getCurrentScene());
338341
GPE::Engine::getInstance()->sceneManager.getCurrentScene()->behaviourSystem.start();
339342
}

0 commit comments

Comments
 (0)