Code Monkey home page Code Monkey logo

rythe-engine's Introduction

rythe logo banner build analyze License-MIT Discord

Rythe-Engine

Rythe-Engine is a data oriented C++17 game engine built to make optimal use of modern hardware.

Rythe's core is built on an async compute minded design to take care of the logic and an ECS to take care of the data. This allows the engine, its other modules, and the editor to utilize all the power they can find and to be extremely modular.

The engine's modules are separated into optional git submodules; links to them can be found in their respective folders in rythe/engine/.

Features

Rendering

  • Post-processing stack
  • Particle system
  • PBR
  • Imgui
  • Automatic exposure
  • Modular rendering pipeline
  • Custom shader support & shader standard library
  • shader precompiler lgnspre
  • GLTF & OBJ support

Physics

  • Convex quick hull generation
  • Diviner physics engine

Preview Feature

  • Dynamic Destruction Demo

ECS

  • Data oriented
  • Thread-safe
  • "Archetype" support

Eventsystem

  • Thread-safe eventbus
  • Unique & Persistent events
  • easy extensebility

Audio

  • Spatial audio
  • Non-spatial audio
  • Dopplereffect
  • MP3 & WAV support
  • Stereo->Mono conversion

Compute

  • OpenCL frontend with support for buffers & textures
  • High level abstractions

Misc

  • Virtual filesystem
  • Serialization & Scenes(Alpha)
  • Job scheduling
  • Pipeline scheduling for multiple main threads
  • Modular Processchains
  • Custom logging support
  • Custom input system
  • Extended standard library
  • Modular Architecture
  • Math extensions to GLM

CMake

Rythe uses CMake to generate its project files. The CMake script recognizes git submodules and adds configurable options to enable/disable them in the cache.

Using this system, you can easily generate a project with the modules that you need. Adding new modules is also simple and requires no CMake modification, see the Adding new modules section for more.

Supported configurations

Platform Compiler
Windows 10+ LLVM-Clang
Ubuntu 20.04 Clang++

All configurations use C++17 on the x64 architecture.

Building

Rythe-Engine uses CMake 3.16, make sure to install a CMake version that is the same or higher (https://cmake.org/install/).

If you haven't yet cloned the repository, start with that:

cd repositories/
git clone https://github.com/Rythe-Interactive/Rythe-Engine.git

CMake projects are built using a command-line interface, or through the GUI. We'll describe the command-line approach here. Note particularly the -T ClangCL parameter; this is to select the LLVM Clang toolchain in Visual Studio.

cd repositories
cmake -E make_directory Rythe-Engine-Build
cmake . 
    -G "Visual Studio 16 2019" 
    -S Rythe-Engine/ 
    -B Rythe-Engine-Build/
    -T ClangCL

Enable/disable optional parameters by adding them to the last command using -D<PARAMETER_NAME>=ON Optional parameters to add to the last command are:

Parameter Description
RYTHE_BUILD_APPLICATIONS Add applications to the project files. The engine provides a sandbox application in the root repository, but modules may also provide their own (sandbox, samples, etc.).
RYTHE_BUILD_OPTION_ASAN Enable the address sanitizer. Can be useful/important for debugging memory violations.
RYTHE_FORCE_ENABLE_ALL_MODULES Forcefully enable every available module. This is mostly used for CI reasons but you may use this for convenience as well.
RYTHE_MODULE_<NAME> If enabled, the module with the given name (the parameter is uppercase, the module lowercase), will be added to the build.

You may now either open the project, or build the engine using the CLI:

cmake --build Rythe-Engine-Build/ --config Debug

Adding new modules

We recommend using the module template to create new modules, but it is also possible to set up the cmake scripts manually - if you wish to do so, refer to the build system API documentation for expected cmake scripts, and the usage patterns of helper functions.

To add a new module: Create a new repository using the instructions on the repository template at https://github.com/Rythe-Interactive/Rythe-Module-Template.

Assuming you have previously cloned Rythe-Engine, go to its root folder and add the git submodule the following commmand:

git submodule add <link> rythe/engine/<name>

This modifies two things; the gitmodules file and a separate commit hash file. Make sure to commit/push these changes to the branch of your choice.

After having added the git submodule, simply configure CMake with RYTHE_MODULE_<NAME>=ON, or with the checkbox checked in the CMake GUI as discussed in the building section.

Setup

Legion already defines the C++ entry point in it's own source code. So in order to start making a program define LEGION_ENTRY and include any of modules main include files. eg:

#define LEGION_ENTRY
#include <core/core.hpp>

Since the entry point is already defined you need to define a different function to start working with Legion. Legion will already start itself, but it won't have any modules attached. In order to attach modules you need to define the reportModules function like so:

#include "mymodule.hpp"
using namespace legion;

void LEGION_CCONV reportModules(Engine* engine)
{
    engine->reportModule<MyModule>();
    engine->reportModule<app::ApplicationModule>();
}

Of course in order to link your own modules you need to make one:

#include <core/core.hpp>
#include "mysystem.hpp"

class TestModule : public legion::Module
{
public:
    virtual void setup() override
    {
        reportComponentType<my_component>(); // Report a component type
        reportSystem<MySystem>(); // Report a system
    }
};

Legion engine uses an ECS for all of it's core functionality. So for your own project you need to define your own systems and components:

#include <core/core.hpp>

struct my_component { int myVal; };

class MySystem final : public legion::System<MySystem>
{
    virtual void setup()
    {
        createProcess<&MySystem::update>("Update");
    }
    
    void update(legion::time::span deltaTime)
    {
        // Do stuff every frame on the update thread
        static auto myQuery = createQuery<my_component, position>();
        mQuery.queryEntities();
        for(auto entity : myQuery)
        {
            // Runs for every entity that has both my_component and a position component.
        }
    }
};

For more information about the engine usage see the docs.

Dependencies

(All libraries can already be found in the deps folder)

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

rythe-engine's People

Contributors

actions-user avatar algo-ryth-mix avatar developer-the-great avatar glynleine avatar jelled1st avatar kukash avatar leonbrands avatar ragingram2 avatar tuhri444 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rythe-engine's Issues

Engine crashes when I try to destroy entities.

Describe the bug
Before I try and deserialize a scene for loading I try and destroy the scene root object so I can get rid of the first scene. When I do so the engine crashes with a read access violation

If you would like to reproduce the error just look to the SceneManager::loadScene() function, there you should see my method of destruction, I have attached screenshots.

everything in one

scenemanager cpp

Mulitply invoked Kernels crash

Describe the bug
A clear and concise description of what the bug is.
Kernel either crashes on multiple invocations or Leaks GPU memory

Include a MRE
https://stackoverflow.com/help/minimal-reproducible-example

	
	std::vector<int> lhs = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
	std::vector<int> rhs = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
	std::vector<int> res(16);
	compute::function f = fs::view("assets://kernel/vector_add.cl").load_as<compute::function>("vector_add");
	
	f(16,lhs,rhs,res);
	f(16,lhs,rhs,res); //crash!

Expected behavior
No crash

Desktop (please complete the following information):

  • OS: Win 10
  • Version Na

Additional context
This happens because Kernels release their command Queues on finish() this should happen in the dtor instead

Investigate and cleanup delegates

Describe the bug
Delegates might have unused parts, and might not destruct propperly when used with non static non member functions

Expected behavior
delegates should work with any callable type and construct and cleanup propperly.

Spinlocks need queueing

Describe the bug
Due to the severely varying iteration times of all the threads, some threads never get the chance to lock because they're too slow. A queue would help slower threads get a chance at locking as well.

Expected behaviour
Locking a spinlock should not take minutes.

Additional context
Run feature/window enough times and sometimes the windows won't get created or won't respond. either the rendering or input threads have gotten stuck on a spinlock. if you pause the program you'll pause inside a spinlock.

OBJ material importer fails to properly join paths

Describe the bug
The OBJ loader fails to load textures that are stored in relative paths to the obj file. If such a path occurs, it simply adds the model's path to the path.

For example:

  • Model path: "assets:\some_folder\model.obj"
  • Texture described in mtl file: "..\texture_folder\texture.png"
  • Resulting texture path: "assets:\some_folder..\texture_folder\texture.png"

Include a MRE
Load any model where the mtl uses a relative texture path with ../

Expected behavior
The relative filepath should be resolved appropriately by checking for .. before combining the paths

Desktop (please complete the following information):

  • OS: Windows 10

Entity Query does not contain the requested components

Describe the bug
Entity Query does not contain the requested components even after instantiating an entity that has the required components

Include a MRE

  1. create a query
    image

  2. initialize an entity has the required components for the query
    image

  3. attempt to iterate through the query/log its size
    image

  4. The query is empty
    image

Expected behavior
After adding an entity that has the requested queries, it should appear in the query.

Editor Framework

To create a good editor, we need a general editor framework. We can ensure that all editor code will adhere to a certain architecture and stays organised with the framework.

Scene Management

Right now there are no scenes. You can't create scenes, you can't load or destroy scenes. We need a system that allows us to load and unload scenes synchronously and asynchronously. We need the system to also allow us to keep track of a scene queue for linear level progression and a scene stack for handling recursively loaded scenes like sub-scenes in an open world.

cppcheck failing

Describe the bug
cppcheck fails on every pull request.

Expected behavior
cppcheck should build and pass with no problems.

Engine tries to lookup libs in "random" folders

Describe the bug
When building the engine from fresh download (main) the solution tries to lookup a lib in a random folder that has no association with the project.

Include a MRE
Not applicable / Issue with tooling

Expected behavior
The engine builds

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10 Home
  • Version: 10.0.19043 Build 19043

Additional context
image

docs action breaking

Describe the bug
Docs action is failing on main.

Expected behavior
Documentation should be built and updated

Runtime reflection and type information

For serialization and other parts of the engine we need to be able to easily request meta information about a type on runtime. A data structure and wrokflow for this needs to be created.

__cdecl should be replaced by ARGS_CCONV

I would recommend introducing a new macro
#define ARGS_CCONV __cdecl as we might want different calling conventions on different platforms (i.e.: __fastcall on windows)

it should also be part of ARGS_API such that .dll or .so are consistent across the board

PP Pipeline Improvements

Render Pass function
Render pass function should not always give pass color texture and depth texture. The user should be able to decide what input he wants. We probably want to acces stuff like depth texture, normal buffer etc within the shader, as a part of the shader library.

Shader Library
As mentioned in the issue above we want to make use of the shader library within post processing effects. We also want to add functionalities like depthTexture to the library.

Effect exectuion order
Priority is ambiguous (for me at least), is a low number low prio, or high prio?
I would change up the name or the variable to make that more clear or change the way effect execution order is handled.

Debug drawing does not work anymore

Describe the bug
when debug::drawline() is called no line is drawn

Expected behavior
a line is drawn when drawline() is called

Desktop (please complete the following information):

  • OS: win
  • Version develop

Additional context
Blocks #254

Serialization

Right now there is no way to serialize and deserialize scenes, entities, or components.

Mesh Render and Mesh Batcher are not thread safe

Describe the bug
When I attempt to spawn cubes during runtime, I will randomly crash on any given spawn instance.

Include a MRE
Go to the scene-management branch, run the engine, and press F5 till it crashes.

Expected behavior
Not crash

VS Plugin

Working with Legion is quite a chore, especially setting up new projects and creating new files. A Visual Studio plugin could automate a lot of these tasks for the user and make working with Legion a lot easier.

GLTF Punctual light support

Is your feature request related to a problem? Please describe.
My use case uses Blender for level design, and all static geometry is loaded in as a single model (with sub-meshes) from a GLTF file. This limits me in some aspects as I can not simply edit in light sources into the "scene".

Describe the solution you'd like
Since we use Blender for level editing, it'd be very convenient if lights could also be configurable through Blender. This is possible by supporting the GLTF 2.0 KHR_lights_punctual extension enlisted here https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual

Describe alternatives you've considered
Other alternatives would include a custom editor or scene file, both of which would take significantly more time. Supporting the lights extension should take fairly little time and would greatly expand the flexibility of the model loader.

I'm willing to take this upon myself once I have the time but if anyone else is able to start on this sooner then that'd be greatly appreciated as well.

Broken Collisions

Describe the bug
Collisions appear to be broken
Collisions with more than 12 edges appears to break

(check linked pr for mre)

Expected behavior
normal collision

Desktop (please complete the following information):

  • OS: Win
  • Version feature/messy-quick-hull

Additional context
Messy Quick Hull is "messy" because it cannot properly be tested because of this.

No filesystem UML

please create a design of the filesystem and put it in UML. it would allow others to understand it better and possibly help out with the implementation. it also allows other to check for design flaws before the implementation is finished.

Reliance of instable compiler feature: inline static variables

Describe the bug
Inline static variables have a very unstable and hard to predict behaviour when headers with them get included in multiple different .cpp files. they should be avoided for now and an alternative solution should be found.

Include a MRE
baz.hpp:

struct baz
{
    static inline int var;
    static void foo();
};

baz.cpp:

#include <iostream>
#include "baz.hpp"

void baz::foo()
{
    var = 1;
    std::cout << var << std::endl;
}

bar.hpp:

struct bar
{
    static void foo();
};

bar.cpp:

#include <iostream>
#include "baz.hpp"
#include "bar.hpp"

void bar::foo()
{
    std::cout << baz::var << std::endl;
}

main.cpp:

#include <iostream>
#include "baz.hpp"

int main()
{
    baz::foo();
    bar::foo();
    return 0;
}

will output:

1
0

Screenshots
printing out the size of AssetImporter::m_converters in multiple places throughout the engine:

Unit-Tests

as it currently stands the repository is not backed by unit-tests!

We should invest some time into looking into which unit-test framework we want, and implement at least basic test such that subsequent ci runs can detect code that breaks the previous code-base
https://github.com/onqtam/doctest
https://github.com/catchorg/Catch2
https://www.boost.org/doc/libs/1_73_0/libs/test/doc/html/index.html

Additionally we should decide if we want advanced tools for our ci system like code-cov to asses the quality of the unit-test in addition to running them

mutable & const correctness

@GlynLeine please make sure that your code correctly qualifies const & mutable

ecsregistry.cpp
In file included from ecs/ecsregistry.cpp:1:
In file included from ../core/ecs/ecsregistry.hpp:7:
In file included from ../core/ecs/component_container.hpp:5:
../core/containers/atomic_sparse_map.hpp:71:27: error: no matching constructor for initialization of 'async::readonly_guard'
                { async::readonly_guard lock(m_container_lock); return m_dense_value.cbegin(); }
                                        ^    ~~~~~~~~~~~~~~~~
../core/async/readonly_rw_spinlock.hpp:67:3: note: candidate constructor not viable: 1st argument ('const async::readonly_rw_spinlock') would lose const qualifier
                readonly_guard(readonly_rw_spinlock& lock) : lock(lock)
                ^
../core/async/readonly_rw_spinlock.hpp:96:3: note: candidate constructor not viable: no known conversion from 'const async::readonly_rw_spinlock' to 'const args::core::async::readonly_guard' for 1st argument
                readonly_guard(const readonly_guard&) = delete;
                ^

this is directly from develop/core
as you can see the right constructor is discared because it does not qualify const correctly, m_container_lock needs to be mutable in this context

Setup is not called on Renderstages that are created after the Renderer has been initialized

Describe the bug
Renderstages that are attached after the renderer has been initialized will not have their setup functions called

Include a MRE

#pragma once
#include <core/core.hpp>
#include <rendering/util/gui.hpp>
#include <rendering/pipeline/gui/stages/imguirenderstage.hpp>

class GuiTestSystem : public System<GuiTestSystem>
{
    void setup() override
    {

        static_cast<DefaultPipeline*>(Renderer::getMainPipeline())->attachStage<ImGuiStage>();

        //gui code goes here
        ImGuiStage::OnGuiRender += [this]() ///// !CRASH! because ImGuiStage::setup was never called! 
        {
             imgui::base::ShowDemoWindow();
        };
    }
};

Expected behavior
A clear and concise description of what you expected to happen.
When adding a stage after the init() call has been made stages should have the setup() function called in-place

Desktop (please complete the following information):

  • OS: Win
  • Version develop (new-renderer)

Centralized Asset Management

Right now there is no reference implementation for asset management. So each new asset needs to create its own systems and API. this also causes the API around assets to not be coherent. Additionally adding new custom assets is very difficult.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.