Skip to content

Commit

Permalink
Merge branch 'Cammin:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
leohilbert authored Jul 29, 2024
2 parents e756fc9 + 85b7fa1 commit c072867
Show file tree
Hide file tree
Showing 78 changed files with 38,419 additions and 199,422 deletions.
94 changes: 94 additions & 0 deletions Assets/LDtkUnity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,97 @@
# [6.3.0](https://github.com/Cammin/LDtkToUnity/compare/6.2.3...6.3.0) (2024-07-29)


### Features

* Added some API to get LDtkFields point transform components ([aaf9971](https://github.com/Cammin/LDtkToUnity/commit/aaf997116bfd596572832ee97852e41303d1a804))

## [6.2.3](https://github.com/Cammin/LDtkToUnity/compare/6.2.2...6.2.3) (2024-07-28)


### Bug Fixes

* Fixed a problem in the tileset clear pixel inspection, where some valid sprites would not generate if the texture dimensions were not fully divisible by the GridSize. Additionally fixed an improper use of a padding check ([a47328f](https://github.com/Cammin/LDtkToUnity/commit/a47328f6e04aba48e4f18d84b6605ca0281d4b46))

## [6.2.2](https://github.com/Cammin/LDtkToUnity/compare/6.2.1...6.2.2) (2024-07-22)


### Bug Fixes

* The tile building process will now shift cells if a given tile's offset reached or exceeds 1 in any direction brought on by a rule building multiple tiles. This fixed some render order problems ([4346541](https://github.com/Cammin/LDtkToUnity/commit/43465411888de66894edac5eca72d56e25e4f975))

## [6.2.1](https://github.com/Cammin/LDtkToUnity/compare/6.2.0...6.2.1) (2024-07-16)


### Performance Improvements

* Slight optimize to the tile building, where the flip bits is calculated in the job execution instead of the job construction ([266c53c](https://github.com/Cammin/LDtkToUnity/commit/266c53cea8f58ab7d16e94fe804669b9e3f2cd68))

# [6.2.0](https://github.com/Cammin/LDtkToUnity/compare/6.1.11...6.2.0) (2024-06-10)


### Features

* Linux support ([d28f5e4](https://github.com/Cammin/LDtkToUnity/commit/d28f5e4a7cdf0bae00c7533a77edd083a4f5c475))

## [6.1.11](https://github.com/Cammin/LDtkToUnity/compare/6.1.10...6.1.11) (2024-06-10)


### Bug Fixes

* Fixed two occurrances of deserialization failure if some values in the json were null types ([e1d29a5](https://github.com/Cammin/LDtkToUnity/commit/e1d29a53c0e3394d1e7501410e03b7a8e6020a73))

## [6.1.10](https://github.com/Cammin/LDtkToUnity/compare/6.1.9...6.1.10) (2024-05-31)


### Bug Fixes

* Fixed issue where layer components were being populated with incorrect layer data ([f51d393](https://github.com/Cammin/LDtkToUnity/commit/f51d393892efcf63606eb506299bf4c29a45e333))

## [6.1.9](https://github.com/Cammin/LDtkToUnity/compare/6.1.8...6.1.9) (2024-05-26)


### Bug Fixes

* Remove unnessesary disposal of a NativeArray to fix a tileset import exception in older unity versions ([51976b7](https://github.com/Cammin/LDtkToUnity/commit/51976b7c55086f8bc0d7d9c3995a7b8145a07019))

## [6.1.8](https://github.com/Cammin/LDtkToUnity/compare/6.1.7...6.1.8) (2024-05-26)


### Bug Fixes

* Compile error on versions 2020.1 and below (again) ([47dddfb](https://github.com/Cammin/LDtkToUnity/commit/47dddfbf2dc2c926af69bd2f15aee5d924166be1))

## [6.1.7](https://github.com/Cammin/LDtkToUnity/compare/6.1.6...6.1.7) (2024-05-26)


### Bug Fixes

* Compile error on versions 2020.1 and below ([98a585c](https://github.com/Cammin/LDtkToUnity/commit/98a585cf69bcea4b70be7d96cb94a36ada64ea30))

## [6.1.6](https://github.com/Cammin/LDtkToUnity/compare/6.1.5...6.1.6) (2024-05-26)


### Bug Fixes

* Reversed the tile stacking order to fix tiles being layered improperly ([7b366ce](https://github.com/Cammin/LDtkToUnity/commit/7b366ce1ea1b57fa43a5c4dcd510347b4081ea77))


### Performance Improvements

* Empty tile sprites are no longer generated, resulting in faster import speeds, and more optimal atlas packing ([1dd82f3](https://github.com/Cammin/LDtkToUnity/commit/1dd82f32a66227d10f4628979fd37cf870874078))

## [6.1.5](https://github.com/Cammin/LDtkToUnity/compare/6.1.4...6.1.5) (2024-05-26)


### Bug Fixes

* Reverted setting sprites as HideInHierarchy so that they can be added to SpriteAtlas properly ([4825f28](https://github.com/Cammin/LDtkToUnity/commit/4825f28998a838ab9e52af9ff29466782f93f186))


### Performance Improvements

* Small list preallocation ([9566734](https://github.com/Cammin/LDtkToUnity/commit/9566734817429b3ed400fcd749ed5836130f1517))

## [6.1.4](https://github.com/Cammin/LDtkToUnity/compare/6.1.3...6.1.4) (2024-05-21)


Expand Down
1 change: 1 addition & 0 deletions Assets/LDtkUnity/Editor/Builders/LDtkBuilderLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ private LDtkComponentLayer BuildLayerInstance(LayerInstance layer)
LDtkComponentEntity[] entities = null;
float layerScale = 1;

_layerComponent = null;
_layerIntGrid = null;
_layerTiles = null;

Expand Down
20 changes: 13 additions & 7 deletions Assets/LDtkUnity/Editor/Builders/LDtkBuilderTileset.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Unity.Jobs;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Tilemaps;

Expand Down Expand Up @@ -105,18 +104,25 @@ public void BuildTileset(TileInstance[] tiles)

LDtkProfiler.BeginSample("CacheNeededTilesArtifacts");
TileBase[] tileAssets = new TileBase[tilesLength];
List<LDtkTilesetTile> artifactTiles = artifacts._tiles;
int artifactCount = artifactTiles.Count;
LDtkTilesetTile[] artifactTiles = artifacts._tiles;
int artifactCount = artifactTiles.Length;
for (int i = 0; i < tilesLength; i++)
{
int t = _tiles[i].T;
int? t = _tiles[i].T;

//it's possible that a t value is null in the json, unfortunately
if (t == null)
{
continue;
}

//if the tile is ever higher than the number of artifacts,
//it means the tileset definition was reshaped and some rogue tiles were left behind in the level,
//awaiting to be recovered upon bringing back the tileset def size.
if (t < artifactCount)
int tValue = t.Value;
if (tValue < artifactCount)
{
tileAssets[i] = artifactTiles[t];
tileAssets[i] = artifactTiles[tValue];
}
}
LDtkProfiler.EndSample();
Expand Down
26 changes: 19 additions & 7 deletions Assets/LDtkUnity/Editor/Builders/TileBuildingJob.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Unity.Collections;
using System;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;

Expand All @@ -11,8 +12,7 @@ public struct InputData
public int CoordId;
public int PxX;
public int PxY;
public bool FlipX;
public bool FlipY;
public int Flip;
}

public struct OutputData
Expand Down Expand Up @@ -49,8 +49,7 @@ public TileBuildingJob(TileInstance[] tiles, LayerInstance layer, float layerSca
CoordId = isAutoLayer ? tile.D[1] : tile.D[0],
PxX = tile.Px[0],
PxY = tile.Px[1],
FlipX = tile.FlipX,
FlipY = tile.FlipY,
Flip = tile.F,
};
}
}
Expand All @@ -69,9 +68,22 @@ public void Execute(int i)
offset.x = pxOffsetX / (float)LayerGridSize;
offset.y = -pxOffsetY / (float)LayerGridSize;

//Rules can have multiple tiles built (like a 2x2 of art), but they all occupy the same coordId despite being located full cell(s) away!
//this results in offsets that can exceed 1 or -1, which at that point, should occupy the next cell over.
//not only is it easier to track down the tile in the editor, but it renders in a better z order with other tiles in that other cell.
int cellShiftX = offset.x > 0 ? (int)Math.Floor(offset.x) : (int)Math.Ceiling(offset.x);
int cellShiftY = offset.y > 0 ? (int)Math.Floor(offset.y) : (int)Math.Ceiling(offset.y);
cX += cellShiftX;
cY -= cellShiftY;
offset.x -= cellShiftX;
offset.y -= cellShiftY;

bool flipX = (input.Flip & 1) == 1;
bool flipY = (input.Flip & 2) == 2;

Vector3 scale = new Vector3(ScaleFactor, ScaleFactor, 1);
scale.x *= input.FlipX ? -1 : 1;
scale.y *= input.FlipY ? -1 : 1;
scale.x *= flipX ? -1 : 1;
scale.y *= flipY ? -1 : 1;

//convert y into unity tilemap coordinate space
cY = -cY + LayerCHei - 1;
Expand Down
3 changes: 2 additions & 1 deletion Assets/LDtkUnity/Editor/Builders/TilemapTilesBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public TilemapTilesBuilder(Tilemap map, int capacity)
_depth = new Dictionary<Vector3Int, int>(10);
}

/// <param name="cell">Z is always 0</param>
public int GetNextCellZ(Vector3Int cell)
{
if (!_depth.ContainsKey(cell))
Expand All @@ -56,7 +57,7 @@ public int GetNextCellZ(Vector3Int cell)
return 0;
}

_depth[cell] -= 1;
_depth[cell] += 1;
return _depth[cell];
}

Expand Down
Loading

0 comments on commit c072867

Please sign in to comment.