Cache system doesnt break when transforming objects

This commit is contained in:
Yousef Khadadeh 2025-07-21 11:59:19 +03:00
parent caea747f1e
commit eb00125f01
9 changed files with 101 additions and 95 deletions

View file

@ -109,14 +109,14 @@ void DrawComponent::check_timers(DrawingProgram& drawP) {
}
void DrawComponent::temp_update(DrawingProgram& drawP) {
drawP.compCache.preupdate_component(this);
drawP.compCache.preupdate_component(collabListInfo.lock());
worldAABB = std::nullopt;
initialize_draw_data(drawP);
updateDraw = true;
}
void DrawComponent::transform_temp_update(DrawingProgram& drawP) {
drawP.compCache.preupdate_component(this);
drawP.compCache.preupdate_component(collabListInfo.lock());
worldAABB = std::nullopt;
updateDraw = true;
}
@ -127,12 +127,6 @@ void DrawComponent::final_update(DrawingProgram& drawP) {
updateDraw = true;
}
void DrawComponent::final_update_dont_invalidate_cache(DrawingProgram& drawP) {
initialize_draw_data(drawP);
finalize_update(drawP, false);
updateDraw = true;
}
void DrawComponent::client_send_place(DrawingProgram& drawP, uint64_t placement) {
drawP.world.con.client_send_items_to_server(RELIABLE_COMMAND_CHANNEL, SERVER_PLACE_COMPONENT, placement, get_type(), this->coords, *this);
}
@ -159,7 +153,7 @@ void DrawComponent::client_send_transform_final(DrawingProgram& drawP, ServerCli
void DrawComponent::finalize_update(DrawingProgram& drawP, bool invalidateCache) {
if(invalidateCache)
drawP.compCache.preupdate_component(this);
drawP.compCache.preupdate_component(collabListInfo.lock());
create_collider(drawP.colliderAllocated);
updateDraw = true;
}

View file

@ -5,6 +5,8 @@
#include "../SharedTypes.hpp"
#include "../CoordSpaceHelper.hpp"
#include "../Server/MainServer.hpp"
#include "../CollabList.hpp"
#include "../DrawingProgram/DrawingProgramCache.hpp"
#ifndef IS_SERVER
#include "../DrawData.hpp"
@ -64,6 +66,9 @@ class DrawComponent {
std::chrono::time_point<std::chrono::steady_clock> tempServerTransformTimer;
bool serverIsTempTransform = false;
std::weak_ptr<CollabList<std::shared_ptr<DrawComponent>, ServerClientID>::ObjectInfo> collabListInfo;
std::weak_ptr<DrawingProgramCache::BVHNode> parentBvhNode;
void server_update(MainServer& server, ServerClientID id);
#ifndef IS_SERVER
@ -100,7 +105,6 @@ class DrawComponent {
virtual void draw(SkCanvas* canvas, const DrawData& drawData) = 0;
void temp_update(DrawingProgram& drawP);
void final_update(DrawingProgram& drawP);
void final_update_dont_invalidate_cache(DrawingProgram& drawP);
void transform_temp_update(DrawingProgram& drawP);
virtual void initialize_draw_data(DrawingProgram& drawP) = 0;
virtual void finalize_update(DrawingProgram& drawP, bool invalidateCache = true);