Cache system doesnt break when transforming objects
This commit is contained in:
parent
caea747f1e
commit
eb00125f01
9 changed files with 101 additions and 95 deletions
|
|
@ -1,12 +1,14 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include "../CollabList.hpp"
|
||||
#include "../DrawComponents/DrawComponent.hpp"
|
||||
#include <include/core/SkSurface.h>
|
||||
#include <unordered_set>
|
||||
#include "../DrawData.hpp"
|
||||
|
||||
class DrawingProgram;
|
||||
|
||||
class DrawComponent;
|
||||
|
||||
class DrawingProgramCache {
|
||||
public:
|
||||
typedef CollabList<std::shared_ptr<DrawComponent>, ServerClientID> CollabListType;
|
||||
|
|
@ -20,7 +22,7 @@ class DrawingProgramCache {
|
|||
struct BVHNode {
|
||||
SCollision::AABB<WorldScalar> bounds;
|
||||
std::vector<CollabListType::ObjectInfoPtr> components;
|
||||
std::vector<BVHNode> children;
|
||||
std::vector<std::shared_ptr<BVHNode>> children;
|
||||
|
||||
CoordSpaceHelper coords;
|
||||
Vector2i resolution;
|
||||
|
|
@ -33,25 +35,28 @@ class DrawingProgramCache {
|
|||
std::optional<DrawCacheData> drawCache;
|
||||
};
|
||||
|
||||
std::unordered_set<BVHNode*> nodesWithCachedSurfaces;
|
||||
std::unordered_set<std::shared_ptr<BVHNode>> nodesWithCachedSurfaces;
|
||||
|
||||
void traverse_bvh_run_function(const SCollision::AABB<WorldScalar>& aabb, std::function<bool(BVHNode* node, const std::vector<CollabListType::ObjectInfoPtr>& components)> f);
|
||||
void traverse_bvh_run_function(const SCollision::AABB<WorldScalar>& aabb, std::function<bool(const std::shared_ptr<BVHNode> node, const std::vector<CollabListType::ObjectInfoPtr>& components)> f);
|
||||
void force_rebuild();
|
||||
|
||||
// Run before actually updating the component
|
||||
void preupdate_component(DrawComponent* c);
|
||||
void preupdate_component(const CollabListType::ObjectInfoPtr& c);
|
||||
|
||||
void invalidate_cache_before_pos(uint64_t placementToInvalidateAt);
|
||||
private:
|
||||
void build_bvh_node_coords_and_resolution(BVHNode& node);
|
||||
void refresh_draw_cache(BVHNode& bvhNode, const DrawData& drawData);
|
||||
void refresh_draw_cache(const std::shared_ptr<BVHNode>& bvhNode, const DrawData& drawData);
|
||||
|
||||
void build(std::vector<CollabListType::ObjectInfoPtr> components);
|
||||
|
||||
void traverse_bvh_run_function_recursive(BVHNode& bvhNode, const SCollision::AABB<WorldScalar>& aabb, std::function<bool(BVHNode* node, const std::vector<CollabListType::ObjectInfoPtr>& components)> f);
|
||||
std::pair<DrawingProgramCache::BVHNode*, std::vector<DrawingProgramCache::CollabListType::ObjectInfoPtr>::iterator> get_bvh_node_fully_containing_recursive(BVHNode& bvhNode, DrawComponent* c);
|
||||
std::chrono::steady_clock::time_point lastBvhBuildTime;
|
||||
|
||||
void build_bvh_node(BVHNode& node, std::vector<CollabListType::ObjectInfoPtr> components);
|
||||
BVHNode bvhRoot;
|
||||
void traverse_bvh_run_function_recursive(const std::shared_ptr<BVHNode>& bvhNode, const SCollision::AABB<WorldScalar>& aabb, std::function<bool(const std::shared_ptr<BVHNode>& node, const std::vector<CollabListType::ObjectInfoPtr>& components)> f);
|
||||
std::pair<std::shared_ptr<DrawingProgramCache::BVHNode>, std::vector<DrawingProgramCache::CollabListType::ObjectInfoPtr>::iterator> get_bvh_node_fully_containing_recursive(const std::shared_ptr<BVHNode>& bvhNode, DrawComponent* c);
|
||||
|
||||
void build_bvh_node(const std::shared_ptr<BVHNode>& bvhNode, std::vector<CollabListType::ObjectInfoPtr> components);
|
||||
std::shared_ptr<BVHNode> bvhRoot;
|
||||
std::vector<CollabListType::ObjectInfoPtr> unsortedComponents;
|
||||
DrawingProgram& drawP;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue