Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tasks and more II #244

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9784612
Add WIP Universe scenario
Capital-Asterisk Feb 5, 2023
6d97a52
Re-add universe test scene
Capital-Asterisk Mar 3, 2023
303816f
Add cursor and some drawing-related changes
Capital-Asterisk Mar 6, 2023
8c0d12f
Add cone default resource
Capital-Asterisk Mar 10, 2023
8a5484e
Add "Thrust Indicator"
Capital-Asterisk Mar 10, 2023
247f014
Clean up various stuff
Capital-Asterisk Mar 11, 2023
0d1adbb
Fix machines initialization order fiasco
Capital-Asterisk Apr 11, 2023
3b26242
Screw with renderer again
Capital-Asterisk Apr 13, 2023
6680590
Fix code after adding "Draw Entities"
Capital-Asterisk Apr 16, 2023
decd8b9
Rewrite Tasks to use "Targets" instead of Tags
Capital-Asterisk Apr 17, 2023
d80c440
Progress on new Task system
Capital-Asterisk Apr 24, 2023
bb137fa
Mess with even more task stuff
Capital-Asterisk Apr 26, 2023
5612508
Restructure testapp for new task changes, Fixes enginetest
Capital-Asterisk Apr 27, 2023
76e754e
Use entt::sparse_set for queued tasks
Capital-Asterisk Apr 28, 2023
6f32a96
Fix Physics test scene for task changes
Capital-Asterisk May 8, 2023
de6ad81
Rewrite Task systems into "Pipelines"
Capital-Asterisk Jun 5, 2023
5702e3a
Rewrite pipelines (already lol)
Capital-Asterisk Jun 10, 2023
ca55487
Make pipelines work
Capital-Asterisk Jun 19, 2023
671aff9
Fix enginetest for Pipelines
Capital-Asterisk Jun 21, 2023
51b1776
Fix more stuff
Capital-Asterisk Jul 3, 2023
2441813
Implement Pipeline logging and fix more pipeline issues
Capital-Asterisk Jul 5, 2023
1285583
Implement pipeline task 'conditions'
Capital-Asterisk Jul 9, 2023
2bf3063
Rewrite pipelines again
Capital-Asterisk Jul 18, 2023
435c3b3
Implement optional pipeline stages
Capital-Asterisk Jul 24, 2023
561eb96
Remove optional Pipeline stages, Improve pipeline tree structure
Capital-Asterisk Jul 27, 2023
181a038
Implement Pipeline Loops
Capital-Asterisk Jul 31, 2023
f4960a4
Implement Pipeline Nested Loops
Capital-Asterisk Aug 5, 2023
67892e6
Implement Pipeline "Wait for (external) signal"
Capital-Asterisk Aug 6, 2023
0b3adc0
Progress on fixing everything after pipeline nuke
Capital-Asterisk Aug 15, 2023
6a2eda0
Fix pipeline execute bug related to loops
Capital-Asterisk Aug 20, 2023
b20b411
Fix a lot of stuff
Capital-Asterisk Aug 23, 2023
c101a2f
Fix more pipeline stuff
Capital-Asterisk Aug 26, 2023
9a0b590
Rework renderer 'resync' logic
Capital-Asterisk Aug 27, 2023
1025ae8
Fully fix physics test scene
Capital-Asterisk Aug 28, 2023
c175994
Fix windows build and other issues on PR #244
Capital-Asterisk Aug 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/adera/Shaders/PlumeShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void PlumeShader::assign_plumes(
{
for (ActiveEnt ent : entities)
{
rStorage.emplace(ent, EntityToDraw{&draw_plume, {&rData} });
//rStorage.emplace(ent, EntityToDraw{&draw_plume, {&rData} });
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/adera/machines/links.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ using osp::link::MachTypeId;
namespace adera
{

MachTypeId const gc_mtUserCtrl = MachTypeReg_t::create();
MachTypeId const gc_mtMagicRocket = MachTypeReg_t::create();
MachTypeId const gc_mtRcsDriver = MachTypeReg_t::create();

float thruster_influence(Vector3 const pos, Vector3 const dir, Vector3 const cmdLin, Vector3 const cmdAng) noexcept
{
using Magnum::Math::cross;
Expand Down
6 changes: 3 additions & 3 deletions src/adera/machines/links.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ using osp::link::gc_ntSigFloat;
using osp::link::gc_sigIn;
using osp::link::gc_sigOut;

extern osp::link::MachTypeId const gc_mtUserCtrl;
extern osp::link::MachTypeId const gc_mtMagicRocket;
extern osp::link::MachTypeId const gc_mtRcsDriver;
inline osp::link::MachTypeId const gc_mtUserCtrl = osp::link::MachTypeReg_t::create();
inline osp::link::MachTypeId const gc_mtMagicRocket = osp::link::MachTypeReg_t::create();
inline osp::link::MachTypeId const gc_mtRcsDriver = osp::link::MachTypeReg_t::create();

constexpr osp::Vector3 gc_rocketForward{0.0f, 0.0f, 1.0f};

Expand Down
1 change: 0 additions & 1 deletion src/newtondynamics_physics/SysNewton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ using namespace Magnum::Math::Literals;

using osp::phys::EShape;

using osp::active::acomp_view_t;
using osp::active::acomp_storage_t;

using osp::active::ActiveEnt;
Expand Down
79 changes: 62 additions & 17 deletions src/osp/Active/SysPrefabInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ void SysPrefabInit::init_drawing(
Resources& rResources,
ACtxDrawing& rDrawing,
ACtxDrawingRes& rDrawingRes,
std::optional<EntSetPair> material) noexcept
std::optional<Material> material) noexcept
{
auto itPfEnts = std::begin(rPrefabInit.m_ents);
auto itPfEnts = rPrefabInit.m_ents.begin();

// stupidly make drawIDs first
// TODO: separate this into another step.
for (TmpPrefabInitBasic const& rPfBasic : rPrefabInit.m_basicIn)
{
auto const &rImportData = rResources.data_get<osp::ImporterData const>(
Expand All @@ -131,13 +133,53 @@ void SysPrefabInit::init_drawing(

for (std::size_t i = 0; i < objects.size(); ++i)
{
int const meshImportId = rImportData.m_objMeshes[objects[i]];
if (meshImportId == -1)
{
continue;
}

ActiveEnt const ent = (*itPfEnts)[i];
rDrawing.m_activeToDraw[ent] = rDrawing.m_drawIds.create();
}

++itPfEnts;
}

// then resize containers
rDrawing.resize_draw();

itPfEnts = rPrefabInit.m_ents.begin();

// TODO: Don't actually do this. This marks every entity as drawable,
// which considers them for draw transformations.
// Only set drawable for entities that have a mesh or is an
// ancestor of an entity with a mesh.
rDrawing.m_drawable.set(std::size_t(ent));
for (TmpPrefabInitBasic const& rPfBasic : rPrefabInit.m_basicIn)
{
auto const &rImportData = rResources.data_get<osp::ImporterData const>(
gc_importer, rPfBasic.m_importerRes);
auto const &rPrefabData = rResources.data_get<osp::Prefabs const>(
gc_importer, rPfBasic.m_importerRes);

auto const ents = ArrayView<ActiveEnt const>{*itPfEnts};
auto const objects = lgrn::Span<int const>{rPrefabData.m_prefabs[rPfBasic.m_prefabId]};
auto const parents = lgrn::Span<int const>{rPrefabData.m_prefabParents[rPfBasic.m_prefabId]};

// All ancestors of each entity that has a mesh
auto const needs_draw_transform
= [&parents, &ents, &rDrawing, &needDrawTf = rDrawing.m_needDrawTf]
(auto && self, int const object, ActiveEnt const ent) noexcept -> void
{
needDrawTf.set(std::size_t(ent));

int const parentObj = parents[object];

if (parentObj != -1)
{
self(self, parentObj, ents[parentObj]);
}
};

for (std::size_t i = 0; i < objects.size(); ++i)
{
ActiveEnt const ent = (*itPfEnts)[i];

// Check if object has mesh
int const meshImportId = rImportData.m_objMeshes[objects[i]];
Expand All @@ -146,10 +188,14 @@ void SysPrefabInit::init_drawing(
continue;
}

needs_draw_transform(needs_draw_transform, objects[i], ent);

DrawEnt const drawEnt = rDrawing.m_activeToDraw[ent];

osp::ResId const meshRes = rImportData.m_meshes[meshImportId];
MeshId const meshId = SysRender::own_mesh_resource(rDrawing, rDrawingRes, rResources, meshRes);
rDrawing.m_mesh.emplace(ent, rDrawing.m_meshRefCounts.ref_add(meshId));
rDrawing.m_meshDirty.push_back(ent);
rDrawing.m_mesh[drawEnt] = rDrawing.m_meshRefCounts.ref_add(meshId);
rDrawing.m_meshDirty.push_back(drawEnt);

int const matImportId = rImportData.m_objMaterials[objects[i]];

Expand All @@ -162,23 +208,22 @@ void SysPrefabInit::init_drawing(
{
osp::ResId const texRes = rImportData.m_textures[baseColor];
TexId const texId = SysRender::own_texture_resource(rDrawing, rDrawingRes, rResources, texRes);
rDrawing.m_diffuseTex.emplace(ent, rDrawing.m_texRefCounts.ref_add(texId));
rDrawing.m_diffuseDirty.push_back(ent);
rDrawing.m_diffuseTex[drawEnt] = rDrawing.m_texRefCounts.ref_add(texId);
rDrawing.m_diffuseDirty.push_back(drawEnt);
}

}

rDrawing.m_opaque.emplace(ent);
rDrawing.m_visible.emplace(ent);
rDrawing.m_drawBasic[drawEnt] = { .m_opaque = true, .m_transparent = false };
rDrawing.m_visible.set(std::size_t(drawEnt));

if (material.has_value())
{
material.value().m_rEnts.set(std::size_t(ent));
material.value().m_rDirty.push_back(ent);
material.value().m_ents.set(std::size_t(drawEnt));
material.value().m_dirty.push_back(drawEnt);
}
}

std::advance(itPfEnts, 1);
++itPfEnts;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/osp/Active/SysPrefabInit.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class SysPrefabInit
Resources& rResources,
ACtxDrawing& rDrawing,
ACtxDrawingRes& rCtxDrawRes,
std::optional<EntSetPair> material) noexcept;
std::optional<Material> material) noexcept;

static void init_physics(
ACtxPrefabInit const& rPrefabInit,
Expand Down
63 changes: 43 additions & 20 deletions src/osp/Active/SysRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,47 +91,70 @@ void SysRender::set_dirty_all(ACtxDrawing &rCtxDrawing)
{
using osp::active::active_sparse_set_t;

// Set all meshs dirty
auto &rMeshSet = static_cast<active_sparse_set_t&>(rCtxDrawing.m_mesh);
rCtxDrawing.m_meshDirty.assign(std::begin(rMeshSet), std::end(rMeshSet));

// Set all textures dirty
auto &rDiffSet = static_cast<active_sparse_set_t&>(rCtxDrawing.m_diffuseTex);
rCtxDrawing.m_diffuseDirty.assign(std::begin(rMeshSet), std::end(rMeshSet));
}
for (std::size_t const drawEntInt : rCtxDrawing.m_drawIds.bitview().zeros())
{
auto const drawEnt = DrawEnt(drawEntInt);

void SysRender::clear_dirty_all(ACtxDrawing& rCtxDrawing)
{
rCtxDrawing.m_meshDirty.clear();
rCtxDrawing.m_diffuseDirty.clear();
// Set all meshs dirty
if (rCtxDrawing.m_mesh[drawEnt] != lgrn::id_null<MeshId>())
{
rCtxDrawing.m_meshDirty.push_back(drawEnt);
}

// Set all textures dirty
if (rCtxDrawing.m_diffuseTex[drawEnt] != lgrn::id_null<TexId>())
{
rCtxDrawing.m_diffuseDirty.push_back(drawEnt);
}
}

for (std::size_t const materialInt : rCtxDrawing.m_materialIds.bitview().zeros())
{
Material &mat = rCtxDrawing.m_materials[MaterialId(materialInt)];
for (std::size_t const entInt : mat.m_ents.ones())
{
mat.m_dirty.push_back(DrawEnt(entInt));
}
}
}


void SysRender::update_draw_transforms_recurse(
ACtxSceneGraph const& rScnGraph,
KeyedVec<ActiveEnt, DrawEnt> const& activeToDraw,
acomp_storage_t<ACompTransform> const& rTf,
acomp_storage_t<Matrix4>& rDrawTf,
EntSet_t const& rDrawable,
DrawTransforms_t& rDrawTf,
ActiveEntSet_t const& needDrawTf,
ActiveEnt ent,
Matrix4 const& parentTf,
bool root)
{
Matrix4 const& entTf = rTf.get(ent).m_transform;
Matrix4 const& entDrawTf = root ? (entTf) : (parentTf * entTf);
Matrix4 const& entTf = rTf.get(ent).m_transform;
Matrix4 const& entDrawTf = root ? (entTf) : (parentTf * entTf);

if (rDrawTf.contains(ent))
if (DrawEnt const drawEnt = activeToDraw[ent];
drawEnt != lgrn::id_null<DrawEnt>())
{
rDrawTf.get(ent) = entDrawTf;
rDrawTf[drawEnt] = entDrawTf;
}

for (ActiveEnt entChild : SysSceneGraph::children(rScnGraph, ent))
{
if (rDrawable.test(std::size_t(entChild)))
if (needDrawTf.test(std::size_t(entChild)))
{
update_draw_transforms_recurse(rScnGraph, rTf, rDrawTf, rDrawable, entChild, entDrawTf, false);
update_draw_transforms_recurse(rScnGraph, activeToDraw, rTf, rDrawTf, needDrawTf, entChild, entDrawTf, false);
}
}
}


//parentTf.
MeshIdOwner_t SysRender::add_drawable_mesh(ACtxDrawing& rDrawing, ACtxDrawingRes& rDrawingRes, Resources& rResources, PkgId const pkg, std::string_view const name)
{
ResId const res = rResources.find(restypes::gc_mesh, pkg, name);
assert(res != lgrn::id_null<ResId>());
MeshId const meshId = SysRender::own_mesh_resource(rDrawing, rDrawingRes, rResources, res);
return rDrawing.m_meshRefCounts.ref_add(meshId);
}


Loading
Loading