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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user