mix 2d and 3d done

This commit is contained in:
2015-08-16 20:58:37 +06:00
parent 3a0d4e3b2f
commit b52c52870f
12 changed files with 1610 additions and 762 deletions

View File

@@ -42,7 +42,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 124842}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -.966036558, y: 1.8369118, z: 14.0350876}
m_LocalPosition: {x: -23.7793617, y: 45.2162933, z: 14.0350876}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 491986}
@@ -77,12 +77,9 @@ MonoBehaviour:
Internal:
Dirty: 0
Visited: 0
Bounds:
m_Center: {x: -.966036558, y: 2.16191173, z: 14.0350876}
m_Extent: {x: .324999958, y: .324999988, z: 0}
Bounds3d:
m_Center: {x: -.966036558, y: 2.14391184, z: 14.0350876}
m_Extent: {x: .235000014, y: .234999955, z: .100000381}
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
Offset3d: 0
MinSector: {x: 0, y: 0, z: 0}
MaxSector: {x: 0, y: 0, z: 0}

View File

@@ -83,7 +83,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 199876}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: .649999976, y: 2.27499986, z: 52.7777863}
m_LocalPosition: {x: 16, y: 56, z: 52.7777863}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 492676}
@@ -132,13 +132,10 @@ MonoBehaviour:
Internal:
Dirty: 0
Visited: 0
Bounds:
m_Center: {x: .649999976, y: 3.25, z: 52.7777863}
m_Extent: {x: .649999976, y: .975000024, z: 0}
Bounds3d:
m_Center: {x: .649999976, y: 3.64999986, z: 52.5777855}
m_Extent: {x: .495000005, y: .299999952, z: .0999984741}
Offset3d: .200000763
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
Offset3d: 0
MinSector: {x: 0, y: 0, z: 0}
MaxSector: {x: 0, y: 0, z: 0}
_isAlignment: 1

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 129934}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: .344499975, z: 0}
m_LocalPosition: {x: 0, y: 8.47999954, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 403766}
@@ -74,12 +74,9 @@ MonoBehaviour:
Internal:
Dirty: 0
Visited: 0
Bounds:
m_Center: {x: .302249998, y: .658124983, z: 0}
m_Extent: {x: .347749978, y: .313624978, z: 0}
Bounds3d:
m_Center: {x: .305000007, y: .654500008, z: 0}
m_Extent: {x: .354999959, y: .319999993, z: .100000001}
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
Offset3d: 0
MinSector: {x: 0, y: 0, z: 0}
MaxSector: {x: 0, y: 0, z: 0}

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110900}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.17386711, y: .057843782, z: 0}
m_LocalPosition: {x: -28.8951912, y: 1.42384696, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 449742}
@@ -74,12 +74,9 @@ MonoBehaviour:
Internal:
Dirty: 0
Visited: 0
Bounds:
m_Center: {x: -1.47611713, y: .371468782, z: 0}
m_Extent: {x: .347750008, y: .313624978, z: 0}
Bounds3d:
m_Center: {x: -1.47886705, y: .367843807, z: 0}
m_Extent: {x: .355000019, y: .314999998, z: .100000001}
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
Offset3d: 0
MinSector: {x: 0, y: 0, z: 0}
MaxSector: {x: 0, y: 0, z: 0}

View File

@@ -43,7 +43,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 121016}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.59553313, y: 1.54941559, z: 30.3571491}
m_LocalPosition: {x: -39.274662, y: 38.1394615, z: 30.3571491}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 442418}
@@ -78,12 +78,9 @@ MonoBehaviour:
Internal:
Dirty: 0
Visited: 0
Bounds:
m_Center: {x: -1.59553313, y: 1.84191561, z: 30.3571491}
m_Extent: {x: .194999993, y: .292500019, z: 0}
Bounds3d:
m_Center: {x: -1.59553313, y: 1.84641552, z: 30.3571491}
m_Extent: {x: .164999962, y: .230000019, z: .0499992371}
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
Offset3d: 0
MinSector: {x: 0, y: 0, z: 0}
MaxSector: {x: 0, y: 0, z: 0}

View File

@@ -74,12 +74,9 @@ MonoBehaviour:
Internal:
Dirty: 0
Visited: 0
Bounds:
m_Center: {x: 0, y: .497249961, z: 0}
m_Extent: {x: .649999976, y: .497249961, z: 0}
Bounds3d:
m_Center: {x: 0, y: .5, z: 0}
m_Extent: {x: .660000026, y: .504999995, z: .100000001}
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
Offset3d: 0
MinSector: {x: 0, y: 0, z: 0}
MaxSector: {x: 0, y: 0, z: 0}

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 128698}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.12775278, y: 2.6389122, z: 43.75}
m_LocalPosition: {x: 52.3754539, y: 64.95784, z: 43.75}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 461496}
@@ -74,12 +74,9 @@ MonoBehaviour:
Internal:
Dirty: 0
Visited: 0
Bounds:
m_Center: {x: 2.12775278, y: 2.89891219, z: 43.75}
m_Extent: {x: .195000112, y: .25999999, z: 0}
Bounds3d:
m_Center: {x: 2.12775278, y: 2.90991211, z: 43.75}
m_Extent: {x: .160000026, y: .224999905, z: .0999984741}
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
Offset3d: 0
MinSector: {x: 0, y: 0, z: 0}
MaxSector: {x: 0, y: 0, z: 0}

View File

@@ -46,12 +46,9 @@ MonoBehaviour:
Internal:
Dirty: 0
Visited: 0
Bounds:
m_Center: {x: 0, y: .324999988, z: 0}
m_Extent: {x: .649999976, y: .324999988, z: 0}
Bounds3d:
m_Center: {x: 0, y: 8.5, z: 0}
m_Extent: {x: 17, y: 8.5, z: .100000001}
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
Offset3d: 0
MinSector: {x: 0, y: 0, z: 0}
MaxSector: {x: 0, y: 0, z: 0}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -361,30 +361,6 @@ namespace IsoTools {
: obj.AddComponent<T>();
}
static Bounds IsoObject3DBounds(GameObject obj, bool exist, Bounds bounds) {
var renderer = obj.GetComponent<Renderer>();
if ( renderer ) {
if ( exist ) {
bounds.Encapsulate(renderer.bounds);
} else {
exist = true;
bounds = renderer.bounds;
}
}
var obj_transform = obj.transform;
for ( var i = 0; i < obj_transform.childCount; ++i ) {
var child_obj = obj_transform.GetChild(i).gameObject;
bounds = IsoObject3DBounds(child_obj, exist, bounds);
}
return bounds;
}
public static Bounds IsoObject3DBounds(IsoObject iso_object) {
return iso_object
? IsoObject3DBounds(iso_object.gameObject, false, new Bounds())
: new Bounds();
}
public static IsoCollider IsoConvertCollider(Collider collider) {
var fake_collider = collider ? collider.GetComponent<IsoFakeCollider>() : null;
return fake_collider ? fake_collider.isoCollider : null;

View File

@@ -9,10 +9,11 @@ namespace IsoTools {
[ExecuteInEditMode, DisallowMultipleComponent]
public class IsoWorld : MonoBehaviour {
bool _dirty = false;
HashSet<IsoObject> _objects = new HashSet<IsoObject>();
HashSet<IsoObject> _visibles = new HashSet<IsoObject>();
HashSet<IsoObject> _oldVisibles = new HashSet<IsoObject>();
bool _dirty = false;
HashSet<IsoObject> _objects = new HashSet<IsoObject>();
HashSet<IsoObject> _visibles = new HashSet<IsoObject>();
HashSet<IsoObject> _oldVisibles = new HashSet<IsoObject>();
List<Renderer> _tmpRenderers = new List<Renderer>();
class Sector {
public List<IsoObject> objects = new List<IsoObject>();
@@ -132,7 +133,7 @@ namespace IsoTools {
bool CheckIsoObjectChangeBounds3d(IsoObject iso_object) {
if ( iso_object.mode == IsoObject.Mode.Mode3d ) {
var bounds3d = IsoUtils.IsoObject3DBounds(iso_object);
var bounds3d = IsoObject3DBounds(iso_object);
var offset3d = iso_object.transform.position.z - bounds3d.center.z;
if ( iso_object.Internal.Bounds3d.extents != bounds3d.extents ||
!Mathf.Approximately(iso_object.Internal.Offset3d, offset3d) )
@@ -144,25 +145,28 @@ namespace IsoTools {
}
return false;
}
bool IsGameObjectVisible(GameObject obj) {
var renderer = obj.GetComponent<Renderer>();
if ( renderer && renderer.isVisible ) {
return true;
Bounds IsoObject3DBounds(IsoObject iso_object) {
var bounds = new Bounds();
iso_object.GetComponentsInChildren<Renderer>(_tmpRenderers);
if ( _tmpRenderers.Count > 0 ) {
bounds = _tmpRenderers[0].bounds;
for ( var i = 1; i < _tmpRenderers.Count; ++i ) {
bounds.Encapsulate(_tmpRenderers[i].bounds);
}
}
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 bounds;
}
bool IsIsoObjectVisible(IsoObject iso_object) {
iso_object.GetComponentsInChildren<Renderer>(_tmpRenderers);
for ( var i = 0; i < _tmpRenderers.Count; ++i ) {
if ( _tmpRenderers[i].isVisible ) {
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) {
var a_max = a_min + a_size;