Skip to content

Commit

Permalink
Merge branch 'develop/premake' of https://github.com/Rythe-Interactiv…
Browse files Browse the repository at this point in the history
…e/Rythe-Engine into develop/premake
  • Loading branch information
GlynLeine committed Nov 3, 2023
2 parents d2bf26f + 7c5cc8a commit 6e02720
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 176 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,6 @@ docs/venv
*.sln
*.vcxproj
*.filters
build/.cmake
build/CMakeFiles
build/CMakeCache.txt
Binary file added applications/editor/engine/tools/lgnspre.exe
Binary file not shown.
6 changes: 3 additions & 3 deletions applications/sandbox/build-sandbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ DEALINGS IN THE SOFTWARE.
createProject("applications","sandbox","ConsoleApp")
targetdir "$(SolutionDir)bin\\build\\"
includedirs {
"sandbox/"
"sandbox/",
"third_party/*"
}
files {
"**.h",
Expand All @@ -33,9 +34,8 @@ files {
"**.c",
"**.cpp"
}

dofile "rythe/engine/core/include-core.lua"
dofile "rythe/engine/application/include-application.lua"
dofile "rythe/engine/graphics/include-graphics.lua"


Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion applications/sandbox/src/sandbox/module/examplemodule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ExampleModule : public rythe::Module

//reportSystem<MySystem>();
reportSystem<SimpleCameraController>();
reportSystem<ExampleSystem>();
//reportSystem<ExampleSystem>();
reportSystem<GuiTestSystem>();
}
};
122 changes: 20 additions & 102 deletions applications/sandbox/src/sandbox/source.cpp
Original file line number Diff line number Diff line change
@@ -1,109 +1,27 @@
//#define RYTHE_ENTRY
//#define RYTHE_LOG_DEBUG

//#if defined(NDEBUG)
// #define RYTHE_KEEP_CONSOLE
//#endif
//#include <core/core.hpp>
//#include <application/application.hpp>
//#include <graphics/graphics.hpp>
//#include "module/examplemodule.hpp"
//
//#ifdef RYTHE_AUDIO
//#include <audio/audio.hpp>
//#endif
//
//void LEGION_CCONV reportModules(legion::Engine* engine)
//{
// using namespace legion;
// engine->reportModule<app::ApplicationModule>();
// engine->reportModule<gfx::RenderingModule>();
// engine->reportModule<ExampleModule>();
//
//#ifdef RYTHE_AUDIO
// engine->reportModule<audio::AudioModule>();
//#endif
//}

//#define LEGION_ENTRY

#include <iostream>
#define RYTHE_ENTRY
#define RYTHE_LOG_DEBUG

#if defined(NDEBUG)
#define RYTHE_KEEP_CONSOLE
#endif
#include <core/core.hpp>
#include <application/application.hpp>
#include <graphics/graphics.hpp>

struct StartFeature : public rythe::feature {
void invoke() {}
};

struct UpdateFeature : public rythe::feature {
void invoke() {}
};

struct RaycastFeature : public rythe::feature {
void invoke() {}
};

struct RaycastTerrainFeature : public rythe::feature {
void invoke() {}
};


struct RenderFeature : public rythe::feature {
void invoke() {}
};

class GameModule : public rythe::module<rythe::feature_set<StartFeature, UpdateFeature, RenderFeature>> {
};

class PhysicsModule : public rythe::module<rythe::feature_set<RaycastFeature, RaycastTerrainFeature>> {
};

class Game : public rythe::program<GameModule, PhysicsModule> {
};

template<typename T>
void logType() {
std::cout << rsl::type_name<T>() << '\n';
}

template<typename... Types>
void logTypeSequenceImpl(rsl::type_sequence<Types...>) {
(logType<Types>(), ...);
}

template<rsl::type_sequence_c Seq>
void logTypeSequence() {
logTypeSequenceImpl(Seq{});
}

template<rythe::feature_set_c Seq>
void logFeatureSet() {
logTypeSequenceImpl(typename Seq::type_sequence{});
}

template<typename ProgramT, rythe::feature_c feature>
void checkFeature() {
static_assert(ProgramT::template has_feature<feature>(), "Missing feature!");
}

int main() {
using t = rsl::concat_sequence_t<rsl::type_sequence<StartFeature, UpdateFeature>, rsl::type_sequence<RaycastFeature, RaycastTerrainFeature, RenderFeature>>;
std::cout << "type sequence:\n";
logTypeSequence<t>();
#include "module/examplemodule.hpp"

std::cout << "\nfeature set:\n";
logFeatureSet<Game::features>();
#ifdef RYTHE_AUDIO
#include <audio/audio.hpp>
#endif

checkFeature<Game, StartFeature>();
checkFeature<Game, UpdateFeature>();
checkFeature<Game, RaycastFeature>();
checkFeature<Game, RaycastTerrainFeature>();
if constexpr (!Game::has_feature<RenderFeature>()) {
std::cout << "Game does not have \"" << rsl::type_name<RenderFeature>() << "\"\n";
}
else {
std::cout << "Game has \"" << rsl::type_name<RenderFeature>() << "\"\n";
}
void RYTHE_CCONV reportModules(rythe::Engine* engine)
{
using namespace rythe;
engine->reportModule<app::ApplicationModule>();
engine->reportModule<gfx::RenderingModule>();
engine->reportModule<ExampleModule>();

return 0;
#ifdef RYTHE_AUDIO
engine->reportModule<audio::AudioModule>();
#endif
}
62 changes: 31 additions & 31 deletions applications/sandbox/src/sandbox/systems/examplesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ struct switch_skybox_action : public ryt::app::input_action<switch_skybox_action

class ExampleSystem final : public rythe::System<ExampleSystem>
{
ryt::size_type frames = 0;
ryt::time64 totalTime = 0;
ryt::time::stopwatch<ryt::time64> timer;
std::array<ryt::time64, 18000> times;
rsl::size_type frames = 0;
rsl::time64 totalTime = 0;
rsl::stopwatch<rsl::time64> timer;
std::array<rsl::time64, 18000> times;

public:
void setup()
Expand Down Expand Up @@ -266,10 +266,10 @@ class ExampleSystem final : public rythe::System<ExampleSystem>

material = gfx::MaterialCache::create_material("default", fs::view("assets://shaders/pbr.shs"));

material.set_param(SV_ALBEDO, rendering::TextureCache::create_texture(fs::view("engine://resources/default/albedo")));
material.set_param(SV_NORMALHEIGHT, rendering::TextureCache::create_texture(fs::view("engine://resources/default/normalHeight")));
material.set_param(SV_MRDAO, rendering::TextureCache::create_texture(fs::view("engine://resources/default/MRDAo")));
material.set_param(SV_EMISSIVE, rendering::TextureCache::create_texture(fs::view("engine://resources/default/emissive")));
material.set_param(SV_ALBEDO, rendering::TextureCache::create_texture(fs::view("engine://resources/default/albedo.png")));
material.set_param(SV_NORMALHEIGHT, rendering::TextureCache::create_texture(fs::view("engine://resources/default/normalHeight.png")));
material.set_param(SV_MRDAO, rendering::TextureCache::create_texture(fs::view("engine://resources/default/MRDAo.png")));
material.set_param(SV_EMISSIVE, rendering::TextureCache::create_texture(fs::view("engine://resources/default/emissive.png")));
material.set_param(SV_HEIGHTSCALE, 1.f);

{
Expand All @@ -282,7 +282,7 @@ class ExampleSystem final : public rythe::System<ExampleSystem>
ent.add_component(gfx::mesh_renderer(material, model));
}

bindToEvent<events::exit, &ExampleSystem::onExit>();
//core::events::bindToEvent<events::exit, &ExampleSystem::onExit>();
}

void shutdown()
Expand Down Expand Up @@ -318,8 +318,8 @@ class ExampleSystem final : public rythe::System<ExampleSystem>
using namespace rythe;
if (event.pressed())
{
static size_type type = static_cast<size_type>(gfx::tonemapping_type::rythe);
type = (type + 1) % (static_cast<size_type>(gfx::tonemapping_type::unreal3) + 1);
static rsl::size_type type = static_cast<rsl::size_type>(gfx::tonemapping_type::rythe);
type = (type + 1) % (static_cast<rsl::size_type>(gfx::tonemapping_type::unreal3) + 1);

auto typeEnum = static_cast<gfx::tonemapping_type>(type);

Expand Down Expand Up @@ -356,7 +356,7 @@ class ExampleSystem final : public rythe::System<ExampleSystem>
using namespace rythe;
if (event.pressed())
{
static size_type idx = 0;
static rsl::size_type idx = 0;
static gfx::texture_handle textures[4] = {};
static bool initialized = false;

Expand Down Expand Up @@ -392,46 +392,46 @@ class ExampleSystem final : public rythe::System<ExampleSystem>
}
}

void onExit(L_MAYBEUNUSED ryt::events::exit& event)
void onExit([[maybe_unused]] ryt::events::exit& event)
{
using namespace rythe;

time64 avg0 = totalTime / frames;
time64 avg1 = timer.elapsed_time() / frames;
rsl::time64 avg0 = totalTime / frames;
rsl::time64 avg1 = timer.elapsed_time() / frames;

std::set<time64, std::greater<time64>> orderedTimes;
std::set<rsl::time64, std::greater<rsl::time64>> orderedTimes;

for (auto& time : times)
orderedTimes.insert(time);

time64 onePcLow = 0;
time64 pointOnePcLow = 0;
rsl::time64 onePcLow = 0;
rsl::time64 pointOnePcLow = 0;

size_type i = 0;
rsl::size_type i = 0;
for (auto& time : orderedTimes)
{
i++;
onePcLow += time;

if (i <= math::max<size_type>(math::uround(frames / 1000.0), 1))
if (i <= math::max<rsl::size_type>(math::uround(frames / 1000.0), 1))
{
pointOnePcLow += time;
}

if (i >= math::max<size_type>(math::uround(frames / 100.0), 1))
if (i >= math::max<rsl::size_type>(math::uround(frames / 100.0), 1))
{
break;
}
}

pointOnePcLow /= math::max<size_type>(math::uround(frames / 1000.0), 1);
onePcLow /= math::max<size_type>(math::uround(frames / 100.0), 1);
pointOnePcLow /= math::max<rsl::size_type>(math::uround(frames / 1000.0), 1);
onePcLow /= math::max<rsl::size_type>(math::uround(frames / 100.0), 1);

log::info("1%Low {:.3f} 0.1%Low {:.3f} Avg {:.3f} Measured Avg {:.3f}", onePcLow, pointOnePcLow, avg0, avg1);
log::info("1%Low {:.3f} 0.1%Low {:.3f} Avg {:.3f} Measured Avg {:.3f}", 1.0 / onePcLow, 1.0 / pointOnePcLow, 1.0 / avg0, 1.0 / avg1);
}

void update(rythe::time::span deltaTime)
void update(rsl::span deltaTime)
{
using namespace rythe;
static bool firstFrame = true;
Expand All @@ -445,7 +445,7 @@ class ExampleSystem final : public rythe::System<ExampleSystem>
ecs::filter<rotation, example_comp> filter;
for (auto& ent : filter)
{
ent.get_component<rotation>().get() *= math::angleAxis(math::two_pi<float>() * 0.1f * deltaTime, math::float3::up);
ent.get_component<rotation>().get() *= math::angleAxis(math::tau<float>() * 0.1f * deltaTime, math::float3::up);
}
}

Expand All @@ -458,16 +458,16 @@ class ExampleSystem final : public rythe::System<ExampleSystem>
if (filter.size())
{
auto poolSize = (schd::Scheduler::jobPoolSize() + 1);
size_type jobSize = math::iround(math::ceil(filter.size() / static_cast<float>(poolSize)));
rsl::size_type jobSize = math::iround(math::ceil(filter.size() / static_cast<float>(poolSize)));

queueJobs(poolSize, [&](id_type jobId)
queueJobs(poolSize, [&](rsl::id_type jobId)
{
auto start = jobId * jobSize;
auto end = start + jobSize;
if (end > filter.size())
end = filter.size();

for (size_type i = start; i < end; i++)
for (rsl::size_type i = start; i < end; i++)
{
auto& pos = filter[i].get_component<position>().get();
auto& vel = filter[i].get_component<velocity>().get();
Expand All @@ -479,7 +479,7 @@ class ExampleSystem final : public rythe::System<ExampleSystem>

perp = math::normalize(math::cross(vel, math::float3::up));

math::float3 rotated = (math::axisAngleMatrix(vel, math::perlin(pos) * math::pi<float>()) * math::float4(perp.x, perp.y, perp.z, 0)).xyz();
/* math::float3 rotated = (math::axisAngleMatrix(vel, math::perlin(pos) * math::pi<float>()) * math::float4(perp.x, perp.y, perp.z, 0)).xyz();
rotated.y -= 0.5f;
rotated = math::normalize(rotated);
Expand All @@ -490,15 +490,15 @@ class ExampleSystem final : public rythe::System<ExampleSystem>
auto rand = math::circularRand(1.f);
vel.y = 0.9f;
vel = math::normalize(vel + math::float3(rand.x, 0.f, rand.y));
}
}*/

pos += vel * 0.3f * dt;
}
}
).wait();
}

time64 delta = schd::Clock::lastTickDuration();
rsl::time64 delta = schd::Clock::lastTickDuration();

if (frames < times.size())
{
Expand Down
8 changes: 4 additions & 4 deletions applications/sandbox/src/sandbox/systems/gui_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//#include "gui_test.hpp"
//
//bool legion::GuiTestSystem::captured = false;
//bool legion::GuiTestSystem::isEditingText = false;
#include "gui_test.hpp"

bool rythe::GuiTestSystem::captured = false;
bool rythe::GuiTestSystem::isEditingText = false;
Loading

0 comments on commit 6e02720

Please sign in to comment.