mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 19:53:48 +00:00
Make terrain texture settings global, add dialog to painter
This commit is contained in:
parent
d3996aec84
commit
db496fa0c4
10 changed files with 483 additions and 317 deletions
|
|
@ -319,7 +319,7 @@ void GBitmap::allocateBitmap(const U32 in_width, const U32 in_height, const bool
|
|||
U32 currWidth = in_width;
|
||||
U32 currHeight = in_height;
|
||||
|
||||
do
|
||||
while (currWidth != 1 || currHeight != 1)
|
||||
{
|
||||
mMipLevelOffsets[mNumMipLevels] = mMipLevelOffsets[mNumMipLevels - 1] +
|
||||
(currWidth * currHeight * mBytesPerPixel);
|
||||
|
|
@ -330,7 +330,7 @@ void GBitmap::allocateBitmap(const U32 in_width, const U32 in_height, const bool
|
|||
|
||||
mNumMipLevels++;
|
||||
allocPixels += currWidth * currHeight * mBytesPerPixel;
|
||||
} while (currWidth != 1 || currHeight != 1);
|
||||
}
|
||||
|
||||
U32 expectedMips = mFloor(mLog2(mMax(in_width, in_height))) + 1;
|
||||
AssertFatal(mNumMipLevels == expectedMips, "GBitmap::allocateBitmap: mipmap count wrong");
|
||||
|
|
|
|||
|
|
@ -197,14 +197,6 @@ TerrainBlock::TerrainBlock()
|
|||
mLayerTexDirty( false ),
|
||||
mBaseTexSize( 1024 ),
|
||||
mBaseTexFormat( TerrainBlock::DDS ),
|
||||
mDetailTexSize(0),
|
||||
mDetailTexFormat(GFXFormat_COUNT),
|
||||
mMacroTexSize(0),
|
||||
mMacroTexFormat(GFXFormat_COUNT),
|
||||
mNormalTexSize(0),
|
||||
mNormalTexFormat(GFXFormat_COUNT),
|
||||
mOrmTexSize(0),
|
||||
mOrmTexFormat(GFXFormat_COUNT),
|
||||
mCell( NULL ),
|
||||
mBaseMaterial( NULL ),
|
||||
mDefaultMatInst( NULL ),
|
||||
|
|
@ -355,142 +347,6 @@ bool TerrainBlock::_setLightMapSize( void *obj, const char *index, const char *d
|
|||
return false;
|
||||
}
|
||||
|
||||
bool TerrainBlock::_setDetailTexSize(void* obj, const char* index, const char* data)
|
||||
{
|
||||
TerrainBlock* terrain = static_cast<TerrainBlock*>(obj);
|
||||
|
||||
S32 size;
|
||||
castConsoleTypeFromString(size, data);
|
||||
|
||||
if (terrain->mDetailTexSize != size)
|
||||
{
|
||||
terrain->mDetailTexSize = size;
|
||||
terrain->_updateMaterials();
|
||||
terrain->setMaskBits(MaterialMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TerrainBlock::_setDetailTexFormat(void* obj, const char* index, const char* data)
|
||||
{
|
||||
TerrainBlock* terrain = static_cast<TerrainBlock*>(obj);
|
||||
|
||||
GFXFormat format;
|
||||
castConsoleTypeFromString(format, data);
|
||||
|
||||
if (terrain->mDetailTexFormat != format)
|
||||
{
|
||||
terrain->mDetailTexFormat = format;
|
||||
terrain->_updateMaterials();
|
||||
terrain->setMaskBits(MaterialMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TerrainBlock::_setMacroTexSize(void* obj, const char* index, const char* data)
|
||||
{
|
||||
TerrainBlock* terrain = static_cast<TerrainBlock*>(obj);
|
||||
|
||||
S32 size;
|
||||
castConsoleTypeFromString(size, data);
|
||||
|
||||
if (terrain->mMacroTexSize != size)
|
||||
{
|
||||
terrain->mMacroTexSize = size;
|
||||
terrain->_updateMaterials();
|
||||
terrain->setMaskBits(MaterialMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TerrainBlock::_setMacroTexFormat(void* obj, const char* index, const char* data)
|
||||
{
|
||||
TerrainBlock* terrain = static_cast<TerrainBlock*>(obj);
|
||||
|
||||
GFXFormat format;
|
||||
castConsoleTypeFromString(format, data);
|
||||
|
||||
if (terrain->mMacroTexFormat != format)
|
||||
{
|
||||
terrain->mMacroTexFormat = format;
|
||||
terrain->_updateMaterials();
|
||||
terrain->setMaskBits(MaterialMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TerrainBlock::_setNormalTexSize(void* obj, const char* index, const char* data)
|
||||
{
|
||||
TerrainBlock* terrain = static_cast<TerrainBlock*>(obj);
|
||||
|
||||
S32 size;
|
||||
castConsoleTypeFromString(size, data);
|
||||
|
||||
if (terrain->mNormalTexSize != size)
|
||||
{
|
||||
terrain->mNormalTexSize = size;
|
||||
terrain->_updateMaterials();
|
||||
terrain->setMaskBits(MaterialMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TerrainBlock::_setNormalTexFormat(void* obj, const char* index, const char* data)
|
||||
{
|
||||
TerrainBlock* terrain = static_cast<TerrainBlock*>(obj);
|
||||
|
||||
GFXFormat format;
|
||||
castConsoleTypeFromString(format, data);
|
||||
|
||||
if (terrain->mNormalTexFormat != format)
|
||||
{
|
||||
terrain->mNormalTexFormat = format;
|
||||
terrain->_updateMaterials();
|
||||
terrain->setMaskBits(MaterialMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TerrainBlock::_setOrmTexSize(void* obj, const char* index, const char* data)
|
||||
{
|
||||
TerrainBlock* terrain = static_cast<TerrainBlock*>(obj);
|
||||
|
||||
S32 size;
|
||||
castConsoleTypeFromString(size, data);
|
||||
|
||||
if (terrain->mOrmTexSize != size)
|
||||
{
|
||||
terrain->mOrmTexSize = size;
|
||||
terrain->_updateMaterials();
|
||||
terrain->setMaskBits(MaterialMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TerrainBlock::_setOrmTexFormat(void* obj, const char* index, const char* data)
|
||||
{
|
||||
TerrainBlock* terrain = static_cast<TerrainBlock*>(obj);
|
||||
|
||||
GFXFormat format;
|
||||
castConsoleTypeFromString(format, data);
|
||||
|
||||
if (terrain->mOrmTexFormat != format)
|
||||
{
|
||||
terrain->mOrmTexFormat = format;
|
||||
terrain->_updateMaterials();
|
||||
terrain->setMaskBits(MaterialMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TerrainBlock::setFile( const FileName &terrFileName )
|
||||
{
|
||||
if ( mTerrainAsset && mTerrainAsset->getTerrainFilePath() == terrFileName )
|
||||
|
|
@ -1440,38 +1296,6 @@ void TerrainBlock::initPersistFields()
|
|||
&TerrainBlock::_setLightMapSize, &defaultProtectedGetFn,
|
||||
"Light map dimensions in pixels." );
|
||||
|
||||
addProtectedField("detailTexSize", TypeS32, Offset(mDetailTexSize, TerrainBlock),
|
||||
&TerrainBlock::_setDetailTexSize, &defaultProtectedGetFn,
|
||||
"");
|
||||
|
||||
addProtectedField("detailTexFormat", TypeGFXFormat, Offset(mDetailTexFormat, TerrainBlock),
|
||||
&TerrainBlock::_setDetailTexFormat, &defaultProtectedGetFn,
|
||||
"");
|
||||
|
||||
addProtectedField("macroTexSize", TypeS32, Offset(mMacroTexSize, TerrainBlock),
|
||||
&TerrainBlock::_setMacroTexSize, &defaultProtectedGetFn,
|
||||
"");
|
||||
|
||||
addProtectedField("macroTexFormat", TypeGFXFormat, Offset(mMacroTexFormat, TerrainBlock),
|
||||
&TerrainBlock::_setMacroTexFormat, &defaultProtectedGetFn,
|
||||
"");
|
||||
|
||||
addProtectedField("normalTexSize", TypeS32, Offset(mNormalTexSize, TerrainBlock),
|
||||
&TerrainBlock::_setNormalTexSize, &defaultProtectedGetFn,
|
||||
"");
|
||||
|
||||
addProtectedField("normalTexFormat", TypeGFXFormat, Offset(mNormalTexFormat, TerrainBlock),
|
||||
&TerrainBlock::_setNormalTexFormat, &defaultProtectedGetFn,
|
||||
"");
|
||||
|
||||
addProtectedField("ormTexSize", TypeS32, Offset(mOrmTexSize, TerrainBlock),
|
||||
&TerrainBlock::_setOrmTexSize, &defaultProtectedGetFn,
|
||||
"");
|
||||
|
||||
addProtectedField("ormTexFormat", TypeGFXFormat, Offset(mOrmTexFormat, TerrainBlock),
|
||||
&TerrainBlock::_setOrmTexFormat, &defaultProtectedGetFn,
|
||||
"");
|
||||
|
||||
addField( "screenError", TypeS32, Offset( mScreenError, TerrainBlock ), "Not yet implemented." );
|
||||
|
||||
addField( "updateBasetex", TypeBool, Offset( mUpdateBasetex, TerrainBlock ), "Whether or not to update the Base Texture" );
|
||||
|
|
@ -1524,15 +1348,6 @@ U32 TerrainBlock::packUpdate(NetConnection* con, U32 mask, BitStream *stream)
|
|||
{
|
||||
stream->write( mBaseTexSize );
|
||||
stream->write( mLightMapSize );
|
||||
|
||||
stream->write( mDetailTexSize );
|
||||
stream->write( static_cast<S32>(mDetailTexFormat) );
|
||||
stream->write( mMacroTexSize );
|
||||
stream->write( static_cast<S32>(mMacroTexFormat) );
|
||||
stream->write( mNormalTexSize );
|
||||
stream->write( static_cast<S32>(mNormalTexFormat) );
|
||||
stream->write( mOrmTexSize );
|
||||
stream->write( static_cast<S32>(mOrmTexFormat) );
|
||||
}
|
||||
|
||||
stream->writeFlag( mask & HeightMapChangeMask );
|
||||
|
|
@ -1595,73 +1410,6 @@ void TerrainBlock::unpackUpdate(NetConnection* con, BitStream *stream)
|
|||
clearLightMap();
|
||||
}
|
||||
}
|
||||
|
||||
bool updateMaterials = false;
|
||||
|
||||
U32 detailTexSize;
|
||||
stream->read(&detailTexSize);
|
||||
if (mDetailTexSize != detailTexSize)
|
||||
{
|
||||
mDetailTexSize = detailTexSize;
|
||||
updateMaterials = true;
|
||||
}
|
||||
S32 detailTexFormat;
|
||||
stream->read(&detailTexFormat);
|
||||
if (mDetailTexFormat != detailTexFormat)
|
||||
{
|
||||
mDetailTexFormat = static_cast<GFXFormat>(detailTexFormat);
|
||||
updateMaterials = true;
|
||||
}
|
||||
|
||||
U32 macroTexSize;
|
||||
stream->read(¯oTexSize);
|
||||
if (mMacroTexSize != macroTexSize)
|
||||
{
|
||||
mMacroTexSize = macroTexSize;
|
||||
updateMaterials = true;
|
||||
}
|
||||
S32 macroTexFormat;
|
||||
stream->read(¯oTexFormat);
|
||||
if (mMacroTexFormat != macroTexFormat)
|
||||
{
|
||||
mMacroTexFormat = static_cast<GFXFormat>(macroTexFormat);
|
||||
updateMaterials = true;
|
||||
}
|
||||
|
||||
U32 normalTexSize;
|
||||
stream->read(&normalTexSize);
|
||||
if (mNormalTexSize != normalTexSize)
|
||||
{
|
||||
mNormalTexSize = normalTexSize;
|
||||
updateMaterials = true;
|
||||
}
|
||||
S32 normalTexFormat;
|
||||
stream->read(&normalTexFormat);
|
||||
if (mNormalTexFormat != normalTexFormat)
|
||||
{
|
||||
mNormalTexFormat = static_cast<GFXFormat>(normalTexFormat);
|
||||
updateMaterials = true;
|
||||
}
|
||||
|
||||
U32 ormTexSize;
|
||||
stream->read(&ormTexSize);
|
||||
if (mOrmTexSize != ormTexSize)
|
||||
{
|
||||
mOrmTexSize = ormTexSize;
|
||||
updateMaterials = true;
|
||||
}
|
||||
S32 ormTexFormat;
|
||||
stream->read(&ormTexFormat);
|
||||
if (mOrmTexFormat != ormTexFormat)
|
||||
{
|
||||
mOrmTexFormat = static_cast<GFXFormat>(ormTexFormat);
|
||||
updateMaterials = true;
|
||||
}
|
||||
|
||||
if (updateMaterials && isProperlyAdded())
|
||||
{
|
||||
_updateMaterials();
|
||||
}
|
||||
}
|
||||
|
||||
if ( stream->readFlag() && isProperlyAdded() ) // HeightMapChangeMask
|
||||
|
|
|
|||
|
|
@ -174,15 +174,6 @@ protected:
|
|||
|
||||
BaseTexFormat mBaseTexFormat;
|
||||
|
||||
U32 mDetailTexSize;
|
||||
GFXFormat mDetailTexFormat;
|
||||
U32 mMacroTexSize;
|
||||
GFXFormat mMacroTexFormat;
|
||||
U32 mNormalTexSize;
|
||||
GFXFormat mNormalTexFormat;
|
||||
U32 mOrmTexSize;
|
||||
GFXFormat mOrmTexFormat;
|
||||
|
||||
///
|
||||
TerrCell *mCell;
|
||||
|
||||
|
|
@ -267,14 +258,6 @@ protected:
|
|||
static bool _setSquareSize( void *obj, const char *index, const char *data );
|
||||
static bool _setBaseTexSize(void *obj, const char *index, const char *data);
|
||||
static bool _setBaseTexFormat(void *obj, const char *index, const char *data);
|
||||
static bool _setDetailTexSize(void *obj, const char *index, const char *data);
|
||||
static bool _setDetailTexFormat(void *obj, const char *index, const char *data);
|
||||
static bool _setMacroTexSize(void *obj, const char *index, const char *data);
|
||||
static bool _setMacroTexFormat(void *obj, const char *index, const char *data);
|
||||
static bool _setNormalTexSize(void *obj, const char *index, const char *data);
|
||||
static bool _setNormalTexFormat(void *obj, const char *index, const char *data);
|
||||
static bool _setOrmTexSize(void *obj, const char *index, const char *data);
|
||||
static bool _setOrmTexFormat(void *obj, const char *index, const char *data);
|
||||
static bool _setLightMapSize( void *obj, const char *index, const char *data );
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -173,41 +173,52 @@ void TerrainBlock::_updateMaterials()
|
|||
#endif
|
||||
|
||||
// Format has been explicitly set
|
||||
if (mDetailTexSize != 0)
|
||||
const U32 detailTexSize = Con::getIntVariable("Terrain::DetailTextureSize");
|
||||
const GFXFormat detailTexFormat = static_cast<GFXFormat>(Con::getIntVariable("Terrain::DetailTextureFormat"));
|
||||
if (detailTexSize != 0)
|
||||
{
|
||||
GFXFormat format = GFXFormatR8G8B8A8;
|
||||
if (mDetailTexFormat < GFXFormat_COUNT)
|
||||
if (detailTexFormat < GFXFormat_COUNT)
|
||||
{
|
||||
format = mDetailTexFormat;
|
||||
format = detailTexFormat;
|
||||
}
|
||||
mDetailTextureArray->set(mDetailTexSize, mDetailTexSize, detailTexArraySize, format);
|
||||
mDetailTextureArray->set(detailTexSize, detailTexSize, detailTexArraySize, format);
|
||||
}
|
||||
if (mMacroTexSize != 0)
|
||||
|
||||
const U32 macroTexSize = Con::getIntVariable("Terrain::MacroTextureSize");
|
||||
const GFXFormat macroTexFormat = static_cast<GFXFormat>(Con::getIntVariable("Terrain::MacroTextureFormat"));
|
||||
if (macroTexSize != 0)
|
||||
{
|
||||
GFXFormat format = GFXFormatR8G8B8A8;
|
||||
if (mMacroTexFormat < GFXFormat_COUNT)
|
||||
if (macroTexFormat < GFXFormat_COUNT)
|
||||
{
|
||||
format = mMacroTexFormat;
|
||||
format = macroTexFormat;
|
||||
}
|
||||
mMacroTextureArray->set(mMacroTexSize, mMacroTexSize, macroTexArraySize, format);
|
||||
mMacroTextureArray->set(macroTexSize, macroTexSize, macroTexArraySize, format);
|
||||
}
|
||||
if (mNormalTexSize != 0)
|
||||
|
||||
const U32 normalTexSize = Con::getIntVariable("Terrain::NormalTextureSize");
|
||||
const GFXFormat normalTexFormat = static_cast<GFXFormat>(Con::getIntVariable("Terrain::NormalTextureFormat"));
|
||||
if (normalTexSize != 0)
|
||||
{
|
||||
GFXFormat format = GFXFormatR8G8B8A8;
|
||||
if (mNormalTexFormat < GFXFormat_COUNT)
|
||||
if (normalTexFormat < GFXFormat_COUNT)
|
||||
{
|
||||
format = mNormalTexFormat;
|
||||
format = normalTexFormat;
|
||||
}
|
||||
mNormalTextureArray->set(mNormalTexSize, mNormalTexSize, normalTexArraySize, format);
|
||||
mNormalTextureArray->set(normalTexSize, normalTexSize, normalTexArraySize, format);
|
||||
}
|
||||
if (mOrmTexSize != 0)
|
||||
|
||||
const U32 ormTexSize = Con::getIntVariable("Terrain::OrmTextureSize");
|
||||
const GFXFormat ormTexFormat = static_cast<GFXFormat>(Con::getIntVariable("Terrain::OrmTextureFormat"));
|
||||
if (ormTexSize != 0)
|
||||
{
|
||||
GFXFormat format = GFXFormatR8G8B8A8;
|
||||
if (mOrmTexFormat < GFXFormat_COUNT)
|
||||
if (ormTexFormat < GFXFormat_COUNT)
|
||||
{
|
||||
format = mOrmTexFormat;
|
||||
format = ormTexFormat;
|
||||
}
|
||||
mOrmTextureArray->set(mOrmTexSize, mOrmTexSize, ormTexArraySize, format);
|
||||
mOrmTextureArray->set(ormTexSize, ormTexSize, ormTexArraySize, format);
|
||||
}
|
||||
|
||||
if (!mDetailTextureArray->fromTextureArray(detailTexArray, detailTexArraySize))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue