remote (combined) bitset have
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
This commit is contained in:
parent
84ade4d683
commit
9777cb81cb
2
external/solanaceae_object_store
vendored
2
external/solanaceae_object_store
vendored
@ -1 +1 @@
|
||||
Subproject commit ed640ba08cf8452e202ed567cad48ad396b8e1db
|
||||
Subproject commit 18d2888e3452074245375f329d90520ac250b595
|
@ -16,23 +16,8 @@ namespace Message {
|
||||
uint64_t getTimeMS(void);
|
||||
}
|
||||
|
||||
BitsetImageLoader::BitsetImageLoader(void) {
|
||||
}
|
||||
|
||||
std::optional<TextureEntry> BitsetImageLoader::load(TextureUploaderI& tu, ObjectHandle o) {
|
||||
if (!static_cast<bool>(o)) {
|
||||
std::cerr << "BIL error: trying to load invalid object\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (!o.all_of<ObjComp::F::LocalHaveBitset>()) {
|
||||
// after completion, this is called until the texture times out
|
||||
//std::cout << "BIL: no local have bitset\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// TODO: const
|
||||
auto& have = o.get<ObjComp::F::LocalHaveBitset>().have;
|
||||
std::optional<TextureEntry> BitsetImageLoader::haveToTexture(TextureUploaderI& tu, BitSet& have, ObjectHandle o) {
|
||||
assert(have.size_bits() > 0);
|
||||
|
||||
auto* surf = SDL_CreateSurfaceFrom(
|
||||
have.size_bits(), 1,
|
||||
@ -83,3 +68,86 @@ std::optional<TextureEntry> BitsetImageLoader::load(TextureUploaderI& tu, Object
|
||||
return new_entry;
|
||||
}
|
||||
|
||||
BitsetImageLoader::BitsetImageLoader(void) {
|
||||
}
|
||||
|
||||
std::optional<TextureEntry> BitsetImageLoader::load(TextureUploaderI& tu, ObjectHandle o) {
|
||||
if (!static_cast<bool>(o)) {
|
||||
std::cerr << "BIL error: trying to load invalid object\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (!o.any_of<ObjComp::F::LocalHaveBitset, ObjComp::F::RemoteHaveBitset>()) {
|
||||
// after completion, this is called until the texture times out
|
||||
//std::cout << "BIL: no local have bitset\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (o.all_of<ObjComp::F::LocalHaveBitset>()) {
|
||||
auto& have = o.get<ObjComp::F::LocalHaveBitset>().have;
|
||||
assert(have.size_bits() > 0);
|
||||
return haveToTexture(tu, have, o);
|
||||
} else if (o.all_of<ObjComp::F::RemoteHaveBitset>()) {
|
||||
auto& list = o.get<ObjComp::F::RemoteHaveBitset>().others;
|
||||
if (list.empty()) {
|
||||
std::cout << "BIL: remote set list empty\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto& first_entry = list.begin()->second;
|
||||
|
||||
if (first_entry.have_all) {
|
||||
_tmp_bitset = {8};
|
||||
_tmp_bitset.invert();
|
||||
std::cout << "BIL: remote first have all\n";
|
||||
} else {
|
||||
_tmp_bitset = first_entry.have;
|
||||
assert(_tmp_bitset.size_bits() == first_entry.have.size_bits());
|
||||
|
||||
for (auto it = list.begin()+1; it != list.end(); it++) {
|
||||
if (it->second.have_all) {
|
||||
_tmp_bitset = {8};
|
||||
_tmp_bitset.invert();
|
||||
std::cout << "BIL: remote have all\n";
|
||||
break;
|
||||
}
|
||||
|
||||
_tmp_bitset.merge(it->second.have);
|
||||
}
|
||||
}
|
||||
|
||||
return haveToTexture(tu, _tmp_bitset, o);
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<TextureEntry> BitsetImageLoader::load(TextureUploaderI& tu, ObjectContactSub ocs) {
|
||||
if (!static_cast<bool>(ocs.o)) {
|
||||
std::cerr << "BIL error: trying to load invalid object\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (!ocs.o.all_of<ObjComp::F::RemoteHaveBitset>()) {
|
||||
// after completion, this is called until the texture times out
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto& map = ocs.o.get<ObjComp::F::RemoteHaveBitset>().others;
|
||||
auto it = map.find(ocs.c);
|
||||
if (it == map.end()) {
|
||||
// contact not found
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (it->second.have_all) {
|
||||
BitSet tmp{8}; // or 1?
|
||||
tmp.invert();
|
||||
return haveToTexture(tu, tmp, ocs.o);
|
||||
} else if (it->second.have.size_bits() == 0) {
|
||||
BitSet tmp{8}; // or 1?
|
||||
return haveToTexture(tu, tmp, ocs.o);
|
||||
} else {
|
||||
return haveToTexture(tu, it->second.have, ocs.o);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <solanaceae/object_store/fwd.hpp>
|
||||
#include <solanaceae/contact/contact_model3.hpp>
|
||||
#include <solanaceae/util/bitset.hpp>
|
||||
|
||||
#include "./texture_cache.hpp"
|
||||
|
||||
#include <optional>
|
||||
|
||||
struct ObjectContactSub final {
|
||||
ObjectHandle o;
|
||||
Contact3 c{entt::null};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct std::hash<ObjectContactSub> {
|
||||
std::size_t operator()(ObjectContactSub const& ocs) const noexcept {
|
||||
const std::size_t h1 = reinterpret_cast<std::size_t>(ocs.o.registry());
|
||||
const std::size_t h2 = entt::to_integral(ocs.o.entity());
|
||||
const std::size_t h3 = entt::to_integral(ocs.c);
|
||||
return (h1 << 3) ^ (h3 << 7) ^ (h2 * 11400714819323198485llu);
|
||||
}
|
||||
};
|
||||
|
||||
class BitsetImageLoader {
|
||||
BitSet _tmp_bitset;
|
||||
|
||||
std::optional<TextureEntry> haveToTexture(TextureUploaderI& tu, BitSet& have, ObjectHandle o);
|
||||
|
||||
public:
|
||||
BitsetImageLoader(void);
|
||||
std::optional<TextureEntry> load(TextureUploaderI& tu, ObjectHandle o);
|
||||
std::optional<TextureEntry> load(TextureUploaderI& tu, ObjectContactSub ocs);
|
||||
};
|
||||
|
||||
|
@ -1232,7 +1232,10 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) {
|
||||
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f);
|
||||
}
|
||||
|
||||
if (!upload && !o.all_of<ObjComp::F::TagLocalHaveAll>() && o.all_of<ObjComp::F::LocalHaveBitset>()) {
|
||||
if (
|
||||
(!upload && !o.all_of<ObjComp::F::TagLocalHaveAll>() && o.all_of<ObjComp::F::LocalHaveBitset>()) ||
|
||||
(upload && o.all_of<ObjComp::F::RemoteHaveBitset>())
|
||||
) {
|
||||
ImGui::BeginGroup();
|
||||
|
||||
// TODO: hights are all off
|
||||
@ -1266,7 +1269,6 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) {
|
||||
);
|
||||
|
||||
ImGui::EndGroup();
|
||||
//} else if (upload && o.all_of<ObjComp::F::RemoteHaveBitset>()) {
|
||||
} else {
|
||||
ImGui::ProgressBar(
|
||||
fraction,
|
||||
@ -1770,11 +1772,10 @@ void ChatGui4::sendFileList(const std::vector<std::string_view>& list) {
|
||||
}
|
||||
|
||||
bool ChatGui4::onEvent(const ObjectStore::Events::ObjectUpdate& e) {
|
||||
if (!e.e.all_of<ObjComp::F::LocalHaveBitset>()) {
|
||||
return false;
|
||||
if (e.e.any_of<ObjComp::F::LocalHaveBitset, ObjComp::F::RemoteHaveBitset>()) {
|
||||
_b_tc.stale(e.e);
|
||||
}
|
||||
|
||||
_b_tc.stale(e.e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -8,21 +8,6 @@
|
||||
|
||||
namespace ObjectStore::Components {
|
||||
|
||||
// until i find a better name
|
||||
namespace File {
|
||||
|
||||
// ephemeral?, not sure saving this to disk makes sense
|
||||
// tag remove have all?
|
||||
struct RemoteHaveBitset {
|
||||
struct Entry {
|
||||
bool have_all {false};
|
||||
BitSet have;
|
||||
};
|
||||
entt::dense_map<Contact3, Entry> others;
|
||||
};
|
||||
|
||||
} // File
|
||||
|
||||
namespace Ephemeral {
|
||||
|
||||
namespace File {
|
||||
|
@ -18,8 +18,6 @@ constexpr std::string_view entt::type_name<x>::value() noexcept { \
|
||||
|
||||
// cross compile(r) stable ids
|
||||
|
||||
DEFINE_COMP_ID(ObjComp::F::RemoteHaveBitset)
|
||||
|
||||
DEFINE_COMP_ID(ObjComp::Ephemeral::File::TransferStatsSeparated)
|
||||
|
||||
#undef DEFINE_COMP_ID
|
||||
|
Loading…
x
Reference in New Issue
Block a user