fix false warnings

This commit is contained in:
2017-01-01 02:45:59 +07:00
parent 7be90fa61a
commit badbb0a53c
2 changed files with 15 additions and 1 deletions

View File

@@ -405,10 +405,23 @@ namespace IsoTools.Internal {
return a == b;
}
public static bool Vec2Approximately(Vector2 a, Vector2 b, float precision) {
return
Mathf.Abs(a.x - b.x) < precision &&
Mathf.Abs(a.y - b.y) < precision;
}
public static bool Vec3Approximately(Vector3 a, Vector3 b) {
return a == b;
}
public static bool Vec3Approximately(Vector3 a, Vector3 b, float precision) {
return
Mathf.Abs(a.x - b.x) < precision &&
Mathf.Abs(a.y - b.y) < precision &&
Mathf.Abs(a.z - b.z) < precision;
}
// ---------------------------------------------------------------------
//
// Beautifiers

View File

@@ -116,9 +116,10 @@ namespace IsoTools.Internal {
void CheckChangedTransform(IsoObject iso_object) {
var iso_world = iso_object.isoWorld;
if ( iso_world ) {
var precision = Mathf.Min(iso_world.tileSize, iso_world.tileHeight) * 0.01f;
var needed_position = iso_world.IsoToScreen(iso_object.position);
var current_position = iso_object.transform.position;
if ( !IsoUtils.Vec2Approximately(needed_position, current_position) ) {
if ( !IsoUtils.Vec2Approximately(needed_position, current_position, precision) ) {
Debug.LogWarning(
"Don't change 'IsoObject.transform.position' manually!\n" +
"Use 'IsoObject.position' instead.",