WaterBlock change
by Brian Hook · in Torque Game Engine · 03/01/2003 (10:35 am) · 1 replies
While rifling through the code looking for dependencies on the implementation of the terrain engine, it looks like there is a hardcoded dependency between the waterblock fluid system and the underlying terrain engine.
Specifically, the fluid class takes a U16 * of heightmap data in SetTerrainData(), then makes hardcoded assumptions about the dimensionality of the heightmap data (256x256) in RebuildMasks():
for( X = 0; X < m_SquaresInX+1; X++ )
{
i = (((m_SquareY0+Y) & 255) << 8) + ((m_SquareX0+X) & 255);
*pG = (u8)(FluidLevel > m_pTerrain[i]);
pG++;
}
I think this can be changed by temporarily introducing a dependency on TerrainBlock and terrData.h and accepting a TerrainBlock * instead of a U16 *. This then lets the above code become:
*pG = (u8)(FluidLevel > m_pTerrainBlock->getHeight( m_SquareX0 + X, m_SquareY0 + Y ) );
In addition, m_SquareX0 and m_SquareY0 and a couple other hardcoded size assumptions would have to be updated, but once that was done this would (theoretically) allow waterblocks to co-exist with terrains that have had their parameters adjusted, and possibly start the process towards generalizing the terrain engine.
Comments?
Specifically, the fluid class takes a U16 * of heightmap data in SetTerrainData(), then makes hardcoded assumptions about the dimensionality of the heightmap data (256x256) in RebuildMasks():
for( X = 0; X < m_SquaresInX+1; X++ )
{
i = (((m_SquareY0+Y) & 255) << 8) + ((m_SquareX0+X) & 255);
*pG = (u8)(FluidLevel > m_pTerrain[i]);
pG++;
}
I think this can be changed by temporarily introducing a dependency on TerrainBlock and terrData.h and accepting a TerrainBlock * instead of a U16 *. This then lets the above code become:
*pG = (u8)(FluidLevel > m_pTerrainBlock->getHeight( m_SquareX0 + X, m_SquareY0 + Y ) );
In addition, m_SquareX0 and m_SquareY0 and a couple other hardcoded size assumptions would have to be updated, but once that was done this would (theoretically) allow waterblocks to co-exist with terrains that have had their parameters adjusted, and possibly start the process towards generalizing the terrain engine.
Comments?
Associate Kyle Carter