Skip to content

Commit

Permalink
Merge branch 'TheOpenSpaceProgram:master' into Solar-System-Scenario-…
Browse files Browse the repository at this point in the history
…05/24
  • Loading branch information
Ben-Bingham authored Jun 22, 2024
2 parents c142004 + 9d566bb commit a3f0230
Show file tree
Hide file tree
Showing 51 changed files with 393 additions and 430 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/analyzers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ jobs:
fetch-depth: 1
submodules: recursive

- name: Hack to fix github runner
run: |
# Hack to deal with https://github.com/actions/runner-images/issues/8659
sudo rm -f /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
sudo apt-get update
sudo apt-get install -y --allow-downgrades libstdc++-12-dev libstdc++6=12.* libgcc-s1=12.*
- name: Install dependencies
run: |
sudo apt-get update
Expand All @@ -67,7 +60,7 @@ jobs:
cmake --build build --parallel --config ${{ matrix.config }} --target compile-osp-magnum-deps compile-test-deps
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
if: ${{ matrix.tool == 'CodeQL' }}
with:
languages: cpp
Expand All @@ -85,7 +78,7 @@ jobs:
# Unlike clang-analyzer and include-what-you-use, CodeQL can't operate on just the config step. Need to actually build everything.
- name: Perform CodeQL Analysis
if: ${{ matrix.tool == 'CodeQL' }}
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
upload: false
output: sarif-results
Expand All @@ -102,7 +95,7 @@ jobs:

- name: Upload SARIF
if: ${{ matrix.tool == 'CodeQL' }}
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: sarif-results/cpp.sarif

Expand Down Expand Up @@ -162,6 +155,6 @@ jobs:

# Upload SARIF file to GitHub Code Scanning Alerts
- name: Upload SARIF to GitHub
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.run-analysis.outputs.sarif }}
9 changes: 1 addition & 8 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ jobs:
with:
key: linux-${{ matrix.image }}-${{ matrix.compiler }}-${{ matrix.config }}

- name: Hack to fix github runner
run: |
# Hack to deal with https://github.com/actions/runner-images/issues/8659
sudo rm -f /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
sudo apt-get update
sudo apt-get install -y --allow-downgrades libstdc++-12-dev libstdc++6=12.* libgcc-s1=12.*
- name: Install dependencies
run: |
sudo apt update
Expand Down Expand Up @@ -81,7 +74,7 @@ jobs:
run: |
ctest --schedule-random --progress --output-on-failure --parallel --no-tests error --build-config ${{ matrix.config }} --test-dir build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: OSP-linux-${{ matrix.image}}-${{ matrix.config }}-${{ matrix.compiler }}
path: build/${{ matrix.config }}
1 change: 1 addition & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
fail-fast: false
matrix:
config: [Release, Debug]
# Don't build with macos-14 yet, newton dynamics 3.14 can't handle it.
image: [macos-12, macos-13]

runs-on: ${{ matrix.image }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
run: |
ctest --schedule-random --progress --output-on-failure --parallel --no-tests error --build-config ${{ matrix.config }} --test-dir build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: OSP-${{ matrix.image }}-${{ matrix.config }}-${{ matrix.compiler }}
path: build\${{ matrix.config }}
8 changes: 4 additions & 4 deletions src/adera/activescene/VehicleBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,15 @@ VehicleData VehicleBuilder::finalize_release()

// reserve node-to-machine partitions
rPerNodeType.nodeToMach.data_reserve(rPerNodeType.m_connectCountTotal);
for (NodeId node : rPerNodeType.nodeIds.bitview().zeros())
for (NodeId node : rPerNodeType.nodeIds)
{
rPerNodeType.nodeToMach.emplace(node, rPerNodeType.m_nodeConnectCount[node]);
lgrn::Span<Junction> junction = rPerNodeType.nodeToMach[node];
std::fill(std::begin(junction), std::end(junction), Junction{});
}

// assign node-to-machine
for (MachAnyId const mach : rData.m_machines.ids.bitview().zeros())
for (MachAnyId const mach : rData.m_machines.ids)
{
lgrn::Span<NodeId> portSpan = rPerNodeType.machToNode[mach];
lgrn::Span<JuncCustom> customSpan = rPerNodeType.m_machToNodeCustom[mach];
Expand Down Expand Up @@ -249,13 +249,13 @@ VehicleData VehicleBuilder::finalize_release()
using osp::link::MachinePair;
rData.m_partToMachines.ids_reserve(rData.m_partIds.capacity());
rData.m_partToMachines.data_reserve(rData.m_machines.ids.capacity());
for (PartId const part : rData.m_partIds.bitview().zeros())
for (PartId const part : rData.m_partIds)
{
rData.m_partToMachines.emplace(part, m_partMachCount[part]);
}

// Assign part-to-machine partitions
for (MachAnyId const mach : rData.m_machines.ids.bitview().zeros())
for (MachAnyId const mach : rData.m_machines.ids)
{
MachLocalId const local = rData.m_machines.machToLocal[mach];
MachTypeId const type = rData.m_machines.machTypes[mach];
Expand Down
6 changes: 3 additions & 3 deletions src/adera/activescene/vehicles_vb_fn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void SysVehicleSpawnVB::create_parts_and_welds(ACtxVehicleSpawn& rVehicleSpawn,
std::size_t const remapPartOffset = rVSVB.remapPartOffsets[spVhId];
std::size_t const remapWeldOffset = rVSVB.remapWeldOffsets[spVhId];

for (PartId const srcPart : pVData->m_partIds.bitview().zeros())
for (PartId const srcPart : pVData->m_partIds)
{
PartId const dstPart = *itDstPartIds;
++itDstPartIds;
Expand All @@ -134,7 +134,7 @@ void SysVehicleSpawnVB::create_parts_and_welds(ACtxVehicleSpawn& rVehicleSpawn,
rVSVB.remapParts[remapPartOffset + srcPart] = dstPart;
}

for (WeldId const srcWeld : pVData->m_weldIds.bitview().zeros())
for (WeldId const srcWeld : pVData->m_weldIds)
{
WeldId const dstWeld = *itDstWeldIds;
++itDstWeldIds;
Expand Down Expand Up @@ -181,7 +181,7 @@ void SysVehicleSpawnVB::request_prefabs(ACtxVehicleSpawn& rVehicleSpawn, ACtxVeh
}

// Copy Part data from VehicleBuilder to scene
for (uint32_t srcPart : pVData->m_partIds.bitview().zeros())
for (uint32_t srcPart : pVData->m_partIds)
{
PartId const dstPart = *itDstPartIds;
++itDstPartIds;
Expand Down
8 changes: 3 additions & 5 deletions src/adera/drawing_gl/flat_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ struct ArgsForSyncDrawEntFlat

inline void sync_drawent_flat(osp::draw::DrawEnt ent, ArgsForSyncDrawEntFlat const args)
{
auto const entInt = std::size_t(ent);

bool const hasMaterial = args.hasMaterial.test(entInt);
bool const hasMaterial = args.hasMaterial.contains(ent);
bool const hasTexture = (args.diffuse.size() > std::size_t(ent))
&& (args.diffuse[ent].m_glId != lgrn::id_null<osp::draw::TexGlId>());

Expand All @@ -92,7 +90,7 @@ inline void sync_drawent_flat(osp::draw::DrawEnt ent, ArgsForSyncDrawEntFlat con

if (args.pStorageTransparent != nullptr)
{
auto value = (hasMaterial && args.transparent.test(entInt))
auto value = (hasMaterial && args.transparent.contains(ent))
? std::make_optional(osp::draw::EntityToDraw{&draw_ent_flat, {&args.rData, pShader}})
: std::nullopt;

Expand All @@ -101,7 +99,7 @@ inline void sync_drawent_flat(osp::draw::DrawEnt ent, ArgsForSyncDrawEntFlat con

if (args.pStorageOpaque != nullptr)
{
auto value = (hasMaterial && args.opaque.test(entInt))
auto value = (hasMaterial && args.opaque.contains(ent))
? std::make_optional(osp::draw::EntityToDraw{&draw_ent_flat, {&args.rData, pShader}})
: std::nullopt;

Expand Down
7 changes: 3 additions & 4 deletions src/adera/drawing_gl/phong_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ struct ArgsForSyncDrawEntPhong

inline void sync_drawent_phong(osp::draw::DrawEnt ent, ArgsForSyncDrawEntPhong const args)
{
auto const entInt = std::size_t(ent);

bool const hasMaterial = args.hasMaterial.test(entInt);
bool const hasMaterial = args.hasMaterial.contains(ent);
bool const hasTexture = (args.diffuse.size() > std::size_t(ent)) && (args.diffuse[ent].m_glId != lgrn::id_null<osp::draw::TexGlId>());

PhongGL *pShader = hasTexture
Expand All @@ -93,7 +92,7 @@ inline void sync_drawent_phong(osp::draw::DrawEnt ent, ArgsForSyncDrawEntPhong c

if (args.pStorageTransparent != nullptr)
{
auto value = (hasMaterial && args.transparent.test(entInt))
auto value = (hasMaterial && args.transparent.contains(ent))
? std::make_optional(osp::draw::EntityToDraw{&draw_ent_phong, {&args.rData, pShader}})
: std::nullopt;

Expand All @@ -102,7 +101,7 @@ inline void sync_drawent_phong(osp::draw::DrawEnt ent, ArgsForSyncDrawEntPhong c

if (args.pStorageOpaque != nullptr)
{
auto value = (hasMaterial && args.opaque.test(entInt))
auto value = (hasMaterial && args.opaque.contains(ent))
? std::make_optional(osp::draw::EntityToDraw{&draw_ent_phong, {&args.rData, pShader}})
: std::nullopt;

Expand Down
2 changes: 1 addition & 1 deletion src/adera/drawing_gl/visualizer_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ inline void sync_drawent_visualizer(
ACtxDrawMeshVisualizer& rData)
{
bool alreadyAdded = rStorage.contains(ent);
if (hasMaterial.test(std::size_t(ent)))
if (hasMaterial.contains(ent))
{
if ( ! alreadyAdded)
{
Expand Down
6 changes: 3 additions & 3 deletions src/osp/activescene/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@

#include "active_ent.h"

#include "../core/bitvector.h"
#include "../core/keyed_vector.h"
#include "../core/math_types.h"
#include "../core/storage.h"

#include <longeron/id_management/null.hpp>
#include <longeron/id_management/registry_stl.hpp> // for lgrn::IdRegistryStl
#include <longeron/id_management/registry_stl.hpp>
#include <longeron/id_management/id_set_stl.hpp>

#include <string>

namespace osp::active
{

using ActiveEntVec_t = std::vector<ActiveEnt>;
using ActiveEntSet_t = BitVector_t;
using ActiveEntSet_t = lgrn::IdSetStl<ActiveEnt>;

/**
* @brief Component for transformation (in meters)
Expand Down
4 changes: 2 additions & 2 deletions src/osp/activescene/physics_fn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void SysPhysics::calculate_subtree_mass_center(
rMassPos += childTf.translation() * childMass.m_mass;
}

if (rCtxPhys.m_hasColliders.test(std::size_t(child)))
if (rCtxPhys.m_hasColliders.contains(child))
{
calculate_subtree_mass_center(rTf, rCtxPhys, rScnGraph, child, rMassPos, rTotalMass, childTf);
}
Expand Down Expand Up @@ -88,7 +88,7 @@ void SysPhysics::calculate_subtree_mass_inertia(
rInertiaTensor += transform_inertia_tensor(inertiaTensor, childMass.m_mass, offset, childTf.rotation());
}

if (rCtxPhys.m_hasColliders.test(std::size_t(child)))
if (rCtxPhys.m_hasColliders.contains(child))
{
calculate_subtree_mass_inertia(rTf, rCtxPhys, rScnGraph, child, rInertiaTensor, childTf);
}
Expand Down
6 changes: 3 additions & 3 deletions src/osp/activescene/prefab_fn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void SysPrefabInit::init_info(

if (parents[i] == -1)
{
rPrefabs.roots.set(std::size_t(ent));
rPrefabs.roots.insert(ent);
}
}

Expand Down Expand Up @@ -222,11 +222,11 @@ void SysPrefabInit::init_physics(
= [&rHasColliders = rCtxPhys.m_hasColliders, ents, objects, parents]
(auto const& self, int objectId, ActiveEnt ent) -> void
{
if (rHasColliders.test(std::size_t(ent)))
if (rHasColliders.contains(ent))
{
return; // HasColliders bit already set, this means all ancestors have it set too
}
rHasColliders.set(std::size_t(ent));
rHasColliders.insert(ent);

int const parentId = parents[objectId];

Expand Down
4 changes: 2 additions & 2 deletions src/osp/core/Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ResId Resources::create(ResTypeId const typeId, PkgId const pkgId, SharedString
assert(rPkg.m_resTypeOwn.size() > std::size_t(typeId));
PerPkgResType &rPkgType = rPkg.m_resTypeOwn[std::size_t(typeId)];
rPkgType.m_owned.resize(rPerResType.m_resIds.capacity());
rPkgType.m_owned.set(std::size_t(newResId));
rPkgType.m_owned.insert(newResId);

// Track name
auto const& [newIt, success] = rPkgType.m_nameToResId.emplace(std::move(name), newResId);
Expand Down Expand Up @@ -80,7 +80,7 @@ SharedString const& Resources::name(ResTypeId const typeId, ResId const resId) c
return rPerResType.m_resNames[std::size_t(resId)];
}

lgrn::IdRegistry<ResId> const& Resources::ids(ResTypeId const typeId) const noexcept
lgrn::IdRegistryStl<ResId> const& Resources::ids(ResTypeId const typeId) const noexcept
{
return get_type(typeId).m_resIds;
}
Expand Down
19 changes: 12 additions & 7 deletions src/osp/core/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
*/
#pragma once

#include "copymove_macros.h"
#include "shared_string.h"
#include "resourcetypes.h"

#include <longeron/id_management/registry.hpp>
#include <longeron/id_management/id_set_stl.hpp>
#include <longeron/id_management/refcount.hpp>
#include <longeron/id_management/registry_stl.hpp>

#include <entt/core/family.hpp>
#include <entt/core/any.hpp>
Expand All @@ -48,7 +50,7 @@ class Resources

struct PerResType
{
lgrn::IdRegistry<ResId> m_resIds;
lgrn::IdRegistryStl<ResId> m_resIds;
lgrn::RefCount<int> m_resRefs;
std::vector<res_data_type_t> m_resDataTypes;
std::vector<entt::any> m_resData;
Expand All @@ -59,7 +61,7 @@ class Resources

struct PerPkgResType
{
lgrn::HierarchicalBitset<uint64_t> m_owned;
lgrn::IdSetStl<ResId> m_owned;
std::unordered_map< SharedString, ResId, std::hash<SharedString>, std::equal_to<> > m_nameToResId;
};

Expand All @@ -70,6 +72,9 @@ class Resources

public:

Resources() = default;
OSP_MOVE_ONLY_CTOR_ASSIGN(Resources);

/**
* @brief Resize to fit a certain number of resource types
*
Expand Down Expand Up @@ -103,7 +108,7 @@ class Resources
*/
[[nodiscard]] SharedString const& name(ResTypeId typeId, ResId resId) const noexcept;

[[nodiscard]] lgrn::IdRegistry<ResId> const& ids(ResTypeId typeId) const noexcept;
[[nodiscard]] lgrn::IdRegistryStl<ResId> const& ids(ResTypeId typeId) const noexcept;

[[nodiscard]] ResIdOwner_t owner_create(ResTypeId typeId, ResId resId) noexcept;

Expand Down Expand Up @@ -201,9 +206,9 @@ class Resources
template <typename T>
res_container_t<T> const& get_container(PerResType const &rPerResType, ResTypeId typeId) const;

std::vector<PerResType> m_perResType;
lgrn::IdRegistry<PkgId> m_pkgIds;
std::vector<PerPkg> m_pkgData;
std::vector<PerResType> m_perResType;
lgrn::IdRegistryStl<PkgId> m_pkgIds;
std::vector<PerPkg> m_pkgData;
};

template<typename T>
Expand Down
Loading

0 comments on commit a3f0230

Please sign in to comment.