forked from teamnwah/openmw-tes3coop
Add more land table columns
This commit is contained in:
parent
30ba1d4c25
commit
7cc95a11a4
5 changed files with 278 additions and 23 deletions
|
@ -1,28 +1,226 @@
|
||||||
#include "columnimp.hpp"
|
#include "columnimp.hpp"
|
||||||
|
|
||||||
CSMWorld::BodyPartRaceColumn::BodyPartRaceColumn(const MeshTypeColumn<ESM::BodyPart> *meshType)
|
namespace CSMWorld
|
||||||
: mMeshType(meshType)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QVariant CSMWorld::BodyPartRaceColumn::get(const Record<ESM::BodyPart> &record) const
|
|
||||||
{
|
{
|
||||||
if (mMeshType != NULL && mMeshType->get(record) == ESM::BodyPart::MT_Skin)
|
/* LandMapLodColumn */
|
||||||
|
LandMapLodColumn::LandMapLodColumn()
|
||||||
|
: Column<Land>(Columns::ColumnId_LandMapLodIndex, ColumnBase::Display_String, 0)
|
||||||
{
|
{
|
||||||
return QString::fromUtf8(record.get().mRace.c_str());
|
|
||||||
}
|
}
|
||||||
return QVariant(QVariant::UserType);
|
|
||||||
}
|
QVariant LandMapLodColumn::get(const Record<Land>& record) const
|
||||||
|
{
|
||||||
void CSMWorld::BodyPartRaceColumn::set(Record<ESM::BodyPart> &record, const QVariant &data)
|
// Note: original data is signed
|
||||||
{
|
const char* rawData = reinterpret_cast<const char*>(&record.get().mWnam[0]);
|
||||||
ESM::BodyPart record2 = record.get();
|
return QByteArray(rawData, Land::LAND_GLOBAL_MAP_LOD_SIZE);
|
||||||
|
}
|
||||||
record2.mRace = data.toString().toUtf8().constData();
|
|
||||||
|
void LandMapLodColumn::set(Record<Land>& record, const QVariant& data)
|
||||||
record.setModified(record2);
|
{
|
||||||
}
|
Land copy = record.get();
|
||||||
|
QByteArray array = data.toByteArray();
|
||||||
bool CSMWorld::BodyPartRaceColumn::isEditable() const
|
const signed char* rawData = reinterpret_cast<const signed char*>(array.data());
|
||||||
{
|
|
||||||
return true;
|
assert (array.count() == Land::LAND_GLOBAL_MAP_LOD_SIZE);
|
||||||
|
|
||||||
|
for (int i = 0; i < array.count(); ++i)
|
||||||
|
{
|
||||||
|
copy.mWnam[i] = rawData[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
record.setModified(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LandMapLodColumn::isEditable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* LandNormalsColumn */
|
||||||
|
LandNormalsColumn::LandNormalsColumn()
|
||||||
|
: Column<Land>(Columns::ColumnId_LandNormalsIndex, ColumnBase::Display_String, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant LandNormalsColumn::get(const Record<Land>& record) const
|
||||||
|
{
|
||||||
|
const Land::LandData* landData = record.get().getLandData();
|
||||||
|
assert(landData);
|
||||||
|
|
||||||
|
// Note: original data is signed
|
||||||
|
const char* rawData = reinterpret_cast<const char*>(&landData->mNormals[0]);
|
||||||
|
return QByteArray(rawData, Land::LAND_NUM_VERTS * 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandNormalsColumn::set(Record<Land>& record, const QVariant& data)
|
||||||
|
{
|
||||||
|
Land copy = record.get();
|
||||||
|
Land::LandData* landData = copy.getLandData();
|
||||||
|
assert (landData);
|
||||||
|
|
||||||
|
QByteArray array = data.toByteArray();
|
||||||
|
const signed char* rawData = reinterpret_cast<const signed char*>(array.data());
|
||||||
|
|
||||||
|
assert (array.count() == Land::LAND_NUM_VERTS * 3);
|
||||||
|
|
||||||
|
for (int i = 0; i < array.count(); ++i)
|
||||||
|
{
|
||||||
|
landData->mNormals[i] = rawData[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
record.setModified(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LandNormalsColumn::isEditable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* LandHeightsColumn */
|
||||||
|
LandHeightsColumn::LandHeightsColumn()
|
||||||
|
: Column<Land>(Columns::ColumnId_LandHeightsIndex, ColumnBase::Display_String, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant LandHeightsColumn::get(const Record<Land>& record) const
|
||||||
|
{
|
||||||
|
const Land::LandData* landData = record.get().getLandData();
|
||||||
|
assert(landData);
|
||||||
|
|
||||||
|
// Note: original data is float
|
||||||
|
const char* rawData = reinterpret_cast<const char*>(&landData->mHeights[0]);
|
||||||
|
return QByteArray(rawData, Land::LAND_NUM_VERTS * sizeof(float));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandHeightsColumn::set(Record<Land>& record, const QVariant& data)
|
||||||
|
{
|
||||||
|
Land copy = record.get();
|
||||||
|
Land::LandData* landData = copy.getLandData();
|
||||||
|
assert (landData);
|
||||||
|
|
||||||
|
QByteArray array = data.toByteArray();
|
||||||
|
const float* rawData = reinterpret_cast<const float*>(array.data());
|
||||||
|
|
||||||
|
assert (array.count() == Land::LAND_NUM_VERTS * sizeof(float));
|
||||||
|
|
||||||
|
for (int i = 0; i < array.count(); ++i)
|
||||||
|
{
|
||||||
|
landData->mHeights[i] = rawData[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
record.setModified(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LandHeightsColumn::isEditable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* LandColoursColumn */
|
||||||
|
LandColoursColumn::LandColoursColumn()
|
||||||
|
: Column<Land>(Columns::ColumnId_LandColoursIndex, ColumnBase::Display_String, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant LandColoursColumn::get(const Record<Land>& record) const
|
||||||
|
{
|
||||||
|
const Land::LandData* landData = record.get().getLandData();
|
||||||
|
assert(landData);
|
||||||
|
|
||||||
|
// Note: original data is unsigned char
|
||||||
|
const char* rawData = reinterpret_cast<const char*>(&landData->mColours[0]);
|
||||||
|
return QByteArray(rawData, Land::LAND_NUM_VERTS * 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandColoursColumn::set(Record<Land>& record, const QVariant& data)
|
||||||
|
{
|
||||||
|
Land copy = record.get();
|
||||||
|
Land::LandData* landData = copy.getLandData();
|
||||||
|
assert (landData);
|
||||||
|
|
||||||
|
QByteArray array = data.toByteArray();
|
||||||
|
const unsigned char* rawData = reinterpret_cast<const unsigned char*>(array.data());
|
||||||
|
|
||||||
|
assert (array.count() == Land::LAND_NUM_VERTS * 3);
|
||||||
|
|
||||||
|
for (int i = 0; i < array.count(); ++i)
|
||||||
|
{
|
||||||
|
landData->mColours[i] = rawData[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
record.setModified(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LandColoursColumn::isEditable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* LandTexturesColumn */
|
||||||
|
LandTexturesColumn::LandTexturesColumn()
|
||||||
|
: Column<Land>(Columns::ColumnId_LandTexturesIndex, ColumnBase::Display_String, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant LandTexturesColumn::get(const Record<Land>& record) const
|
||||||
|
{
|
||||||
|
const Land::LandData* landData = record.get().getLandData();
|
||||||
|
assert(landData);
|
||||||
|
|
||||||
|
// Note: original data is uint16_t
|
||||||
|
const char* rawData = reinterpret_cast<const char*>(&landData->mTextures[0]);
|
||||||
|
return QByteArray(rawData, Land::LAND_NUM_TEXTURES * sizeof(uint16_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandTexturesColumn::set(Record<Land>& record, const QVariant& data)
|
||||||
|
{
|
||||||
|
Land copy = record.get();
|
||||||
|
Land::LandData* landData = copy.getLandData();
|
||||||
|
assert (landData);
|
||||||
|
|
||||||
|
QByteArray array = data.toByteArray();
|
||||||
|
const uint16_t* rawData = reinterpret_cast<const uint16_t*>(array.data());
|
||||||
|
|
||||||
|
assert (array.count() == Land::LAND_NUM_TEXTURES * sizeof(uint16_t));
|
||||||
|
|
||||||
|
for (int i = 0; i < array.count(); ++i)
|
||||||
|
{
|
||||||
|
landData->mTextures[i] = rawData[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
record.setModified(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LandTexturesColumn::isEditable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* BodyPartRaceColumn */
|
||||||
|
BodyPartRaceColumn::BodyPartRaceColumn(const MeshTypeColumn<ESM::BodyPart> *meshType)
|
||||||
|
: mMeshType(meshType)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QVariant BodyPartRaceColumn::get(const Record<ESM::BodyPart> &record) const
|
||||||
|
{
|
||||||
|
if (mMeshType != NULL && mMeshType->get(record) == ESM::BodyPart::MT_Skin)
|
||||||
|
{
|
||||||
|
return QString::fromUtf8(record.get().mRace.c_str());
|
||||||
|
}
|
||||||
|
return QVariant(QVariant::UserType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BodyPartRaceColumn::set(Record<ESM::BodyPart> &record, const QVariant &data)
|
||||||
|
{
|
||||||
|
ESM::BodyPart record2 = record.get();
|
||||||
|
|
||||||
|
record2.mRace = data.toString().toUtf8().constData();
|
||||||
|
|
||||||
|
record.setModified(record2);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BodyPartRaceColumn::isEditable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2501,6 +2501,51 @@ namespace CSMWorld
|
||||||
return record.get().mPluginIndex;
|
return record.get().mPluginIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct LandMapLodColumn : public Column<Land>
|
||||||
|
{
|
||||||
|
LandMapLodColumn();
|
||||||
|
|
||||||
|
QVariant get(const Record<Land>& record) const override;
|
||||||
|
void set(Record<Land>& record, const QVariant& data) override;
|
||||||
|
bool isEditable() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LandNormalsColumn : public Column<Land>
|
||||||
|
{
|
||||||
|
LandNormalsColumn();
|
||||||
|
|
||||||
|
QVariant get(const Record<Land>& record) const override;
|
||||||
|
void set(Record<Land>& record, const QVariant& data) override;
|
||||||
|
bool isEditable() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LandHeightsColumn : public Column<Land>
|
||||||
|
{
|
||||||
|
LandHeightsColumn();
|
||||||
|
|
||||||
|
QVariant get(const Record<Land>& record) const override;
|
||||||
|
void set(Record<Land>& record, const QVariant& data) override;
|
||||||
|
bool isEditable() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LandColoursColumn : public Column<Land>
|
||||||
|
{
|
||||||
|
LandColoursColumn();
|
||||||
|
|
||||||
|
QVariant get(const Record<Land>& record) const override;
|
||||||
|
void set(Record<Land>& record, const QVariant& data) override;
|
||||||
|
bool isEditable() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LandTexturesColumn : public Column<Land>
|
||||||
|
{
|
||||||
|
LandTexturesColumn();
|
||||||
|
|
||||||
|
QVariant get(const Record<Land>& record) const override;
|
||||||
|
void set(Record<Land>& record, const QVariant& data) override;
|
||||||
|
bool isEditable() const override;
|
||||||
|
};
|
||||||
|
|
||||||
struct BodyPartRaceColumn : public RaceColumn<ESM::BodyPart>
|
struct BodyPartRaceColumn : public RaceColumn<ESM::BodyPart>
|
||||||
{
|
{
|
||||||
const MeshTypeColumn<ESM::BodyPart> *mMeshType;
|
const MeshTypeColumn<ESM::BodyPart> *mMeshType;
|
||||||
|
|
|
@ -332,6 +332,11 @@ namespace CSMWorld
|
||||||
ColumnId_TextureHandle = 298,
|
ColumnId_TextureHandle = 298,
|
||||||
ColumnId_PluginIndex = 299,
|
ColumnId_PluginIndex = 299,
|
||||||
ColumnId_TextureIndex = 300,
|
ColumnId_TextureIndex = 300,
|
||||||
|
ColumnId_LandMapLodIndex = 301,
|
||||||
|
ColumnId_LandNormalsIndex = 302,
|
||||||
|
ColumnId_LandHeightsIndex = 303,
|
||||||
|
ColumnId_LandColoursIndex = 304,
|
||||||
|
ColumnId_LandTexturesIndex = 305,
|
||||||
|
|
||||||
// Allocated to a separate value range, so we don't get a collision should we ever need
|
// Allocated to a separate value range, so we don't get a collision should we ever need
|
||||||
// to extend the number of use values.
|
// to extend the number of use values.
|
||||||
|
|
|
@ -416,6 +416,11 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat
|
||||||
mLand.addColumn (new RecordStateColumn<Land>);
|
mLand.addColumn (new RecordStateColumn<Land>);
|
||||||
mLand.addColumn (new FixedRecordTypeColumn<Land>(UniversalId::Type_Land));
|
mLand.addColumn (new FixedRecordTypeColumn<Land>(UniversalId::Type_Land));
|
||||||
mLand.addColumn (new PluginIndexColumn<Land>);
|
mLand.addColumn (new PluginIndexColumn<Land>);
|
||||||
|
mLand.addColumn (new LandMapLodColumn);
|
||||||
|
mLand.addColumn (new LandNormalsColumn);
|
||||||
|
mLand.addColumn (new LandHeightsColumn);
|
||||||
|
mLand.addColumn (new LandColoursColumn);
|
||||||
|
mLand.addColumn (new LandTexturesColumn);
|
||||||
|
|
||||||
mLandTextures.addColumn (new StringIdColumn<LandTexture>(true));
|
mLandTextures.addColumn (new StringIdColumn<LandTexture>(true));
|
||||||
mLandTextures.addColumn (new RecordStateColumn<LandTexture>);
|
mLandTextures.addColumn (new RecordStateColumn<LandTexture>);
|
||||||
|
|
|
@ -64,6 +64,8 @@ struct Land
|
||||||
//total number of textures per land
|
//total number of textures per land
|
||||||
static const int LAND_NUM_TEXTURES = LAND_TEXTURE_SIZE * LAND_TEXTURE_SIZE;
|
static const int LAND_NUM_TEXTURES = LAND_TEXTURE_SIZE * LAND_TEXTURE_SIZE;
|
||||||
|
|
||||||
|
static const int LAND_GLOBAL_MAP_LOD_SIZE = 81;
|
||||||
|
|
||||||
#pragma pack(push,1)
|
#pragma pack(push,1)
|
||||||
struct VHGT
|
struct VHGT
|
||||||
{
|
{
|
||||||
|
@ -109,7 +111,7 @@ struct Land
|
||||||
};
|
};
|
||||||
|
|
||||||
// low-LOD heightmap (used for rendering the global map)
|
// low-LOD heightmap (used for rendering the global map)
|
||||||
signed char mWnam[81];
|
signed char mWnam[LAND_GLOBAL_MAP_LOD_SIZE];
|
||||||
|
|
||||||
void load(ESMReader &esm, bool &isDeleted);
|
void load(ESMReader &esm, bool &isDeleted);
|
||||||
void save(ESMWriter &esm, bool isDeleted = false) const;
|
void save(ESMWriter &esm, bool isDeleted = false) const;
|
||||||
|
|
Loading…
Reference in a new issue