new sorting wip

This commit is contained in:
2015-08-13 00:47:34 +06:00
parent 5cce4fd9c0
commit 5f99a6d537
20 changed files with 1913 additions and 1982 deletions

View File

@@ -111,7 +111,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 118226} m_GameObject: {fileID: 118226}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5.19999981, y: 1.29999995, z: 0} m_LocalPosition: {x: 128, y: 32, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 465650} - {fileID: 465650}

View File

@@ -83,7 +83,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 179380} m_GameObject: {fileID: 179380}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.94999993, y: 1.625, z: 33.9285774} m_LocalPosition: {x: 48, y: 40, z: 33.9285774}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 454690} - {fileID: 454690}

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 167384} m_GameObject: {fileID: 167384}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.6444999, z: 3.70370364} m_LocalPosition: {x: 0, y: 40.4799995, z: 3.70370364}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 427722} - {fileID: 427722}

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 147772} m_GameObject: {fileID: 147772}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: .455000013, y: 1.87199998, z: 14.8148146} m_LocalPosition: {x: 11.2000008, y: 46.0800018, z: 14.8148146}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 442410} - {fileID: 442410}

View File

@@ -39,7 +39,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 114888} m_GameObject: {fileID: 114888}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.29999995, y: .649999976, z: 22.2222233} m_LocalPosition: {x: 32, y: 16, z: 22.2222233}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 483872} - {fileID: 483872}

View File

@@ -39,7 +39,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155780} m_GameObject: {fileID: 155780}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -2.5999999, y: 0, z: 0} m_LocalPosition: {x: -64, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 457334} - {fileID: 457334}

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 112436} m_GameObject: {fileID: 112436}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.29999995, y: -.649999976, z: 0} m_LocalPosition: {x: 32, y: -16, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 400788} - {fileID: 400788}

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 189540} m_GameObject: {fileID: 189540}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.29999995, y: 1.94999993, z: 51.1110992} m_LocalPosition: {x: 32, y: 48, z: 51.1110992}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 482346} - {fileID: 482346}

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 149682} m_GameObject: {fileID: 149682}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 3.25, z: 97.7777481} m_LocalPosition: {x: 0, y: 80, z: 97.7777481}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 469780} - {fileID: 469780}

View File

@@ -39,7 +39,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 136960} m_GameObject: {fileID: 136960}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -.649999976, y: 2.92499995, z: 95.5555267} m_LocalPosition: {x: -16, y: 72, z: 95.5555267}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 438130} - {fileID: 438130}

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 107490} m_GameObject: {fileID: 107490}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.29999995, y: 2.5999999, z: 93.3333054} m_LocalPosition: {x: -32, y: 64, z: 93.3333054}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 433840} - {fileID: 433840}

View File

@@ -56,7 +56,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 194730} m_GameObject: {fileID: 194730}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -.649999976, y: -.974999964, z: 3.125} m_LocalPosition: {x: -16, y: -24, z: 3.125}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 458188} - {fileID: 458188}

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ namespace IsoTools {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// //
// size // Size
// //
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@@ -55,7 +55,7 @@ namespace IsoTools {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// //
// position // Position
// //
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@@ -99,7 +99,7 @@ namespace IsoTools {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// //
// tilePosition // TilePosition
// //
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@@ -137,7 +137,7 @@ namespace IsoTools {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// //
// bounds // Bounds
// //
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@@ -149,12 +149,12 @@ namespace IsoTools {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// //
// internal // Internal
// //
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
public class InternalState { public class InternalState {
public bool Moved = false; public bool Dirty = false;
public bool Visited = false; public bool Visited = false;
public Vector3 MinSector = Vector3.zero; public Vector3 MinSector = Vector3.zero;
public Vector3 MaxSector = Vector3.zero; public Vector3 MaxSector = Vector3.zero;
@@ -255,11 +255,10 @@ namespace IsoTools {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void Awake() { void Awake() {
Internal.SelfDepends = new HashSet<IsoObject>(new IsoObject[51]); Internal.SelfDepends = new HashSet<IsoObject>(new IsoObject[19]);
Internal.TheirDepends = new HashSet<IsoObject>(new IsoObject[51]);
Internal.SelfDepends.Clear(); Internal.SelfDepends.Clear();
Internal.TheirDepends = new HashSet<IsoObject>(new IsoObject[19]);
Internal.TheirDepends.Clear(); Internal.TheirDepends.Clear();
FixLastProperties(); FixLastProperties();
FixIsoPosition(); FixIsoPosition();
} }

View File

@@ -1,5 +1,4 @@
using UnityEngine; using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR #if UNITY_EDITOR
using UnityEditor; using UnityEditor;
@@ -8,36 +7,6 @@ using UnityEditor;
namespace IsoTools { namespace IsoTools {
public static class IsoUtils { public static class IsoUtils {
// ---------------------------------------------------------------------
//
// Poolable/Pool
//
// ---------------------------------------------------------------------
public interface IPoolable {
void Reset();
}
public class Pool<T> where T : IPoolable {
System.Func<T> _createFn = null;
Stack<T> _capacity = new Stack<T>();
public Pool(System.Func<T> create_fn) {
_createFn = create_fn;
}
public T Pop() {
return _capacity.Count > 0
? _capacity.Pop()
: _createFn();
}
public void Push(T value) {
value.Reset();
_capacity.Push(value);
}
}
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// //
// Consts // Consts
@@ -379,27 +348,6 @@ namespace IsoTools {
return a == b; return a == b;
} }
// ---------------------------------------------------------------------
//
// LookUpCube
//
// ---------------------------------------------------------------------
public static void LookUpCube(Vector2 min, Vector2 max, System.Action<Vector2> act) {
for ( var y = min.y; y < max.y; ++y ) {
for ( var x = min.x; x < max.x; ++x ) {
act(new Vector2(x, y));
}}
}
public static void LookUpCube(Vector3 min, Vector3 max, System.Action<Vector3> act) {
for ( var z = min.z; z < max.z; ++z ) {
for ( var y = min.y; y < max.y; ++y ) {
for ( var x = min.x; x < max.x; ++x ) {
act(new Vector3(x, y, z));
}}}
}
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// //
// Helpers // Helpers

View File

@@ -14,12 +14,14 @@ namespace IsoTools {
HashSet<IsoObject> _visibles = new HashSet<IsoObject>(); HashSet<IsoObject> _visibles = new HashSet<IsoObject>();
HashSet<IsoObject> _oldVisibles = new HashSet<IsoObject>(); HashSet<IsoObject> _oldVisibles = new HashSet<IsoObject>();
class SectorInfo { class Sector {
public List<IsoObject> objects = new List<IsoObject>(); public List<IsoObject> objects = new List<IsoObject>();
public void Reset() {
objects.Clear();
}
} }
List<SectorInfo> _sectors = new List<SectorInfo>(); List<Sector> _sectors = new List<Sector>();
Stack<SectorInfo> _sectorsPool = new Stack<SectorInfo>();
float _sectorsSize = 0.0f; float _sectorsSize = 0.0f;
Vector3 _sectorsMinNumPos = Vector3.zero; Vector3 _sectorsMinNumPos = Vector3.zero;
Vector3 _sectorsMaxNumPos = Vector3.zero; Vector3 _sectorsMaxNumPos = Vector3.zero;
@@ -61,20 +63,6 @@ namespace IsoTools {
} }
} }
public void MarkDirty() {
if ( !_dirty ) {
_dirty = true;
MarkEditorWorldDirty();
}
}
public void MarkDirty(IsoObject iso_object) {
if ( iso_object && _visibles.Contains(iso_object) ) {
iso_object.Internal.Moved = true;
MarkDirty();
}
}
public Vector2 IsoToScreen(Vector3 pos) { public Vector2 IsoToScreen(Vector3 pos) {
return new Vector2( return new Vector2(
(pos.x - pos.y), (pos.x - pos.y),
@@ -94,6 +82,26 @@ namespace IsoTools {
iso_z); iso_z);
} }
// ------------------------------------------------------------------------
//
// Internal
//
// ------------------------------------------------------------------------
public void MarkDirty() {
if ( !_dirty ) {
_dirty = true;
MarkEditorWorldDirty();
}
}
public void MarkDirty(IsoObject iso_object) {
if ( iso_object && _visibles.Contains(iso_object) ) {
iso_object.Internal.Dirty = true;
MarkDirty();
}
}
public void AddIsoObject(IsoObject iso_object) { public void AddIsoObject(IsoObject iso_object) {
_objects.Add(iso_object); _objects.Add(iso_object);
} }
@@ -132,26 +140,6 @@ namespace IsoTools {
: false; : false;
} }
/*
bool IsGameObjectVisible(GameObject obj) {
var renderer = obj.GetComponent<Renderer>();
if ( renderer && renderer.isVisible ) {
return true;
}
var obj_transform = obj.transform;
for ( var i = 0; i < obj_transform.childCount; ++i ) {
var child_obj = obj_transform.GetChild(i).gameObject;
if ( IsGameObjectVisible(child_obj) ) {
return true;
}
}
return false;
}
bool IsIsoObjectVisible(IsoObject iso_object) {
return IsGameObjectVisible(iso_object.gameObject);
}*/
bool IsIsoObjectDepends(Vector3 a_min, Vector3 a_size, Vector3 b_min, Vector3 b_size) { bool IsIsoObjectDepends(Vector3 a_min, Vector3 a_size, Vector3 b_min, Vector3 b_size) {
var a_max = a_min + a_size; var a_max = a_min + a_size;
var b_max = b_min + b_size; var b_max = b_min + b_size;
@@ -176,17 +164,6 @@ namespace IsoTools {
return IsIsoObjectDepends(a.position, a.size, b.position, b.size); return IsIsoObjectDepends(a.position, a.size, b.position, b.size);
} }
void PushSectorPool(SectorInfo sector) {
sector.objects.Clear();
_sectorsPool.Push(sector);
}
SectorInfo PopSectorPool() {
return _sectorsPool.Count > 0
? _sectorsPool.Pop()
: new SectorInfo();
}
int SectorIndex(Vector3 num_pos) { int SectorIndex(Vector3 num_pos) {
return Mathf.FloorToInt( return Mathf.FloorToInt(
num_pos.x + _sectorsNumPosCount.x * (num_pos.y + num_pos.z * _sectorsNumPosCount.y)); num_pos.x + _sectorsNumPosCount.x * (num_pos.y + num_pos.z * _sectorsNumPosCount.y));
@@ -201,7 +178,7 @@ namespace IsoTools {
return new Vector3(vx, vy, vz); return new Vector3(vx, vy, vz);
} }
SectorInfo FindSector(Vector3 num_pos) { Sector FindSector(Vector3 num_pos) {
if ( num_pos.x < 0 || num_pos.y < 0 || num_pos.z < 0 ) { if ( num_pos.x < 0 || num_pos.y < 0 || num_pos.z < 0 ) {
return null; return null;
} }
@@ -214,13 +191,13 @@ namespace IsoTools {
void LookUpSectorDepends(Vector3 num_pos, IsoObject obj_a) { void LookUpSectorDepends(Vector3 num_pos, IsoObject obj_a) {
var ms = FindSector(num_pos); var ms = FindSector(num_pos);
if ( ms != null ) { if ( ms != null ) {
Fun1(ms, obj_a); LookUpSectorDepends(ms, obj_a);
var s1 = FindSector(num_pos + new Vector3(-1, 0, 0)); var s1 = FindSector(num_pos + new Vector3(-1, 0, 0));
var s2 = FindSector(num_pos + new Vector3( 0, -1, 0)); var s2 = FindSector(num_pos + new Vector3( 0, -1, 0));
var s3 = FindSector(num_pos + new Vector3(-1, -1, 0)); var s3 = FindSector(num_pos + new Vector3(-1, -1, 0));
if ( s1 != null ) Fun1(s1, obj_a); if ( s1 != null ) LookUpSectorDepends(s1, obj_a);
if ( s2 != null ) Fun1(s2, obj_a); if ( s2 != null ) LookUpSectorDepends(s2, obj_a);
if ( s3 != null ) Fun1(s3, obj_a); if ( s3 != null ) LookUpSectorDepends(s3, obj_a);
for ( var i = 0; i <= _sectorsNumPosCount.z; ++i ) { for ( var i = 0; i <= _sectorsNumPosCount.z; ++i ) {
var ss1 = FindSector(num_pos + new Vector3( 0 - i, 0 - i, i + 1)); var ss1 = FindSector(num_pos + new Vector3( 0 - i, 0 - i, i + 1));
var ss2 = FindSector(num_pos + new Vector3(-1 - i, 0 - i, i + 1)); var ss2 = FindSector(num_pos + new Vector3(-1 - i, 0 - i, i + 1));
@@ -229,13 +206,24 @@ namespace IsoTools {
var ss5 = FindSector(num_pos + new Vector3(-2 - i, -1 - i, i + 1)); var ss5 = FindSector(num_pos + new Vector3(-2 - i, -1 - i, i + 1));
var ss6 = FindSector(num_pos + new Vector3(-1 - i, -2 - i, i + 1)); var ss6 = FindSector(num_pos + new Vector3(-1 - i, -2 - i, i + 1));
var ss7 = FindSector(num_pos + new Vector3(-2 - i, -2 - i, i + 1)); var ss7 = FindSector(num_pos + new Vector3(-2 - i, -2 - i, i + 1));
if ( ss1 != null ) Fun1(ss1, obj_a); if ( ss1 != null ) LookUpSectorDepends(ss1, obj_a);
if ( ss2 != null ) Fun1(ss2, obj_a); if ( ss2 != null ) LookUpSectorDepends(ss2, obj_a);
if ( ss3 != null ) Fun1(ss3, obj_a); if ( ss3 != null ) LookUpSectorDepends(ss3, obj_a);
if ( ss4 != null ) Fun1(ss4, obj_a); if ( ss4 != null ) LookUpSectorDepends(ss4, obj_a);
if ( ss5 != null ) Fun1(ss5, obj_a); if ( ss5 != null ) LookUpSectorDepends(ss5, obj_a);
if ( ss6 != null ) Fun1(ss6, obj_a); if ( ss6 != null ) LookUpSectorDepends(ss6, obj_a);
if ( ss7 != null ) Fun1(ss7, obj_a); if ( ss7 != null ) LookUpSectorDepends(ss7, obj_a);
}
}
}
void LookUpSectorDepends(Sector sec, IsoObject obj_a) {
var sec_objects_iter = sec.objects.GetEnumerator();
while ( sec_objects_iter.MoveNext() ) {
var obj_b = sec_objects_iter.Current;
if ( obj_a != obj_b && !obj_b.Internal.Dirty && IsIsoObjectDepends(obj_a, obj_b) ) {
obj_a.Internal.SelfDepends.Add(obj_b);
obj_b.Internal.TheirDepends.Add(obj_a);
} }
} }
} }
@@ -243,13 +231,13 @@ namespace IsoTools {
void LookUpSectorRDepends(Vector3 num_pos, IsoObject obj_a) { void LookUpSectorRDepends(Vector3 num_pos, IsoObject obj_a) {
var ms = FindSector(num_pos); var ms = FindSector(num_pos);
if ( ms != null ) { if ( ms != null ) {
Fun2(ms, obj_a); LookUpSectorRDepends(ms, obj_a);
var s1 = FindSector(num_pos + new Vector3( 1, 0, 0)); var s1 = FindSector(num_pos + new Vector3( 1, 0, 0));
var s2 = FindSector(num_pos + new Vector3( 0, 1, 0)); var s2 = FindSector(num_pos + new Vector3( 0, 1, 0));
var s3 = FindSector(num_pos + new Vector3( 1, 1, 0)); var s3 = FindSector(num_pos + new Vector3( 1, 1, 0));
if ( s1 != null ) Fun2(s1, obj_a); if ( s1 != null ) LookUpSectorRDepends(s1, obj_a);
if ( s2 != null ) Fun2(s2, obj_a); if ( s2 != null ) LookUpSectorRDepends(s2, obj_a);
if ( s3 != null ) Fun2(s3, obj_a); if ( s3 != null ) LookUpSectorRDepends(s3, obj_a);
for ( var i = 0; i <= _sectorsNumPosCount.z; ++i ) { for ( var i = 0; i <= _sectorsNumPosCount.z; ++i ) {
var ss1 = FindSector(num_pos + new Vector3( 0 + i, 0 + i, -i - 1)); var ss1 = FindSector(num_pos + new Vector3( 0 + i, 0 + i, -i - 1));
var ss2 = FindSector(num_pos + new Vector3( 1 + i, 0 + i, -i - 1)); var ss2 = FindSector(num_pos + new Vector3( 1 + i, 0 + i, -i - 1));
@@ -258,13 +246,24 @@ namespace IsoTools {
var ss5 = FindSector(num_pos + new Vector3( 2 + i, 1 + i, -i - 1)); var ss5 = FindSector(num_pos + new Vector3( 2 + i, 1 + i, -i - 1));
var ss6 = FindSector(num_pos + new Vector3( 1 + i, 2 + i, -i - 1)); var ss6 = FindSector(num_pos + new Vector3( 1 + i, 2 + i, -i - 1));
var ss7 = FindSector(num_pos + new Vector3( 2 + i, 2 + i, -i - 1)); var ss7 = FindSector(num_pos + new Vector3( 2 + i, 2 + i, -i - 1));
if ( ss1 != null ) Fun2(ss1, obj_a); if ( ss1 != null ) LookUpSectorRDepends(ss1, obj_a);
if ( ss2 != null ) Fun2(ss2, obj_a); if ( ss2 != null ) LookUpSectorRDepends(ss2, obj_a);
if ( ss3 != null ) Fun2(ss3, obj_a); if ( ss3 != null ) LookUpSectorRDepends(ss3, obj_a);
if ( ss4 != null ) Fun2(ss4, obj_a); if ( ss4 != null ) LookUpSectorRDepends(ss4, obj_a);
if ( ss5 != null ) Fun2(ss5, obj_a); if ( ss5 != null ) LookUpSectorRDepends(ss5, obj_a);
if ( ss6 != null ) Fun2(ss6, obj_a); if ( ss6 != null ) LookUpSectorRDepends(ss6, obj_a);
if ( ss7 != null ) Fun2(ss7, obj_a); if ( ss7 != null ) LookUpSectorRDepends(ss7, obj_a);
}
}
}
void LookUpSectorRDepends(Sector sec, IsoObject obj_a) {
var sec_objects_iter = sec.objects.GetEnumerator();
while ( sec_objects_iter.MoveNext() ) {
var obj_b = sec_objects_iter.Current;
if ( obj_a != obj_b && !obj_b.Internal.Dirty && IsIsoObjectDepends(obj_b, obj_a) ) {
obj_b.Internal.SelfDepends.Add(obj_a);
obj_a.Internal.TheirDepends.Add(obj_b);
} }
} }
} }
@@ -295,19 +294,19 @@ namespace IsoTools {
_sectorsNumPosCount = _sectorsMaxNumPos - _sectorsMinNumPos; _sectorsNumPosCount = _sectorsMaxNumPos - _sectorsMinNumPos;
} }
void ClearSectors() { void ResizeSectors(int count) {
if ( _sectors.Count < count ) {
if ( _sectors.Capacity < count ) {
_sectors.Capacity = count;
}
while ( _sectors.Count < _sectors.Capacity ) {
_sectors.Add(new Sector());
}
}
var sectors_iter = _sectors.GetEnumerator(); var sectors_iter = _sectors.GetEnumerator();
while ( sectors_iter.MoveNext() ) { while ( sectors_iter.MoveNext() ) {
PushSectorPool(sectors_iter.Current); sectors_iter.Current.Reset();
}
_sectors.Clear();
}
void ResizeSectors(int count) {
_sectors.Capacity = count;
while ( _sectors.Count < _sectors.Capacity ) {
var sector = PopSectorPool();
_sectors.Add(sector);
} }
} }
@@ -317,15 +316,6 @@ namespace IsoTools {
var iso_object = visibles_iter.Current; var iso_object = visibles_iter.Current;
iso_object.Internal.MinSector -= _sectorsMinNumPos; iso_object.Internal.MinSector -= _sectorsMinNumPos;
iso_object.Internal.MaxSector -= _sectorsMinNumPos; iso_object.Internal.MaxSector -= _sectorsMinNumPos;
/*
IsoUtils.LookUpCube(iso_object.Internal.MinSector, iso_object.Internal.MaxSector, p => {
var sector = FindSector(p);
if ( sector != null ) {
sector.objects.Add(iso_object);
}
});*/
var min = iso_object.Internal.MinSector; var min = iso_object.Internal.MinSector;
var max = iso_object.Internal.MaxSector; var max = iso_object.Internal.MaxSector;
for ( var z = min.z; z < max.z; ++z ) { for ( var z = min.z; z < max.z; ++z ) {
@@ -340,19 +330,18 @@ namespace IsoTools {
} }
void SetupSectors() { void SetupSectors() {
ClearSectors();
ResizeSectors(Mathf.FloorToInt(_sectorsNumPosCount.x * _sectorsNumPosCount.y * _sectorsNumPosCount.z)); ResizeSectors(Mathf.FloorToInt(_sectorsNumPosCount.x * _sectorsNumPosCount.y * _sectorsNumPosCount.z));
TuneSectors(); TuneSectors();
} }
void StepSort() { void StepSort() {
//Profiler.BeginSample("UpdateVisibles"); Profiler.BeginSample("UpdateVisibles");
UpdateVisibles(); UpdateVisibles();
//Profiler.EndSample(); Profiler.EndSample();
if ( _dirty ) { if ( _dirty ) {
//Profiler.BeginSample("PlaceAllVisibles"); Profiler.BeginSample("PlaceAllVisibles");
PlaceAllVisibles(); PlaceAllVisibles();
//Profiler.EndSample(); Profiler.EndSample();
_dirty = false; _dirty = false;
} }
} }
@@ -367,18 +356,18 @@ namespace IsoTools {
var visibles_iter = _visibles.GetEnumerator(); var visibles_iter = _visibles.GetEnumerator();
while ( visibles_iter.MoveNext() ) { while ( visibles_iter.MoveNext() ) {
var iso_object = visibles_iter.Current; var iso_object = visibles_iter.Current;
if ( iso_object.Internal.Moved || !_oldVisibles.Contains(iso_object) ) { if ( iso_object.Internal.Dirty || !_oldVisibles.Contains(iso_object) ) {
iso_object.Internal.Moved = true; iso_object.Internal.Dirty = true;
} }
} }
visibles_iter = _visibles.GetEnumerator(); visibles_iter = _visibles.GetEnumerator();
while ( visibles_iter.MoveNext() ) { while ( visibles_iter.MoveNext() ) {
var iso_object = visibles_iter.Current; var iso_object = visibles_iter.Current;
if ( iso_object.Internal.Moved ) { if ( iso_object.Internal.Dirty ) {
MarkDirty(); MarkDirty();
SetupIsoObjectDepends(iso_object); SetupIsoObjectDepends(iso_object);
iso_object.Internal.Moved = false; iso_object.Internal.Dirty = false;
} }
} }
@@ -418,27 +407,6 @@ namespace IsoTools {
iso_object.Internal.SelfDepends.Clear(); iso_object.Internal.SelfDepends.Clear();
iso_object.Internal.TheirDepends.Clear(); iso_object.Internal.TheirDepends.Clear();
} }
void Fun1(SectorInfo sec, IsoObject obj_a) {
var sec_objects_iter = sec.objects.GetEnumerator();
while ( sec_objects_iter.MoveNext() ) {
var obj_b = sec_objects_iter.Current;
if ( obj_a != obj_b && !obj_b.Internal.Moved && IsIsoObjectDepends(obj_a, obj_b) ) {
obj_a.Internal.SelfDepends.Add(obj_b);
obj_b.Internal.TheirDepends.Add(obj_a);
}
}
}
void Fun2(SectorInfo sec, IsoObject obj_a) {
var sec_objects_iter = sec.objects.GetEnumerator();
while ( sec_objects_iter.MoveNext() ) {
var obj_b = sec_objects_iter.Current;
if ( obj_a != obj_b && !obj_b.Internal.Moved && IsIsoObjectDepends(obj_b, obj_a) ) {
obj_b.Internal.SelfDepends.Add(obj_a);
obj_a.Internal.TheirDepends.Add(obj_b);
}
}
}
void SetupIsoObjectDepends(IsoObject obj_a) { void SetupIsoObjectDepends(IsoObject obj_a) {
ClearIsoObjectDepends(obj_a); ClearIsoObjectDepends(obj_a);
@@ -451,9 +419,6 @@ namespace IsoTools {
LookUpSectorDepends(v, obj_a); LookUpSectorDepends(v, obj_a);
LookUpSectorRDepends(v, obj_a); LookUpSectorRDepends(v, obj_a);
}}} }}}
if ( obj_a.Internal.SelfDepends.Count > 45 ) {
//Debug.LogFormat("Self: {0}, Their: {1}", obj_a.Internal.SelfDepends.Count, obj_a.Internal.TheirDepends.Count);
}
} }
void PlaceAllVisibles() { void PlaceAllVisibles() {

View File

@@ -14,12 +14,16 @@ QualitySettings:
shadowProjection: 1 shadowProjection: 1
shadowCascades: 1 shadowCascades: 1
shadowDistance: 15 shadowDistance: 15
shadowCascade2Split: .333333343
shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669}
blendWeights: 1 blendWeights: 1
textureQuality: 1 textureQuality: 1
anisotropicTextures: 0 anisotropicTextures: 0
antiAliasing: 0 antiAliasing: 0
softParticles: 0 softParticles: 0
softVegetation: 0 softVegetation: 0
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 0
vSyncCount: 0 vSyncCount: 0
lodBias: .300000012 lodBias: .300000012
maximumLODLevel: 0 maximumLODLevel: 0
@@ -33,12 +37,16 @@ QualitySettings:
shadowProjection: 1 shadowProjection: 1
shadowCascades: 1 shadowCascades: 1
shadowDistance: 20 shadowDistance: 20
shadowCascade2Split: .333333343
shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669}
blendWeights: 2 blendWeights: 2
textureQuality: 0 textureQuality: 0
anisotropicTextures: 0 anisotropicTextures: 0
antiAliasing: 0 antiAliasing: 0
softParticles: 0 softParticles: 0
softVegetation: 0 softVegetation: 0
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 0
vSyncCount: 0 vSyncCount: 0
lodBias: .400000006 lodBias: .400000006
maximumLODLevel: 0 maximumLODLevel: 0
@@ -52,12 +60,16 @@ QualitySettings:
shadowProjection: 1 shadowProjection: 1
shadowCascades: 1 shadowCascades: 1
shadowDistance: 20 shadowDistance: 20
shadowCascade2Split: .333333343
shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669}
blendWeights: 2 blendWeights: 2
textureQuality: 0 textureQuality: 0
anisotropicTextures: 1 anisotropicTextures: 1
antiAliasing: 0 antiAliasing: 0
softParticles: 0 softParticles: 0
softVegetation: 0 softVegetation: 0
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 0
vSyncCount: 0 vSyncCount: 0
lodBias: .699999988 lodBias: .699999988
maximumLODLevel: 0 maximumLODLevel: 0
@@ -71,12 +83,16 @@ QualitySettings:
shadowProjection: 1 shadowProjection: 1
shadowCascades: 2 shadowCascades: 2
shadowDistance: 40 shadowDistance: 40
shadowCascade2Split: .333333343
shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669}
blendWeights: 2 blendWeights: 2
textureQuality: 0 textureQuality: 0
anisotropicTextures: 1 anisotropicTextures: 1
antiAliasing: 0 antiAliasing: 0
softParticles: 0 softParticles: 0
softVegetation: 1 softVegetation: 1
realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
vSyncCount: 1 vSyncCount: 1
lodBias: 1 lodBias: 1
maximumLODLevel: 0 maximumLODLevel: 0
@@ -90,12 +106,16 @@ QualitySettings:
shadowProjection: 1 shadowProjection: 1
shadowCascades: 2 shadowCascades: 2
shadowDistance: 70 shadowDistance: 70
shadowCascade2Split: .333333343
shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669}
blendWeights: 4 blendWeights: 4
textureQuality: 0 textureQuality: 0
anisotropicTextures: 2 anisotropicTextures: 2
antiAliasing: 2 antiAliasing: 2
softParticles: 1 softParticles: 1
softVegetation: 1 softVegetation: 1
realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
vSyncCount: 1 vSyncCount: 1
lodBias: 1.5 lodBias: 1.5
maximumLODLevel: 0 maximumLODLevel: 0
@@ -109,32 +129,30 @@ QualitySettings:
shadowProjection: 1 shadowProjection: 1
shadowCascades: 4 shadowCascades: 4
shadowDistance: 150 shadowDistance: 150
shadowCascade2Split: .333333343
shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669}
blendWeights: 4 blendWeights: 4
textureQuality: 0 textureQuality: 0
anisotropicTextures: 2 anisotropicTextures: 2
antiAliasing: 2 antiAliasing: 2
softParticles: 1 softParticles: 1
softVegetation: 1 softVegetation: 1
realtimeReflectionProbes: 1
billboardsFaceCameraPosition: 1
vSyncCount: 1 vSyncCount: 1
lodBias: 2 lodBias: 2
maximumLODLevel: 0 maximumLODLevel: 0
particleRaycastBudget: 4096 particleRaycastBudget: 4096
excludedTargetPlatforms: [] excludedTargetPlatforms: []
m_PerPlatformDefaultQuality: m_PerPlatformDefaultQuality:
Android: 2 '': 0
BlackBerry: 2 Android: 0
FlashPlayer: 3 BlackBerry: 0
GLES Emulation: 3 Samsung TV: 0
PS3: 3 Standalone: 0
PS4: 3 Web: 0
PSM: 3 WebGL: 0
PSP2: 3
Samsung TV: 2
Standalone: 3
Tizen: 2
WP8: 3
Web: 3
Windows Store Apps: 3 Windows Store Apps: 3
XBOX360: 3 XBOX360: 0
XboxOne: 3 XboxOne: 0
iPhone: 2 iPhone: 0

View File

@@ -23,7 +23,7 @@ Global
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Assembly-CSharp.csproj StartupItem = Assembly-CSharp.csproj
Policies = $0 Policies = $0
$0.TextStylePolicy = $1 $0.TextStylePolicy = $1

View File

@@ -23,7 +23,7 @@ Global
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Assembly-CSharp.csproj StartupItem = Assembly-CSharp.csproj
Policies = $0 Policies = $0
$0.TextStylePolicy = $1 $0.TextStylePolicy = $1

View File

@@ -1,9 +1,10 @@
<Properties> <Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="MonoDevelop.Default" /> <MonoDevelop.Ide.Workspace />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/IsoTools/Scripts/IsoWorld.cs"> <MonoDevelop.Ide.Workbench ActiveDocument="Assets/IsoTools/Scripts/IsoWorld.cs">
<Files> <Files>
<File FileName="Assets/IsoTools/Scripts/IsoObject.cs" Line="258" Column="70" /> <File FileName="Assets/IsoTools/Scripts/IsoWorld.cs" Line="191" Column="4" />
<File FileName="Assets/IsoTools/Scripts/IsoWorld.cs" Line="169" Column="29" /> <File FileName="Assets/IsoTools/Scripts/IsoUtils.cs" Line="385" Column="4" />
<File FileName="Assets/IsoTools/Scripts/IsoObject.cs" Line="157" Column="30" />
</Files> </Files>
</MonoDevelop.Ide.Workbench> </MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints> <MonoDevelop.Ide.DebuggingService.Breakpoints>