1
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:9c184a1e5cc20654384071dfebc106ed",
|
||||
"GUID:bdb069e155d2f944cb1bf28602b6d4c1"
|
||||
"GUID:bdb069e155d2f944cb1bf28602b6d4c1",
|
||||
"GUID:1193c2664d97cc049a6e4c486c6bce71"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Pinwheel.Griffin;
|
||||
using UnityEditor.Build;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.WorldChunk
|
||||
{
|
||||
public class PolarisTerrainChunk : WorldChunk
|
||||
{
|
||||
private GTerrainChunk terrain;
|
||||
private MeshRenderer meshRenderer;
|
||||
private bool _isLoaded;
|
||||
private Rect _rect;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
terrain = GetComponent<GTerrainChunk>();
|
||||
meshRenderer = GetComponent<MeshRenderer>();
|
||||
|
||||
var bounds = meshRenderer.bounds;
|
||||
var pos = bounds.center;
|
||||
var size = bounds.size;
|
||||
|
||||
_rect = new Rect(
|
||||
pos.x,
|
||||
pos.z,
|
||||
size.x,
|
||||
size.y
|
||||
);
|
||||
Add(this);
|
||||
destroyCancellationToken.Register(() => { Remove(this); });
|
||||
|
||||
_isLoaded = gameObject.activeSelf;
|
||||
}
|
||||
public override Rect GetRect() => _rect;
|
||||
|
||||
public override void SetActive(bool active)
|
||||
{
|
||||
if (_isLoaded == active) return;
|
||||
terrain.gameObject.SetActive(active);
|
||||
_isLoaded = active;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Pinwheel.Griffin;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.WorldChunk
|
||||
{
|
||||
public class PolarisTerrainChunkManager : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
foreach (var x in GetComponentsInChildren<GTerrainChunk>())
|
||||
{
|
||||
x.gameObject.AddComponent<PolarisTerrainChunk>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Pinwheel.Griffin;
|
||||
using Quadtree;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.OpenWorld
|
||||
{
|
||||
public class PolarisTerrainChunkService : WorldChunkService<PolarisTerrainChunkService>
|
||||
{
|
||||
private class ChunkData:IWorldChunkObject
|
||||
{
|
||||
public Collider Collider { get; set; }
|
||||
public Bounds GetBounds() => Bounds;
|
||||
public Bounds Bounds { get; set; }
|
||||
public Node<IWorldChunkObject> ParentNode { get; set; }
|
||||
public void QuadTree_Root_Initialized(IQuadtreeRoot<IWorldChunkObject, Node<IWorldChunkObject>> root)
|
||||
{
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public int Lod
|
||||
{
|
||||
get => lod;
|
||||
set
|
||||
{
|
||||
Collider.enabled = value is 0;
|
||||
lod = value;
|
||||
}
|
||||
}
|
||||
private int lod=-1;
|
||||
}
|
||||
[SerializeField] private GStylizedTerrain[] terrains;
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
var reporter = new StringBuilder();
|
||||
foreach (var terrain in terrains)
|
||||
{
|
||||
reporter.AppendLine($"正在注册地形 {terrain.name},尺寸:{terrain.TerrainData.Geometry.Width}x{terrain.TerrainData.Geometry.Length}");
|
||||
foreach (var chunk in terrain.GetChunks())
|
||||
{
|
||||
var data =new ChunkData()
|
||||
{
|
||||
Collider = chunk.MeshColliderComponent,
|
||||
Bounds = chunk.MeshColliderComponent.bounds
|
||||
};
|
||||
data.Collider.enabled = false;
|
||||
Register(data);
|
||||
reporter.AppendLine($"注册地形碰撞体 {chunk.name},尺寸:{data.Bounds.size}");
|
||||
}
|
||||
}
|
||||
Debug.Log(reporter);
|
||||
OnTick(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user