T2DTileObject.Visible = false Bug Fix
by Zach Barrier · in Torque X 2D · 03/12/2010 (6:17 am) · 0 replies
Problem:
When a T2DTileObject's Visible Property is set to false, it is still rendered anyway.
Solution:
In the T2DTileLayer.cs file under Torque2D.T2D folder locate the following method:
public override void Render(SceneRenderState srs)
Find the section of the method that collects all the tiles that are to be rendered:
// collect all the tiles we're actually going to render and put them in the right batch
bool doCheckRotation = _rotation != 0.0f;
for (int j = r.Top; j <= r.Height; j++)
{
for (int i = r.Left; i <= r.Width; i++)
{
T2DTileObject tile = GetTileByGridCoords(i, j);
if (tile == null) // ***** BUG IS RIGHT HERE!!! *****
continue;
Change the line marked as the bug to the following
if (tile == null || !tile.Visible)
continue;
Now the T2DTileObject.Visible Property should work. As far as the T2DTileObject.Visibility Property is concerned, it doesn't look like it works. By looking at the code, I think all tiles are rendered with the Visibility value associated with the T2DTileLayer assuming you have made the _isColorBlended = true fix in the SimpleMaterial class as previously listed by someone else.
When a T2DTileObject's Visible Property is set to false, it is still rendered anyway.
Solution:
In the T2DTileLayer.cs file under Torque2D.T2D folder locate the following method:
public override void Render(SceneRenderState srs)
Find the section of the method that collects all the tiles that are to be rendered:
// collect all the tiles we're actually going to render and put them in the right batch
bool doCheckRotation = _rotation != 0.0f;
for (int j = r.Top; j <= r.Height; j++)
{
for (int i = r.Left; i <= r.Width; i++)
{
T2DTileObject tile = GetTileByGridCoords(i, j);
if (tile == null) // ***** BUG IS RIGHT HERE!!! *****
continue;
Change the line marked as the bug to the following
if (tile == null || !tile.Visible)
continue;
Now the T2DTileObject.Visible Property should work. As far as the T2DTileObject.Visibility Property is concerned, it doesn't look like it works. By looking at the code, I think all tiles are rendered with the Visibility value associated with the T2DTileLayer assuming you have made the _isColorBlended = true fix in the SimpleMaterial class as previously listed by someone else.