9f2536498b
P0 实现(11/11 完成,0 stub 残留): - mesh: QEM 简化、Laplacian 平滑、质量评估、修复、3D 布尔 - spatial: Octree、KD-Tree、R-Tree 完整实现 - collision: GJK 距离+EPA 穿透深度、SAT、Tri-Tri 相交 - boolean: Vatti 2D 布尔扫描线算法 - core: 3D 凸包 QuickHull - spatial/BVH: 最近命中查询(AABB slab + Möller-Trumbore) 文档新增: - 05-核心竞争力与差异化功能(14 项独有功能) - SRS 扩展到 16 类 FR、100+ 条目 - 杀手功能:约束求解器/SDF隐式建模/可微分几何/惰性管线/Python绑定
31 lines
1.0 KiB
C++
31 lines
1.0 KiB
C++
#pragma once
|
|
#include "vde/spatial/spatial_index.h"
|
|
#include <memory>
|
|
|
|
namespace vde::spatial {
|
|
|
|
template <typename T> struct OctreeNode;
|
|
template <typename T> struct OctreeData;
|
|
|
|
template <typename T>
|
|
class Octree : public SpatialIndex<T> {
|
|
public:
|
|
explicit Octree(int max_depth = 8, int max_items = 16);
|
|
void build(const std::vector<T>& items) override;
|
|
void insert(const T& item) override;
|
|
bool remove(const T& item) override;
|
|
std::vector<T> query_range(const AABB3D& range) const override;
|
|
std::vector<T> query_knn(const Point3D& point, size_t k) const override;
|
|
std::vector<T> query_ray(const Ray3Dd& ray) const override;
|
|
void clear() override;
|
|
size_t size() const override;
|
|
private:
|
|
void insert_recursive(int node_idx, const T& item, int depth);
|
|
void subdivide_recursive(int node_idx, int depth);
|
|
void query_range_recursive(int node_idx, const AABB3D& range, std::vector<T>& result) const;
|
|
std::shared_ptr<OctreeData<T>> data_;
|
|
int max_depth_, max_items_;
|
|
};
|
|
|
|
} // namespace vde::spatial
|