Hello Guest

Author Topic: TileMap Problem: aabb.IsValid()  (Read 4167 times)

adangly

  • Newbie
  • *
  • Posts: 2
    • View Profile
TileMap Problem: aabb.IsValid()
« on: March 17, 2014, 03:35:30 am »
   
    I just got a random "aabb.IsValid()" when enter my game's level,  and finally I found it's caused by tilemap's chunk;

    It seemed that the mesh of chunk is wrong, because if I replace the mesh with another(in run time), the error gone. But the default mesh of chunk is always 0 verts, 0 tris, that makes me confused.
   
    Can anyone tell me why, and how to solve it? :)

    And  my tk2d version is 2.2.3.
« Last Edit: March 17, 2014, 03:44:04 am by adangly »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: TileMap Problem: aabb.IsValid()
« Reply #1 on: March 17, 2014, 11:38:32 am »
Is this all the meshes, or just the empty chunks? It can possibly leave empty chunk mesh present on occasion. It shouldn't cause any issues though. You can delete the render data object and Commit to have it reconstruct everything - that may help.

adangly

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: TileMap Problem: aabb.IsValid()
« Reply #2 on: March 17, 2014, 02:02:13 pm »
Thanks for reply.

The problem is only happened on chunk, not every mesh; and I think it's not a data problem, because the error not happened every time, just randomly.

And I try this:
change  tk2dTileMapMeshBuilder.cs  line 145
    var meshFilter = chunk.gameObject.GetComponent<MeshFilter>();
    meshFilter.sharedMesh = chunk.mesh;
to
   if (Application.isPlaying == false)
   {
         var meshFilter = chunk.gameObject.GetComponent<MeshFilter>();
         meshFilter.sharedMesh = chunk.mesh;
   }

Then everything works fines, no "aabb.IsValid()" anymore.

I guess it may caused by mesh.RecalculateBounds(), maybe sometimes it sucked :-\