资源简介
C#实现的4叉树算法,亲测可用。适合初学者
代码片段和文件信息
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public delegate void UQtCellChanged(UQtLeaf left UQtLeaf entered);
public delegate void UQtCellSwapIn(UQtLeaf leaf);
public delegate void UQtCellSwapOut(UQtLeaf leaf);
public static class UQtConfig
{
// this value determines the smallest cell size
// the space-partition process would stop dividing if cell size is smaller than this value
public static float CellSizeThreshold = 50.0f;
// swap-in distance of cells
public static float CellSwapInDist = 100.0f;
// swap-out distance of cells
// (would be larger than swap-in to prevent poping)
public static float CellSwapOutDist = 150.0f;
// time interval to update the focus point
// so that a new swap would potentially triggered (in seconds)
public static float SwapTriggerInterval = 0.5f;
// time interval to update the in/out swapping queues (in seconds)
public static float SwapProcessInterval = 0.2f;
}
// user data stored in quadtree leaves
public interface IQtUserData
{
Vector3 GetCenter();
Vector3 GetExtends();
void SwapIn();
void SwapOut();
bool IsSwapInCompleted();
bool IsSwapOutCompleted();
}
public class UQtNode
{
public UQtNode(Rect bound)
{
_bound = bound;
}
public Rect Bound { get { return _bound; } }
protected Rect _bound;
public virtual void SetSubNodes(UQtNode[] subNodes)
{
_subNodes = subNodes;
}
public virtual void Receive(IQtUserData userData)
{
if (!UQtAlgo.Intersects(Bound userData))
{
return;
}
foreach (var sub in SubNodes)
{
sub.Receive(userData);
}
}
public UQtNode[] SubNodes { get { return _subNodes; } }
public const int SubCount = 4;
protected UQtNode[] _subNodes = null;
}
public class UQtLeaf : UQtNode
{
public UQtLeaf(Rect bound) : base(bound)
{
}
public override void SetSubNodes(UQtNode[] subNodes)
{
UCore.Assert(false);
}
public override void Receive(IQtUserData userData)
{
if (!UQtAlgo.Intersects(Bound userData))
return;
if (Bound.Contains(new Vector2(userData.GetCenter().x userData.GetCenter().z)))
{
_ownedobjects.Add(userData);
}
else
{
_affectedobjects.Add(userData);
}
}
public void SwapIn()
{
foreach (var obj in _ownedobjects)
obj.SwapIn();
foreach (var obj in _affectedobjects)
obj.SwapIn();
}
public void SwapOut()
{
foreach (var obj in _ownedobjects)
obj.SwapOut();
foreach (var obj in _affectedobjects)
obj.SwapOut();
}
public bool IsSwapInCompleted()
{
foreach (var obj in _ownedobjects)
{
if (!obj.IsSwapInCompleted())
return false;
}
fore
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-07-19 06:56 uquadtree-master\
文件 499 2015-07-19 06:56 uquadtree-master\.gitignore
文件 1084 2015-07-19 06:56 uquadtree-master\LICENSE
文件 128 2015-07-19 06:56 uquadtree-master\README.md
目录 0 2015-07-19 06:56 uquadtree-master\uquadtree\
目录 0 2015-07-19 06:56 uquadtree-master\uquadtree\Unity-5.0.1f1\
文件 3470336 2015-07-19 06:56 uquadtree-master\uquadtree\Unity-5.0.1f1\UnityEditor.dll
文件 794112 2015-07-19 06:56 uquadtree-master\uquadtree\Unity-5.0.1f1\UnityEngine.dll
文件 974 2015-07-19 06:56 uquadtree-master\uquadtree\uquadtree.sln
目录 0 2015-07-19 06:56 uquadtree-master\uquadtree\uquadtree\
目录 0 2015-07-19 06:56 uquadtree-master\uquadtree\uquadtree\Properties\
文件 1394 2015-07-19 06:56 uquadtree-master\uquadtree\uquadtree\Properties\AssemblyInfo.cs
文件 7628 2015-07-19 06:56 uquadtree-master\uquadtree\uquadtree\UQuadtree.cs
文件 4971 2015-07-19 06:56 uquadtree-master\uquadtree\uquadtree\UQuadtree_Internal.cs
文件 2604 2015-07-19 06:56 uquadtree-master\uquadtree\uquadtree\uquadtree.csproj
目录 0 2015-07-19 06:56 uquadtree-master\uquadtree_test\
目录 0 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\
文件 191 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree.me
目录 0 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\
文件 191 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\Materials.me
目录 0 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\Materials\
文件 4268 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\Materials\Ground.mat
文件 179 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\Materials\Ground.mat.me
文件 191 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\Scenes.me
目录 0 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\Scenes\
文件 34178 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\Scenes\test_scene.unity
文件 174 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\Scenes\test_scene.unity.me
文件 191 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\sc
目录 0 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\sc
文件 1900 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\sc
文件 262 2015-07-19 06:56 uquadtree-master\uquadtree_test\Assets\UQuadtree\sc
............此处省略19个文件信息
- 上一篇:C#开发的医院挂号管理系统
- 下一篇:skyline C#
相关资源
- skyline C#
- C#开发的医院挂号管理系统
- 学生宿舍管理系统c#winform窗体程序
- C#考试管理系统C/S
- C# 科学计算器 华东师范大学 作业
- C#拼图游戏源代码
- C#在线考试随机出题系统
- c# 网页抓取分析 表格图形生成
- Professional C# 7 and .NET Core 2.0 源码
- C#写的桌面倒计时器,可用于各种竞赛
- C#库存管理系统visual studio2005
- C#编写的人事管理系统源码配有数据库
- 两款基于Windows的桌面管理系统.net(
- c#电子邮件收发系统
- IP_camera网络摄像头c#程序
- c#网络应用开发例学与实践
- Winform C# C/S 程序 html 富文本编辑器
- C# SqlServer 进销存毕业设计及论文字数
- [WPF系列] Prism MVVM 模式应用开发指南
- [源代码] C# WinForms 项目实战 - 人事工
- [源代码] C# WinForms 项目实战 - 企业客
- [源代码] C# ASP.NET 项目实战 - 新闻发布
- [源代码] C# ASP.NET 项目实战 - 图书馆管
- C# ASP.NET 模块 - 购物车模块
- C# 桌面背单词软件测试版。。只有一
- C# 网吧管理系统
- c#微信通讯的Web平台
- C#药店管理系统(C-SHARP源码)
- 超漂亮带音乐的C#俄罗斯方块源代码能
- c#做的简单图书管理系统
评论
共有 条评论