begin isoworld refactoring

This commit is contained in:
2016-12-22 23:53:35 +07:00
parent 9bef427c5f
commit 780d0391aa
8 changed files with 1354 additions and 453 deletions

View File

@@ -190,7 +190,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalPosition.z
value: 1.9000002
value: 1.8000002
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalRotation.x
@@ -252,7 +252,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.z
value: 1.5000001
value: 2.0000002
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.x
@@ -662,7 +662,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 439388, guid: d564723f17e5b453ab3cf2ba1886790d, type: 2}
propertyPath: m_LocalPosition.z
value: 1
value: 2.2
objectReference: {fileID: 0}
- target: {fileID: 439388, guid: d564723f17e5b453ab3cf2ba1886790d, type: 2}
propertyPath: m_LocalRotation.x
@@ -1094,7 +1094,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalPosition.z
value: 2.1000001
value: 1.9000002
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalRotation.x
@@ -1156,7 +1156,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 452998, guid: a8efaa982fcfd42a495b3649618fac91, type: 2}
propertyPath: m_LocalPosition.z
value: 1.3000001
value: 1.2
objectReference: {fileID: 0}
- target: {fileID: 452998, guid: a8efaa982fcfd42a495b3649618fac91, type: 2}
propertyPath: m_LocalRotation.x
@@ -1296,7 +1296,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalPosition.z
value: 1.4000001
value: 2.0000002
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalRotation.x
@@ -1429,7 +1429,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 439388, guid: d564723f17e5b453ab3cf2ba1886790d, type: 2}
propertyPath: m_LocalPosition.z
value: 1.5000001
value: 1.4000001
objectReference: {fileID: 0}
- target: {fileID: 439388, guid: d564723f17e5b453ab3cf2ba1886790d, type: 2}
propertyPath: m_LocalRotation.x
@@ -1489,7 +1489,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalPosition.z
value: 2.2
value: 2.3
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalRotation.x
@@ -1719,7 +1719,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 439388, guid: dd0c4026a6d694c3dade62fd46e77651, type: 2}
propertyPath: m_LocalPosition.z
value: 2.0000002
value: 1.5000001
objectReference: {fileID: 0}
- target: {fileID: 439388, guid: dd0c4026a6d694c3dade62fd46e77651, type: 2}
propertyPath: m_LocalRotation.x
@@ -1904,7 +1904,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.z
value: 2.0000002
value: 1.5000001
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.x
@@ -2050,7 +2050,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 439388, guid: d564723f17e5b453ab3cf2ba1886790d, type: 2}
propertyPath: m_LocalPosition.z
value: 1.2
value: 1.1
objectReference: {fileID: 0}
- target: {fileID: 439388, guid: d564723f17e5b453ab3cf2ba1886790d, type: 2}
propertyPath: m_LocalRotation.x
@@ -2193,7 +2193,7 @@ Prefab:
m_Modifications:
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.x
value: -4.2424803
value: -4.24292
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.y
@@ -2225,11 +2225,11 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.x
value: -3.6706
value: -3.6707
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.y
value: -0.6176
value: -0.6175
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.z
@@ -2427,7 +2427,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalPosition.z
value: 2.3
value: 1.3000001
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalRotation.x
@@ -2571,7 +2571,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 452998, guid: c0f50e2db7b084147b02788fcd9b9e0d, type: 2}
propertyPath: m_LocalPosition.z
value: 1.8000002
value: 2.1000001
objectReference: {fileID: 0}
- target: {fileID: 452998, guid: c0f50e2db7b084147b02788fcd9b9e0d, type: 2}
propertyPath: m_LocalRotation.x
@@ -2629,7 +2629,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalPosition.z
value: 1.1
value: 1
objectReference: {fileID: 0}
- target: {fileID: 467434, guid: 724acce3e28b04f4ab4302d47fe5429d, type: 2}
propertyPath: m_LocalRotation.x

View File

@@ -0,0 +1,741 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 3
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
--- !u!157 &4
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 4
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 0
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_DirectLightInLightProbes: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 1024
m_ReflectionCompression: 2
m_LightingDataAsset: {fileID: 0}
m_RuntimeCPUUsage: 25
--- !u!196 &5
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
accuratePlacement: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &522845241
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 522845242}
- component: {fileID: 522845244}
- component: {fileID: 522845243}
m_Layer: 0
m_Name: IsoWorld
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &522845242
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 522845241}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1378790441}
- {fileID: 811987150}
- {fileID: 1132388994}
- {fileID: 1887318779}
- {fileID: 769235454}
- {fileID: 1680987096}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &522845243
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 522845241}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f1e3b581728784cafa59b549fe35214b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &522845244
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 522845241}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3f01619d3802e814f86f9e6bb965349a, type: 3}
m_Name:
m_EditorClassIdentifier:
_tileSize: 2.2
_tileRatio: 0.5
_tileAngle: 45
_tileHeight: 1.6
_stepDepth: 0.1
_startDepth: 1
_showIsoBounds: 0
_showScreenBounds: 0
_showDepends: 1
_snapByCells: 1
_snapByObjects: 1
--- !u!1001 &769235453
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 522845242}
m_Modifications:
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.x
value: 2.2000008
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.y
value: -3.3
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.z
value: 1
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.x
value: -1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.y
value: -2
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showTheirDepends
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showIsoBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showScreenBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showSelfDepends
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Name
value: TileA (5)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_IsPrefabParent: 0
--- !u!4 &769235454 stripped
Transform:
m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_PrefabInternal: {fileID: 769235453}
--- !u!1001 &811987149
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 522845242}
m_Modifications:
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.x
value: 2.2000003
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.y
value: -1.0999999
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.z
value: 1.4000001
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.y
value: -1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showTheirDepends
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showIsoBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showScreenBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showSelfDepends
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Name
value: TileA (2)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_IsPrefabParent: 0
--- !u!4 &811987150 stripped
Transform:
m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_PrefabInternal: {fileID: 811987149}
--- !u!1001 &1132388993
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 522845242}
m_Modifications:
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.x
value: -2.1999993
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.y
value: -3.3000002
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.z
value: 1.1
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.x
value: -2
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.y
value: -1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showTheirDepends
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showIsoBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showScreenBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showSelfDepends
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Name
value: TileA (3)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_IsPrefabParent: 0
--- !u!4 &1132388994 stripped
Transform:
m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_PrefabInternal: {fileID: 1132388993}
--- !u!1001 &1378790440
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 522845242}
m_Modifications:
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.x
value: 0.00000047683716
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.y
value: -2.2
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.z
value: 1.3000001
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.x
value: -1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.y
value: -1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showTheirDepends
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showIsoBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showScreenBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showSelfDepends
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Name
value: TileA (1)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_IsPrefabParent: 0
--- !u!4 &1378790441 stripped
Transform:
m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_PrefabInternal: {fileID: 1378790440}
--- !u!1 &1396455878
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1396455884}
- component: {fileID: 1396455883}
- component: {fileID: 1396455882}
- component: {fileID: 1396455881}
- component: {fileID: 1396455880}
m_Layer: 0
m_Name: Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1396455880
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1396455878}
m_Enabled: 1
--- !u!92 &1396455881
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1396455878}
m_Enabled: 1
--- !u!124 &1396455882
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1396455878}
m_Enabled: 1
--- !u!20 &1396455883
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1396455878}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 10
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!4 &1396455884
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1396455878}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1680987095
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 522845242}
m_Modifications:
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.x
value: 0.00000047683716
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.y
value: -0.6
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.z
value: 1.2
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_RootOrder
value: 5
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.x
value: -1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.y
value: -1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.z
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showTheirDepends
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showIsoBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showScreenBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showSelfDepends
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Name
value: TileA (6)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_IsPrefabParent: 0
--- !u!4 &1680987096 stripped
Transform:
m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_PrefabInternal: {fileID: 1680987095}
--- !u!1001 &1887318778
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 522845242}
m_Modifications:
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.x
value: -2.1999998
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.y
value: -1.1000001
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalPosition.z
value: 1.5000001
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.x
value: -1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _position.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showTheirDepends
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showIsoBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showScreenBounds
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: _showSelfDepends
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
propertyPath: m_Name
value: TileA (4)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_IsPrefabParent: 0
--- !u!4 &1887318779 stripped
Transform:
m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2}
m_PrefabInternal: {fileID: 1887318778}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 345a2a95ba27849d9911b3d25b47eb5a
timeCreated: 1477147799
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,340 @@
using UnityEngine;
using IsoTools.Internal;
using System.Collections.Generic;
#if UNITY_5_5_OR_NEWER
using UnityEngine.Profiling;
#endif
namespace IsoTools {
public class IsoScreenSolver {
public Vector2 minXY = Vector2.zero;
public IsoAssocList<IsoObject> curVisibles = new IsoAssocList<IsoObject>();
public IsoAssocList<IsoObject> oldVisibles = new IsoAssocList<IsoObject>();
class Sector {
public IsoList<IsoObject> objects = new IsoList<IsoObject>();
public void Reset() {
objects.Clear();
}
}
IsoList<Sector> _sectors = new IsoList<Sector>();
float _sectorsSize = 0.0f;
Vector2 _sectorsMinNumPos = Vector2.zero;
Vector2 _sectorsMaxNumPos = Vector2.zero;
Vector2 _sectorsNumPosCount = Vector2.zero;
List<Renderer> _tmpRenderers = new List<Renderer>();
// ---------------------------------------------------------------------
//
// Callbacks
//
// ---------------------------------------------------------------------
public void OnAddInstance(IsoObject iso_object) {
}
public void OnRemoveInstance(IsoObject iso_object) {
oldVisibles.Remove(iso_object);
curVisibles.Remove(iso_object);
ClearIsoObjectDepends(iso_object);
}
public bool OnMarkDirtyInstance(IsoObject iso_object) {
if ( !iso_object.Internal.Dirty && curVisibles.Contains(iso_object) ) {
iso_object.Internal.Dirty = true;
return true;
}
return false;
}
// ---------------------------------------------------------------------
//
// Functions
//
// ---------------------------------------------------------------------
public void StepSortingAction(IsoWorld iso_world, IsoAssocList<IsoObject> instances) {
Profiler.BeginSample("ResolveNewVisibles");
ResolveNewVisibles(instances);
Profiler.EndSample();
Profiler.BeginSample("ResolveSectors");
ResolveSectors(iso_world);
Profiler.EndSample();
}
public void PostStepSortingAction() {
_tmpRenderers.Clear();
}
public void Clear() {
curVisibles.Clear();
oldVisibles.Clear();
_sectors.Clear();
}
// ---------------------------------------------------------------------
//
//
//
// ---------------------------------------------------------------------
void ResolveNewVisibles(IsoAssocList<IsoObject> instances) {
oldVisibles.Clear();
if ( instances.Count > 0 ) {
minXY.Set(float.MaxValue, float.MaxValue);
for ( int i = 0, e = instances.Count; i < e; ++i ) {
var iso_object = instances[i];
var object_pos = iso_object.position;
if ( minXY.x > object_pos.x ) {
minXY.x = object_pos.x;
}
if ( minXY.y > object_pos.y ) {
minXY.y = object_pos.y;
}
if ( !IsoUtils.Vec2Approximately(
iso_object.Internal.LastTrans,
iso_object.Internal.Transform.position) )
{
iso_object.FixIsoPosition();
}
if ( IsIsoObjectVisible(iso_object) ) {
iso_object.Internal.Placed = false;
oldVisibles.Add(iso_object);
}
}
} else {
minXY.Set(0.0f, 0.0f);
}
var temp_visibles = curVisibles;
curVisibles = oldVisibles;
oldVisibles = temp_visibles;
}
void ResolveSectors(IsoWorld iso_world) {
SetupSectorSize(iso_world);
SetupObjectsSectors();
SetupSectors();
}
// ---------------------------------------------------------------------
//
// ResolveSectors
//
// ---------------------------------------------------------------------
void SetupSectorSize(IsoWorld iso_world) {
_sectorsSize = 0.0f;
for ( int i = 0, e = curVisibles.Count; i < e; ++i ) {
var iso_internal = curVisibles[i].Internal;
_sectorsSize += IsoUtils.Vec2MaxF(iso_internal.ScreenBounds.size);
}
var min_sector_size_xy = iso_world.IsoToScreen(IsoUtils.vec3OneXY) - iso_world.IsoToScreen(Vector3.zero);
var min_sector_size = Mathf.Max(min_sector_size_xy.x, min_sector_size_xy.y);
_sectorsSize = curVisibles.Count > 0
? Mathf.Round(Mathf.Max(min_sector_size, _sectorsSize / curVisibles.Count))
: min_sector_size;
}
void SetupObjectsSectors() {
if ( curVisibles.Count > 0 ) {
_sectorsMinNumPos.Set(float.MaxValue, float.MaxValue);
_sectorsMaxNumPos.Set(float.MinValue, float.MinValue);
for ( int i = 0, e = curVisibles.Count; i < e; ++i ) {
var iso_internal = curVisibles[i].Internal;
// high performance tricks
var min_x = iso_internal.ScreenBounds.x.min / _sectorsSize;
var min_y = iso_internal.ScreenBounds.y.min / _sectorsSize;
var max_x = iso_internal.ScreenBounds.x.max / _sectorsSize;
var max_y = iso_internal.ScreenBounds.y.max / _sectorsSize;
iso_internal.MinSector.x = (int)(min_x >= 0.0f ? min_x : min_x - 1.0f);
iso_internal.MinSector.y = (int)(min_y >= 0.0f ? min_y : min_y - 1.0f);
iso_internal.MaxSector.x = (int)(max_x >= 0.0f ? max_x + 1.0f : max_x);
iso_internal.MaxSector.y = (int)(max_y >= 0.0f ? max_y + 1.0f : max_y);
if ( _sectorsMinNumPos.x > iso_internal.MinSector.x ) {
_sectorsMinNumPos.x = iso_internal.MinSector.x;
}
if ( _sectorsMinNumPos.y > iso_internal.MinSector.y ) {
_sectorsMinNumPos.y = iso_internal.MinSector.y;
}
if ( _sectorsMaxNumPos.x < iso_internal.MaxSector.x ) {
_sectorsMaxNumPos.x = iso_internal.MaxSector.x;
}
if ( _sectorsMaxNumPos.y < iso_internal.MaxSector.y ) {
_sectorsMaxNumPos.y = iso_internal.MaxSector.y;
}
}
} else {
_sectorsMinNumPos.Set(0.0f, 0.0f);
_sectorsMaxNumPos.Set(_sectorsSize, _sectorsSize);
}
_sectorsNumPosCount = _sectorsMaxNumPos - _sectorsMinNumPos;
}
void ResizeSectors(int count) {
if ( _sectors.Count < count ) {
if ( _sectors.Capacity < count ) {
_sectors.Capacity = count;
}
while ( _sectors.Count < _sectors.Capacity ) {
_sectors.Add(new Sector());
}
}
for ( int i = 0, e = _sectors.Count; i < e; ++i ) {
_sectors[i].Reset();
}
}
void TuneSectors() {
for ( int i = 0, e = curVisibles.Count; i < e; ++i ) {
var iso_object = curVisibles[i];
iso_object.Internal.MinSector -= _sectorsMinNumPos;
iso_object.Internal.MaxSector -= _sectorsMinNumPos;
var min = iso_object.Internal.MinSector;
var max = iso_object.Internal.MaxSector;
for ( var y = min.y; y < max.y; ++y ) {
for ( var x = min.x; x < max.x; ++x ) {
var sector = FindSector(x, y);
if ( sector != null ) {
sector.objects.Add(iso_object);
}
}}
}
}
void SetupSectors() {
ResizeSectors((int)(_sectorsNumPosCount.x * _sectorsNumPosCount.y));
TuneSectors();
}
Sector FindSector(float num_pos_x, float num_pos_y) {
if ( num_pos_x < 0 || num_pos_y < 0 ) {
return null;
}
if ( num_pos_x >= _sectorsNumPosCount.x || num_pos_y >= _sectorsNumPosCount.y ) {
return null;
}
var sector_index = (int)(num_pos_x + _sectorsNumPosCount.x * num_pos_y);
return _sectors[sector_index];
}
bool IsIsoObjectDepends(Vector3 a_min, Vector3 a_size, Vector3 b_min, Vector3 b_size) {
var a_max = a_min + a_size;
var b_max = b_min + b_size;
var a_yesno = a_max.x > b_min.x && a_max.y > b_min.y && b_max.z > a_min.z;
if ( a_yesno ) {
var b_yesno = b_max.x > a_min.x && b_max.y > a_min.y && a_max.z > b_min.z;
if ( b_yesno ) {
//var da_p = new Vector3(a_max.x - b_min.x, a_max.y - b_min.y, b_max.z - a_min.z);
//var db_p = new Vector3(b_max.x - a_min.x, b_max.y - a_min.y, a_max.z - b_min.z);
//var dp_p = a_size + b_size - IsoUtils.Vec3Abs(da_p - db_p);
var dA_x = a_max.x - b_min.x;
var dA_y = a_max.y - b_min.y;
var dA_z = b_max.z - a_min.z;
var dB_x = b_max.x - a_min.x;
var dB_y = b_max.y - a_min.y;
var dB_z = a_max.z - b_min.z;
var dP_x = a_size.x + b_size.x - Mathf.Abs(dA_x - dB_x);
var dP_y = a_size.y + b_size.y - Mathf.Abs(dA_y - dB_y);
var dP_z = a_size.z + b_size.z - Mathf.Abs(dA_z - dB_z);
if ( dP_x <= dP_y && dP_x <= dP_z ) {
return dA_x > dB_x;
} else if ( dP_y <= dP_x && dP_y <= dP_z ) {
return dA_y > dB_y;
} else {
return dA_z > dB_z;
}
}
}
return a_yesno;
}
bool IsIsoObjectDepends(IsoObject a, IsoObject b) {
return
a.Internal.ScreenBounds.Overlaps(b.Internal.ScreenBounds) &&
IsIsoObjectDepends(a.position, a.size, b.position, b.size);
}
void LookUpSectorDepends(float num_pos_x, float num_pos_y, IsoObject obj_a) {
var sec = FindSector(num_pos_x, num_pos_y);
if ( sec != null ) {
for ( int i = 0, e = sec.objects.Count; i < e; ++i ) {
var obj_b = sec.objects[i];
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);
}
}
}
}
void LookUpSectorRDepends(float num_pos_x, float num_pos_y, IsoObject obj_a) {
var sec = FindSector(num_pos_x, num_pos_y);
if ( sec != null ) {
for ( int i = 0, e = sec.objects.Count; i < e; ++i ) {
var obj_b = sec.objects[i];
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);
}
}
}
}
public void SetupIsoObjectDepends(IsoObject obj_a) {
ClearIsoObjectDepends(obj_a);
var min = obj_a.Internal.MinSector;
var max = obj_a.Internal.MaxSector;
for ( var y = min.y; y < max.y; ++y ) {
for ( var x = min.x; x < max.x; ++x ) {
LookUpSectorDepends(x, y, obj_a);
LookUpSectorRDepends(x, y, obj_a);
}}
}
public void ClearIsoObjectDepends(IsoObject iso_object) {
var their_depends = iso_object.Internal.TheirDepends;
for ( int i = 0, e = their_depends.Count; i < e; ++i ) {
var their_iso_object = their_depends[i];
if ( !their_iso_object.Internal.Dirty ) {
their_iso_object.Internal.SelfDepends.Remove(iso_object);
}
}
iso_object.Internal.SelfDepends.Clear();
iso_object.Internal.TheirDepends.Clear();
}
// ---------------------------------------------------------------------
//
// Private
//
// ---------------------------------------------------------------------
public bool IsIsoObjectVisible(IsoObject iso_object) {
var renderers = GetIsoObjectRenderers(iso_object);
for ( int i = 0, e = renderers.Count; i < e; ++i ) {
if ( renderers[i].isVisible ) {
return true;
}
}
return false;
}
List<Renderer> GetIsoObjectRenderers(IsoObject iso_object) {
if ( iso_object.cacheRenderers ) {
return iso_object.Internal.Renderers;
} else {
iso_object.GetComponentsInChildren<Renderer>(_tmpRenderers);
return _tmpRenderers;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 14792dabb03894fba98a812cdad03447
timeCreated: 1482336304
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,184 @@
using UnityEngine;
using IsoTools.Internal;
using System.Collections.Generic;
#if UNITY_5_5_OR_NEWER
using UnityEngine.Profiling;
#endif
namespace IsoTools {
public class IsoSortingSolver {
public float stepDepth = IsoWorld.DefStepDepth;
public float startDepth = IsoWorld.DefStartDepth;
List<Renderer> _tmpRenderers = new List<Renderer>();
// ---------------------------------------------------------------------
//
// Callbacks
//
// ---------------------------------------------------------------------
public void OnAddInstance(IsoObject iso_object) {
if ( iso_object.cacheRenderers ) {
iso_object.UpdateCachedRenderers();
}
}
public void OnRemoveInstance(IsoObject iso_object) {
if ( iso_object.cacheRenderers ) {
iso_object.ClearCachedRenderers();
}
}
public bool OnMarkDirtyInstance(IsoObject iso_object) {
return false;
}
// ---------------------------------------------------------------------
//
// Functions
//
// ---------------------------------------------------------------------
public bool StepSortingAction(IsoScreenSolver screen_solver){
Profiler.BeginSample("CalculateSectors");
var dirty = ResolveVisibles(screen_solver);
Profiler.EndSample();
if ( dirty ) {
Profiler.BeginSample("PlaceAllVisibles");
PlaceAllVisibles(screen_solver.curVisibles);
Profiler.EndSample();
}
return dirty;
}
public void PostStepSortingAction() {
_tmpRenderers.Clear();
}
// ---------------------------------------------------------------------
//
// ResolveVisibles
//
// ---------------------------------------------------------------------
bool ResolveVisibles(IsoScreenSolver screen_solver){
var old_visibles = screen_solver.oldVisibles;
var cur_visibles = screen_solver.curVisibles;
var mark_dirty = false;
for ( int i = 0, e = cur_visibles.Count; i < e; ++i ) {
var iso_object = cur_visibles[i];
if ( iso_object.Internal.Dirty || !old_visibles.Contains(iso_object) ) {
mark_dirty = true;
screen_solver.SetupIsoObjectDepends(iso_object);
iso_object.Internal.Dirty = false;
}
if ( UpdateIsoObjectBounds3d(iso_object) ) {
mark_dirty = true;
}
}
for ( int i = 0, e = old_visibles.Count; i < e; ++i ) {
var iso_object = old_visibles[i];
if ( !cur_visibles.Contains(iso_object) ) {
mark_dirty = true;
screen_solver.ClearIsoObjectDepends(iso_object);
}
}
_tmpRenderers.Clear();
return mark_dirty;
}
bool UpdateIsoObjectBounds3d(IsoObject iso_object) {
if ( iso_object.mode == IsoObject.Mode.Mode3d ) {
var minmax3d = IsoObjectMinMax3D(iso_object);
var offset3d = iso_object.Internal.Transform.position.z - minmax3d.center;
if ( iso_object.Internal.MinMax3d.Approximately(minmax3d) ||
!Mathf.Approximately(iso_object.Internal.Offset3d, offset3d) )
{
iso_object.Internal.MinMax3d = minmax3d;
iso_object.Internal.Offset3d = offset3d;
return true;
}
}
return false;
}
IsoMinMax IsoObjectMinMax3D(IsoObject iso_object) {
bool inited = false;
var result = IsoMinMax.zero;
var renderers = GetIsoObjectRenderers(iso_object);
for ( int i = 0, e = renderers.Count; i < e; ++i ) {
var bounds = renderers[i].bounds;
var extents = bounds.extents;
if ( extents.x > 0.0f || extents.y > 0.0f || extents.z > 0.0f ) {
var center = bounds.center.z;
var minbounds = center - extents.z;
var maxbounds = center + extents.z;
if ( inited ) {
if ( minbounds < result.min ) {
result.min = minbounds;
}
if ( maxbounds > result.max ) {
result.max = maxbounds;
}
} else {
inited = true;
result = new IsoMinMax(minbounds, maxbounds);
}
}
}
return inited ? result : IsoMinMax.zero;
}
List<Renderer> GetIsoObjectRenderers(IsoObject iso_object) {
if ( iso_object.cacheRenderers ) {
return iso_object.Internal.Renderers;
} else {
iso_object.GetComponentsInChildren<Renderer>(_tmpRenderers);
return _tmpRenderers;
}
}
// ---------------------------------------------------------------------
//
// PlaceAllVisibles
//
// ---------------------------------------------------------------------
void PlaceAllVisibles(IsoAssocList<IsoObject> cur_visibles) {
var depth = startDepth;
for ( int i = 0, e = cur_visibles.Count; i < e; ++i ) {
depth = RecursivePlaceIsoObject(cur_visibles[i], depth);
}
}
float RecursivePlaceIsoObject(IsoObject iso_object, float depth) {
if ( iso_object.Internal.Placed ) {
return depth;
}
iso_object.Internal.Placed = true;
var self_depends = iso_object.Internal.SelfDepends;
for ( int i = 0, e = self_depends.Count; i < e; ++i ) {
depth = RecursivePlaceIsoObject(self_depends[i], depth);
}
if ( iso_object.mode == IsoObject.Mode.Mode3d ) {
var zoffset = iso_object.Internal.Offset3d;
var extents = iso_object.Internal.MinMax3d.size;
PlaceIsoObject(iso_object, depth + extents * 0.5f + zoffset);
return depth + extents + stepDepth;
} else {
PlaceIsoObject(iso_object, depth);
return depth + stepDepth;
}
}
void PlaceIsoObject(IsoObject iso_object, float depth) {
var iso_internal = iso_object.Internal;
var old_position = iso_internal.LastTrans;
iso_internal.Transform.position =
IsoUtils.Vec3FromVec2(old_position, depth);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b88114313623149028393553036d6e0d
timeCreated: 1482336304
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -6,36 +6,14 @@ using System.Collections.Generic;
using UnityEditor;
#endif
#if UNITY_5_5_OR_NEWER
using UnityEngine.Profiling;
#endif
namespace IsoTools {
[ExecuteInEditMode, DisallowMultipleComponent]
public sealed class IsoWorld : IsoHolder<IsoWorld, IsoObject> {
bool _dirty = false;
Vector2 _minXY = Vector2.zero;
IsoAssocList<IsoObject> _visibles = new IsoAssocList<IsoObject>();
IsoAssocList<IsoObject> _oldVisibles = new IsoAssocList<IsoObject>();
bool _dirtyMat = true;
Matrix4x4 _isoMatrix = Matrix4x4.identity;
Matrix4x4 _isoRMatrix = Matrix4x4.identity;
List<Renderer> _tmpRenderers = new List<Renderer>();
class Sector {
public IsoList<IsoObject> objects = new IsoList<IsoObject>();
public void Reset() {
objects.Clear();
}
}
IsoList<Sector> _sectors = new IsoList<Sector>();
float _sectorsSize = 0.0f;
Vector2 _sectorsMinNumPos = Vector2.zero;
Vector2 _sectorsMaxNumPos = Vector2.zero;
Vector2 _sectorsNumPosCount = Vector2.zero;
Matrix4x4 _isoMatrix = Matrix4x4.identity;
Matrix4x4 _isoRMatrix = Matrix4x4.identity;
IsoScreenSolver _screenSolver = new IsoScreenSolver();
IsoSortingSolver _sortingSolver = new IsoSortingSolver();
// ---------------------------------------------------------------------
//
@@ -155,10 +133,6 @@ namespace IsoTools {
// ---------------------------------------------------------------------
public Vector2 IsoToScreen(Vector3 iso_pnt) {
if ( _dirtyMat ) {
UpdateIsoMatrix();
_dirtyMat = false;
}
var screen_pos = _isoMatrix.MultiplyPoint(iso_pnt);
return new Vector2(
screen_pos.x,
@@ -166,11 +140,8 @@ namespace IsoTools {
}
public Vector3 ScreenToIso(Vector2 pos) {
if ( _dirtyMat ) {
UpdateIsoMatrix();
_dirtyMat = false;
}
return _isoRMatrix.MultiplyPoint(new Vector3(pos.x, pos.y, 0.0f));
return _isoRMatrix.MultiplyPoint(
new Vector3(pos.x, pos.y, 0.0f));
}
public Vector3 ScreenToIso(Vector2 pos, float iso_z) {
@@ -188,7 +159,8 @@ namespace IsoTools {
public Ray RayFromIsoCameraToIsoPoint(Vector3 iso_pnt) {
var screen_pnt = IsoToScreen(iso_pnt);
var min_screen_pnt = IsoToScreen(_minXY - Vector2.one);
var min_xy = _screenSolver.minXY;
var min_screen_pnt = IsoToScreen(min_xy - Vector2.one);
var max_screen_dist = screen_pnt.y - min_screen_pnt.y;
var screen_down_pnt = new Vector2(screen_pnt.x, screen_pnt.y - max_screen_dist);
@@ -348,18 +320,11 @@ namespace IsoTools {
//
// ---------------------------------------------------------------------
public void MarkDirty() {
if ( !_dirty ) {
_dirty = true;
#if UNITY_EDITOR
EditorUtility.SetDirty(this);
#endif
}
}
public void MarkDirty(IsoObject iso_object) {
if ( !iso_object.Internal.Dirty && _visibles.Contains(iso_object) ) {
iso_object.Internal.Dirty = true;
if ( _screenSolver.OnMarkDirtyInstance(iso_object) ) {
MarkDirty();
}
if ( _sortingSolver.OnMarkDirtyInstance(iso_object) ) {
MarkDirty();
}
}
@@ -370,8 +335,10 @@ namespace IsoTools {
//
// ---------------------------------------------------------------------
void MarkDirtyIsoMatrix() {
_dirtyMat = true;
void MarkDirty() {
#if UNITY_EDITOR
EditorUtility.SetDirty(this);
#endif
}
void UpdateIsoMatrix() {
@@ -384,385 +351,32 @@ namespace IsoTools {
_isoRMatrix = _isoMatrix.inverse;
}
void FixAllTransforms() {
void FixInstanceTransforms() {
var instances = GetInstances();
for ( int i = 0, e = instances.Count; i < e; ++i ) {
instances[i].FixTransform();
}
}
void UpdateSolverProperties() {
_sortingSolver.stepDepth = stepDepth;
_sortingSolver.startDepth = startDepth;
}
void ChangeSortingProperty() {
MarkDirty();
MarkDirtyIsoMatrix();
FixAllTransforms();
UpdateIsoMatrix();
FixInstanceTransforms();
UpdateSolverProperties();
}
bool UpdateIsoObjectBounds3d(IsoObject iso_object) {
if ( iso_object.mode == IsoObject.Mode.Mode3d ) {
var minmax3d = IsoObjectMinMax3D(iso_object);
var offset3d = iso_object.Internal.Transform.position.z - minmax3d.center;
if ( iso_object.Internal.MinMax3d.Approximately(minmax3d) ||
!Mathf.Approximately(iso_object.Internal.Offset3d, offset3d) )
{
iso_object.Internal.MinMax3d = minmax3d;
iso_object.Internal.Offset3d = offset3d;
return true;
}
void StepSortingProcess() {
_screenSolver.StepSortingAction(this, GetInstances());
if ( _sortingSolver.StepSortingAction(_screenSolver) ) {
MarkDirty();
}
return false;
}
IsoMinMax IsoObjectMinMax3D(IsoObject iso_object) {
bool inited = false;
var result = IsoMinMax.zero;
var renderers = GetIsoObjectRenderers(iso_object);
for ( int i = 0, e = renderers.Count; i < e; ++i ) {
var bounds = renderers[i].bounds;
var extents = bounds.extents;
if ( extents.x > 0.0f || extents.y > 0.0f || extents.z > 0.0f ) {
var center = bounds.center.z;
var minbounds = center - extents.z;
var maxbounds = center + extents.z;
if ( inited ) {
if ( minbounds < result.min ) {
result.min = minbounds;
}
if ( maxbounds > result.max ) {
result.max = maxbounds;
}
} else {
inited = true;
result = new IsoMinMax(minbounds, maxbounds);
}
}
}
return inited ? result : IsoMinMax.zero;
}
List<Renderer> GetIsoObjectRenderers(IsoObject iso_object) {
if ( iso_object.cacheRenderers ) {
return iso_object.Internal.Renderers;
} else {
iso_object.GetComponentsInChildren<Renderer>(_tmpRenderers);
return _tmpRenderers;
}
}
bool IsIsoObjectVisible(IsoObject iso_object) {
var renderers = GetIsoObjectRenderers(iso_object);
for ( int i = 0, e = renderers.Count; i < e; ++i ) {
if ( renderers[i].isVisible ) {
return true;
}
}
return false;
}
bool IsIsoObjectDepends(Vector3 a_min, Vector3 a_size, Vector3 b_min, Vector3 b_size) {
var a_max = a_min + a_size;
var b_max = b_min + b_size;
var a_yesno = a_max.x > b_min.x && a_max.y > b_min.y && b_max.z > a_min.z;
if ( a_yesno ) {
var b_yesno = b_max.x > a_min.x && b_max.y > a_min.y && a_max.z > b_min.z;
if ( b_yesno ) {
//var da_p = new Vector3(a_max.x - b_min.x, a_max.y - b_min.y, b_max.z - a_min.z);
//var db_p = new Vector3(b_max.x - a_min.x, b_max.y - a_min.y, a_max.z - b_min.z);
//var dp_p = a_size + b_size - IsoUtils.Vec3Abs(da_p - db_p);
var dA_x = a_max.x - b_min.x;
var dA_y = a_max.y - b_min.y;
var dA_z = b_max.z - a_min.z;
var dB_x = b_max.x - a_min.x;
var dB_y = b_max.y - a_min.y;
var dB_z = a_max.z - b_min.z;
var dP_x = a_size.x + b_size.x - Mathf.Abs(dA_x - dB_x);
var dP_y = a_size.y + b_size.y - Mathf.Abs(dA_y - dB_y);
var dP_z = a_size.z + b_size.z - Mathf.Abs(dA_z - dB_z);
if ( dP_x <= dP_y && dP_x <= dP_z ) {
return dA_x > dB_x;
} else if ( dP_y <= dP_x && dP_y <= dP_z ) {
return dA_y > dB_y;
} else {
return dA_z > dB_z;
}
}
}
return a_yesno;
}
bool IsIsoObjectDepends(IsoObject a, IsoObject b) {
return
a.Internal.ScreenBounds.Overlaps(b.Internal.ScreenBounds) &&
IsIsoObjectDepends(a.position, a.size, b.position, b.size);
}
Sector FindSector(float num_pos_x, float num_pos_y) {
if ( num_pos_x < 0 || num_pos_y < 0 ) {
return null;
}
if ( num_pos_x >= _sectorsNumPosCount.x || num_pos_y >= _sectorsNumPosCount.y ) {
return null;
}
var sector_index = (int)(num_pos_x + _sectorsNumPosCount.x * num_pos_y);
return _sectors[sector_index];
}
void LookUpSectorDepends(float num_pos_x, float num_pos_y, IsoObject obj_a) {
var sec = FindSector(num_pos_x, num_pos_y);
if ( sec != null ) {
for ( int i = 0, e = sec.objects.Count; i < e; ++i ) {
var obj_b = sec.objects[i];
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);
}
}
}
}
void LookUpSectorRDepends(float num_pos_x, float num_pos_y, IsoObject obj_a) {
var sec = FindSector(num_pos_x, num_pos_y);
if ( sec != null ) {
for ( int i = 0, e = sec.objects.Count; i < e; ++i ) {
var obj_b = sec.objects[i];
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);
}
}
}
}
void SetupSectorSize() {
_sectorsSize = 0.0f;
for ( int i = 0, e = _visibles.Count; i < e; ++i ) {
var iso_internal = _visibles[i].Internal;
_sectorsSize += IsoUtils.Vec2MaxF(iso_internal.ScreenBounds.size);
}
var min_sector_size_xy = IsoToScreen(IsoUtils.vec3OneXY) - IsoToScreen(Vector3.zero);
var min_sector_size = Mathf.Max(min_sector_size_xy.x, min_sector_size_xy.y);
_sectorsSize = _visibles.Count > 0
? Mathf.Round(Mathf.Max(min_sector_size, _sectorsSize / _visibles.Count))
: min_sector_size;
}
void SetupObjectsSectors() {
if ( _visibles.Count > 0 ) {
_sectorsMinNumPos.Set(float.MaxValue, float.MaxValue);
_sectorsMaxNumPos.Set(float.MinValue, float.MinValue);
for ( int i = 0, e = _visibles.Count; i < e; ++i ) {
var iso_internal = _visibles[i].Internal;
// high performance tricks
var min_x = iso_internal.ScreenBounds.x.min / _sectorsSize;
var min_y = iso_internal.ScreenBounds.y.min / _sectorsSize;
var max_x = iso_internal.ScreenBounds.x.max / _sectorsSize;
var max_y = iso_internal.ScreenBounds.y.max / _sectorsSize;
iso_internal.MinSector.x = (int)(min_x >= 0.0f ? min_x : min_x - 1.0f);
iso_internal.MinSector.y = (int)(min_y >= 0.0f ? min_y : min_y - 1.0f);
iso_internal.MaxSector.x = (int)(max_x >= 0.0f ? max_x + 1.0f : max_x);
iso_internal.MaxSector.y = (int)(max_y >= 0.0f ? max_y + 1.0f : max_y);
if ( _sectorsMinNumPos.x > iso_internal.MinSector.x ) {
_sectorsMinNumPos.x = iso_internal.MinSector.x;
}
if ( _sectorsMinNumPos.y > iso_internal.MinSector.y ) {
_sectorsMinNumPos.y = iso_internal.MinSector.y;
}
if ( _sectorsMaxNumPos.x < iso_internal.MaxSector.x ) {
_sectorsMaxNumPos.x = iso_internal.MaxSector.x;
}
if ( _sectorsMaxNumPos.y < iso_internal.MaxSector.y ) {
_sectorsMaxNumPos.y = iso_internal.MaxSector.y;
}
}
} else {
_sectorsMinNumPos.Set(0.0f, 0.0f);
_sectorsMaxNumPos.Set(_sectorsSize, _sectorsSize);
}
_sectorsNumPosCount = _sectorsMaxNumPos - _sectorsMinNumPos;
}
void ResizeSectors(int count) {
if ( _sectors.Count < count ) {
if ( _sectors.Capacity < count ) {
_sectors.Capacity = count;
}
while ( _sectors.Count < _sectors.Capacity ) {
_sectors.Add(new Sector());
}
}
for ( int i = 0, e = _sectors.Count; i < e; ++i ) {
_sectors[i].Reset();
}
}
void TuneSectors() {
for ( int i = 0, e = _visibles.Count; i < e; ++i ) {
var iso_object = _visibles[i];
iso_object.Internal.MinSector -= _sectorsMinNumPos;
iso_object.Internal.MaxSector -= _sectorsMinNumPos;
var min = iso_object.Internal.MinSector;
var max = iso_object.Internal.MaxSector;
for ( var y = min.y; y < max.y; ++y ) {
for ( var x = min.x; x < max.x; ++x ) {
var sector = FindSector(x, y);
if ( sector != null ) {
sector.objects.Add(iso_object);
}
}}
}
}
void SetupSectors() {
ResizeSectors((int)(_sectorsNumPosCount.x * _sectorsNumPosCount.y));
TuneSectors();
}
void StepSort() {
Profiler.BeginSample("UpdateVisibles");
UpdateVisibles();
Profiler.EndSample();
if ( _dirty ) {
Profiler.BeginSample("PlaceAllVisibles");
PlaceAllVisibles();
Profiler.EndSample();
_dirty = false;
}
PostStepSortActions();
}
void PostStepSortActions() {
_tmpRenderers.Clear();
}
void UpdateVisibles() {
Profiler.BeginSample("CalculateNewVisibles");
CalculateNewVisibles();
Profiler.EndSample();
Profiler.BeginSample("CalculateSectors");
SetupSectorSize();
SetupObjectsSectors();
SetupSectors();
Profiler.EndSample();
Profiler.BeginSample("ResolveVisibles");
ResolveVisibles();
Profiler.EndSample();
}
void CalculateNewVisibles() {
_oldVisibles.Clear();
var instances = GetInstances();
if ( instances.Count > 0 ) {
_minXY.Set(float.MaxValue, float.MaxValue);
for ( int i = 0, e = instances.Count; i < e; ++i ) {
var iso_object = instances[i];
var iso_object_pos = iso_object.position;
if ( _minXY.x > iso_object_pos.x ) {
_minXY.x = iso_object_pos.x;
}
if ( _minXY.y > iso_object_pos.y ) {
_minXY.y = iso_object_pos.y;
}
if ( !IsoUtils.Vec2Approximately(
iso_object.Internal.LastTrans,
iso_object.Internal.Transform.position) )
{
iso_object.FixIsoPosition();
}
if ( IsIsoObjectVisible(iso_object) ) {
iso_object.Internal.Placed = false;
_oldVisibles.Add(iso_object);
}
}
} else {
_minXY.Set(0.0f, 0.0f);
}
var old_visibles = _visibles;
_visibles = _oldVisibles;
_oldVisibles = old_visibles;
}
void ResolveVisibles() {
for ( int i = 0, e = _visibles.Count; i < e; ++i ) {
var iso_object = _visibles[i];
if ( iso_object.Internal.Dirty || !_oldVisibles.Contains(iso_object) ) {
MarkDirty();
SetupIsoObjectDepends(iso_object);
iso_object.Internal.Dirty = false;
}
if ( UpdateIsoObjectBounds3d(iso_object) ) {
MarkDirty();
}
}
for ( int i = 0, e = _oldVisibles.Count; i < e; ++i ) {
var iso_object = _oldVisibles[i];
if ( !_visibles.Contains(iso_object) ) {
MarkDirty();
ClearIsoObjectDepends(iso_object);
}
}
}
void ClearIsoObjectDepends(IsoObject iso_object) {
var their_depends = iso_object.Internal.TheirDepends;
for ( int i = 0, e = their_depends.Count; i < e; ++i ) {
var their_depend = their_depends[i];
if ( !their_depend.Internal.Dirty ) {
their_depend.Internal.SelfDepends.Remove(iso_object);
}
}
iso_object.Internal.SelfDepends.Clear();
iso_object.Internal.TheirDepends.Clear();
}
void SetupIsoObjectDepends(IsoObject obj_a) {
ClearIsoObjectDepends(obj_a);
var min = obj_a.Internal.MinSector;
var max = obj_a.Internal.MaxSector;
for ( var y = min.y; y < max.y; ++y ) {
for ( var x = min.x; x < max.x; ++x ) {
LookUpSectorDepends(x, y, obj_a);
LookUpSectorRDepends(x, y, obj_a);
}}
}
void PlaceAllVisibles() {
var depth = startDepth;
for ( int i = 0, e = _visibles.Count; i < e; ++i ) {
depth = RecursivePlaceIsoObject(_visibles[i], depth);
}
}
float RecursivePlaceIsoObject(IsoObject iso_object, float depth) {
if ( iso_object.Internal.Placed ) {
return depth;
}
iso_object.Internal.Placed = true;
var self_depends = iso_object.Internal.SelfDepends;
for ( int i = 0, e = self_depends.Count; i < e; ++i ) {
depth = RecursivePlaceIsoObject(self_depends[i], depth);
}
if ( iso_object.mode == IsoObject.Mode.Mode3d ) {
var zoffset = iso_object.Internal.Offset3d;
var extents = iso_object.Internal.MinMax3d.size;
PlaceIsoObject(iso_object, depth + extents * 0.5f + zoffset);
return depth + extents + stepDepth;
} else {
PlaceIsoObject(iso_object, depth);
return depth + stepDepth;
}
}
void PlaceIsoObject(IsoObject iso_object, float depth) {
var iso_internal = iso_object.Internal;
iso_internal.Transform.position =
IsoUtils.Vec3FromVec2(iso_internal.LastTrans, depth);
_screenSolver.PostStepSortingAction();
_sortingSolver.PostStepSortingAction();
}
// ---------------------------------------------------------------------
@@ -773,43 +387,33 @@ namespace IsoTools {
void Start() {
ChangeSortingProperty();
StepSort();
StepSortingProcess();
}
void LateUpdate() {
StepSort();
StepSortingProcess();
}
protected override void OnEnable() {
base.OnEnable();
_visibles.Clear();
_oldVisibles.Clear();
_sectors.Clear();
MarkDirty();
_screenSolver.Clear();
}
protected override void OnDisable() {
base.OnDisable();
_visibles.Clear();
_oldVisibles.Clear();
_sectors.Clear();
_screenSolver.Clear();
}
protected override void OnAddInstanceToHolder(IsoObject instance) {
base.OnAddInstanceToHolder(instance);
if ( instance.cacheRenderers ) {
instance.UpdateCachedRenderers();
}
_screenSolver.OnAddInstance(instance);
_sortingSolver.OnAddInstance(instance);
}
protected override void OnRemoveInstanceFromHolder(IsoObject instance) {
base.OnRemoveInstanceFromHolder(instance);
if ( instance.cacheRenderers ) {
instance.ClearCachedRenderers();
}
ClearIsoObjectDepends(instance);
_visibles.Remove(instance);
_oldVisibles.Remove(instance);
_screenSolver.OnRemoveInstance(instance);
_sortingSolver.OnRemoveInstance(instance);
}
#if UNITY_EDITOR
@@ -833,7 +437,7 @@ namespace IsoTools {
void OnRenderObject() {
if ( Camera.current && Camera.current.name == "SceneCamera" ) {
StepSort();
StepSortingProcess();
}
}