update
This commit is contained in:
@@ -88,7 +88,7 @@ public:
|
|||||||
|
|
||||||
glm::vec3 mVertices[mapbufsize];
|
glm::vec3 mVertices[mapbufsize];
|
||||||
glm::vec3 mNormals[mapbufsize];
|
glm::vec3 mNormals[mapbufsize];
|
||||||
glm::vec3 mccv[mapbufsize];
|
glm::vec3 mccv[mapbufsize]; // blizzard stores alpha, but deosn't seem to be used
|
||||||
|
|
||||||
uint8_t _shadow_map[64 * 64];
|
uint8_t _shadow_map[64 * 64];
|
||||||
|
|
||||||
|
|||||||
@@ -151,14 +151,6 @@ struct MapChunkHeader {
|
|||||||
uint32_t unused2 = 0;
|
uint32_t unused2 = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MCCV
|
|
||||||
{
|
|
||||||
uint32_t textureID = 0;
|
|
||||||
uint32_t flags = 0;
|
|
||||||
uint32_t ofsAlpha = 0;
|
|
||||||
uint32_t effectID = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MCLYFlags
|
struct MCLYFlags
|
||||||
{
|
{
|
||||||
uint32_t animation_rotation : 3; // each tick is 45°
|
uint32_t animation_rotation : 3; // each tick is 45°
|
||||||
|
|||||||
@@ -1200,7 +1200,7 @@ QImage MapTile::getAlphamapImage(std::string const& filename)
|
|||||||
{
|
{
|
||||||
for (int l = 0; l < 64; ++l)
|
for (int l = 0; l < 64; ++l)
|
||||||
{
|
{
|
||||||
if (layer == 0) // titi test
|
if (layer == 0)
|
||||||
{
|
{
|
||||||
// WoW calculates layer 0 as 255 - sum(Layer[1]...Layer[3])
|
// WoW calculates layer 0 as 255 - sum(Layer[1]...Layer[3])
|
||||||
int layers_sum = 0;
|
int layers_sum = 0;
|
||||||
|
|||||||
@@ -33,12 +33,95 @@ void selected_chunk_type::updateDetails(Noggit::Ui::detail_infos* detail_widget)
|
|||||||
|
|
||||||
select_info << "\n<br><b>Chunk Unit</b> (" << unit_index.x << ", " << unit_index.y << ")"
|
select_info << "\n<br><b>Chunk Unit</b> (" << unit_index.x << ", " << unit_index.y << ")"
|
||||||
<< "<br><b>Chunk Unit Effect Doodads disabled</b>: "
|
<< "<br><b>Chunk Unit Effect Doodads disabled</b>: "
|
||||||
<< (chunk->getTextureSet()->getDoodadEnabledAt(unit_index.y, unit_index.x) ? "True" : "False")
|
<< (chunk->getTextureSet()->getDoodadDisabledAt(unit_index.x, unit_index.y) ? "True" : "False")
|
||||||
<< "<br><b>Chunk Unit Active Doodad Effect Layer </b>: "
|
<< "<br><b>Chunk Unit Active Doodad Effect Layer </b>: "
|
||||||
<< int(chunk->getTextureSet()->getDoodadActiveLayerIdAt(unit_index.x, unit_index.y))
|
<< int(chunk->getTextureSet()->getDoodadActiveLayerIdAt(unit_index.x, unit_index.y))
|
||||||
<< ""
|
<< ""
|
||||||
<<"\n";
|
<<"\n";
|
||||||
|
|
||||||
|
|
||||||
|
// test compare active layer algorithm with blizzard. can reuse the same for saving
|
||||||
|
|
||||||
|
|
||||||
|
int matching_count = 0;
|
||||||
|
int not_matching_count = 0;
|
||||||
|
int very_innacurate_count = 0;
|
||||||
|
|
||||||
|
auto tile = chunk->mt;
|
||||||
|
|
||||||
|
for (int chunk_x = 0; chunk_x < 16; chunk_x++)
|
||||||
|
{
|
||||||
|
for (int chunk_y = 0; chunk_y < 16; chunk_y++)
|
||||||
|
{
|
||||||
|
auto local_chunk = tile->getChunk(chunk_x, chunk_y);
|
||||||
|
|
||||||
|
auto blizzard_mapping = local_chunk->getTextureSet()->getDoodadMapping();
|
||||||
|
auto blizzard_mapping_readable = local_chunk->getTextureSet()->getDoodadMappingReadable();
|
||||||
|
|
||||||
|
std::array<std::uint16_t, 8> test_doodadMapping{};
|
||||||
|
std::array<std::array<std::uint8_t, 8>, 8> doodad_mapping_readable{};
|
||||||
|
|
||||||
|
for (int x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 8; y++)
|
||||||
|
{
|
||||||
|
std::array<float, 4> weights = local_chunk->getTextureSet()->get_textures_weight_for_unit(x, y);
|
||||||
|
|
||||||
|
float max = weights[0];
|
||||||
|
int max_layer_index = 0;
|
||||||
|
|
||||||
|
for (int i = 1; i < weights.size(); i++)
|
||||||
|
if (weights[i] >= max) // (weights[i] >= max) ? superior layer seems to have priority
|
||||||
|
{
|
||||||
|
max = weights[i];
|
||||||
|
max_layer_index = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int firstbit_pos = x * 2;
|
||||||
|
doodad_mapping_readable[y][x] = max_layer_index;
|
||||||
|
// there might be a smarter way to do this
|
||||||
|
if (max_layer_index == 1)
|
||||||
|
{
|
||||||
|
test_doodadMapping[y] |= (1 << firstbit_pos);
|
||||||
|
}
|
||||||
|
else if (max_layer_index == 2)
|
||||||
|
{
|
||||||
|
test_doodadMapping[y] |= (1 << firstbit_pos + 1);
|
||||||
|
}
|
||||||
|
else if (max_layer_index == 3)
|
||||||
|
{
|
||||||
|
test_doodadMapping[y] |= (1 << firstbit_pos) | (1 << (firstbit_pos + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// debug compare
|
||||||
|
uint8_t blizzard_layer_id = blizzard_mapping_readable[y][x];
|
||||||
|
//uint8_t blizzard_layer_id2 = blizzard_mapping_readable[x][y];
|
||||||
|
uint8_t blizzard_layer_id3 = local_chunk->getTextureSet()->getDoodadActiveLayerIdAt(x, y); // make sure
|
||||||
|
bool test_doodads_enabled = local_chunk->getTextureSet()->getDoodadDisabledAt(x, y);
|
||||||
|
|
||||||
|
if (max_layer_index != blizzard_layer_id)
|
||||||
|
{
|
||||||
|
int blizzard_effect_id = local_chunk->getTextureSet()->getEffectForLayer(blizzard_layer_id);
|
||||||
|
int found_effect_id = local_chunk->getTextureSet()->getEffectForLayer(max_layer_index);
|
||||||
|
not_matching_count++;
|
||||||
|
|
||||||
|
float percent_innacuracy = ((weights[max_layer_index] - weights[blizzard_layer_id]) / ((weights[max_layer_index] + weights[blizzard_layer_id]) / 2)) * 100.f;
|
||||||
|
|
||||||
|
if (percent_innacuracy > 10)
|
||||||
|
very_innacurate_count++;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
matching_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float not_matching_percent = ((float)not_matching_count / (float)matching_count) * 100.f;
|
||||||
|
|
||||||
|
|
||||||
std::array<float, 4> weights = chunk->getTextureSet()->get_textures_weight_for_unit(unit_index.x, unit_index.y);
|
std::array<float, 4> weights = chunk->getTextureSet()->get_textures_weight_for_unit(unit_index.x, unit_index.y);
|
||||||
if (chunk->getTextureSet()->num())
|
if (chunk->getTextureSet()->num())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ void Noggit::Rendering::TileRender::setChunkGroundEffectColor(unsigned int chunk
|
|||||||
_chunk_instance_data[chunkid].ChunkGroundEffectColor[0] = color.r;
|
_chunk_instance_data[chunkid].ChunkGroundEffectColor[0] = color.r;
|
||||||
_chunk_instance_data[chunkid].ChunkGroundEffectColor[1] = color.g;
|
_chunk_instance_data[chunkid].ChunkGroundEffectColor[1] = color.g;
|
||||||
_chunk_instance_data[chunkid].ChunkGroundEffectColor[2] = color.b;
|
_chunk_instance_data[chunkid].ChunkGroundEffectColor[2] = color.b;
|
||||||
_chunk_instance_data[chunkid].ChunkGroundEffectColor[2] = 0.0; // not used
|
_chunk_instance_data[chunkid].ChunkGroundEffectColor[3] = 0.0; // not used
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileRender::initChunkData(MapChunk* chunk)
|
void TileRender::initChunkData(MapChunk* chunk)
|
||||||
|
|||||||
@@ -305,14 +305,14 @@ void main()
|
|||||||
uint unit_x = uint(floor((vary_position.x - (tile_base_pos.x + chunk_base_pos.x)) / UNITSIZE));
|
uint unit_x = uint(floor((vary_position.x - (tile_base_pos.x + chunk_base_pos.x)) / UNITSIZE));
|
||||||
uint unit_z = uint(floor((vary_position.z - (tile_base_pos.y + chunk_base_pos.y)) / UNITSIZE));
|
uint unit_z = uint(floor((vary_position.z - (tile_base_pos.y + chunk_base_pos.y)) / UNITSIZE));
|
||||||
|
|
||||||
// swapped x and y order, the data is wrongly ordered when loaded
|
// x and y aren't swapped because getDoodadActiveLayerIdAt() already does it in code
|
||||||
if (unit_z < 4)
|
if (unit_x < 4)
|
||||||
{
|
{
|
||||||
is_active = uint(instances[instanceID].ChunkDoodadsEnabled2_ChunksLayerEnabled2.b) & (1 << ((unit_z * 8) + unit_x) );
|
is_active = uint(instances[instanceID].ChunkDoodadsEnabled2_ChunksLayerEnabled2.b) & (1 << ((unit_x * 8) + unit_z) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
is_active = uint(instances[instanceID].ChunkDoodadsEnabled2_ChunksLayerEnabled2.a) & (1 << ((unit_z * 8) + unit_x) - 32 ); // (unit_x-4) * 8 + unit_z)
|
is_active = uint(instances[instanceID].ChunkDoodadsEnabled2_ChunksLayerEnabled2.a) & (1 << ((unit_x * 8) + unit_z) - 32 ); // (unit_x-4) * 8 + unit_z)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_active != 0)
|
if (is_active != 0)
|
||||||
|
|||||||
@@ -372,22 +372,36 @@ int TextureSet::get_texture_index_or_add (scoped_blp_texture_reference texture,
|
|||||||
return addTexture (std::move (texture));
|
return addTexture (std::move (texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::array<std::array<std::uint8_t, 8>, 8> const TextureSet::getDoodadMappingReadable()
|
||||||
|
{
|
||||||
|
std::array<std::array<std::uint8_t, 8>, 8> doodad_mapping{};
|
||||||
|
|
||||||
|
for (int x = 0; x < 8; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 8; y++)
|
||||||
|
{
|
||||||
|
doodad_mapping[y][x] = getDoodadActiveLayerIdAt(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return doodad_mapping;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t const TextureSet::getDoodadActiveLayerIdAt(unsigned int x, unsigned int y)
|
uint8_t const TextureSet::getDoodadActiveLayerIdAt(unsigned int x, unsigned int y)
|
||||||
{
|
{
|
||||||
if (x >= 8 || y >= 8)
|
if (x >= 8 || y >= 8)
|
||||||
return 0; // not valid
|
return 0; // not valid
|
||||||
|
|
||||||
unsigned int firstbit_pos = y * 2;
|
unsigned int firstbit_pos = x * 2;
|
||||||
|
|
||||||
bool first_bit = _doodadMapping[x] & (1 << firstbit_pos);
|
bool first_bit = _doodadMapping[y] & (1 << firstbit_pos);
|
||||||
bool second_bit = _doodadMapping[x] & (1 << (firstbit_pos + 1) );
|
bool second_bit = _doodadMapping[y] & (1 << (firstbit_pos + 1) );
|
||||||
|
|
||||||
uint8_t layer_id = first_bit + second_bit * 2;
|
uint8_t layer_id = first_bit + second_bit * 2;
|
||||||
|
|
||||||
return layer_id;
|
return layer_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool const TextureSet::getDoodadEnabledAt(int x, int y)
|
bool const TextureSet::getDoodadDisabledAt(int x, int y)
|
||||||
{
|
{
|
||||||
if (x >= 8 || y >= 8)
|
if (x >= 8 || y >= 8)
|
||||||
return true; // not valid. default to enabled
|
return true; // not valid. default to enabled
|
||||||
@@ -1303,15 +1317,15 @@ std::array<float, 4> TextureSet::get_textures_weight_for_unit(unsigned int unit_
|
|||||||
float total_layer_3 = 0.f;
|
float total_layer_3 = 0.f;
|
||||||
|
|
||||||
// 8x8 bits per unit
|
// 8x8 bits per unit
|
||||||
for (int x = unit_x; x < unit_x + 8; x++)
|
for (int x = 0; x < 8; x++)
|
||||||
{
|
{
|
||||||
for (int y = unit_y; y < unit_y + 8; y++)
|
for (int y = 0; y < 8; y++)
|
||||||
{
|
{
|
||||||
float base_alpha = 255.f;
|
float base_alpha = 255.f;
|
||||||
|
|
||||||
for (int alpha_layer = 0; alpha_layer < nTextures - 1; ++alpha_layer)
|
for (int alpha_layer = 0; alpha_layer < nTextures - 1; ++alpha_layer)
|
||||||
{
|
{
|
||||||
float f = static_cast<float>(alphamaps[alpha_layer]->getAlpha(64 * y + x));
|
float f = static_cast<float>(alphamaps[alpha_layer]->getAlpha( (unit_y * 8 + y)* 64 + (unit_x * 8 + x) )); // getAlpha(64 * y + x))
|
||||||
|
|
||||||
if (alpha_layer == 0)
|
if (alpha_layer == 0)
|
||||||
total_layer_1 += f;
|
total_layer_1 += f;
|
||||||
|
|||||||
@@ -96,9 +96,11 @@ public:
|
|||||||
|
|
||||||
int get_texture_index_or_add (scoped_blp_texture_reference texture, float target);
|
int get_texture_index_or_add (scoped_blp_texture_reference texture, float target);
|
||||||
auto getDoodadMappingBase(void) -> std::uint16_t* { return _doodadMapping.data(); }
|
auto getDoodadMappingBase(void) -> std::uint16_t* { return _doodadMapping.data(); }
|
||||||
|
std::array<std::uint16_t, 8> const& getDoodadMapping() { return _doodadMapping; }
|
||||||
|
std::array<std::array<std::uint8_t, 8>, 8> const getDoodadMappingReadable(); // get array of readable values
|
||||||
auto getDoodadStencilBase(void) -> std::uint8_t* { return _doodadStencil.data(); }
|
auto getDoodadStencilBase(void) -> std::uint8_t* { return _doodadStencil.data(); }
|
||||||
uint8_t const getDoodadActiveLayerIdAt(unsigned int x, unsigned int y); // max is 8
|
uint8_t const getDoodadActiveLayerIdAt(unsigned int x, unsigned int y); // max is 8
|
||||||
bool const getDoodadEnabledAt(int x, int y); // max is 8
|
bool const getDoodadDisabledAt(int x, int y); // max is 8
|
||||||
auto getEffectForLayer(std::size_t idx) const -> unsigned { return _layers_info[idx].effectID; }
|
auto getEffectForLayer(std::size_t idx) const -> unsigned { return _layers_info[idx].effectID; }
|
||||||
ENTRY_MCLY* getMCLYEntries() { return &_layers_info[0]; };
|
ENTRY_MCLY* getMCLYEntries() { return &_layers_info[0]; };
|
||||||
void setNTextures(size_t n) { nTextures = n; };
|
void setNTextures(size_t n) { nTextures = n; };
|
||||||
@@ -133,7 +135,7 @@ private:
|
|||||||
// this is actually uint1_t[8][8] (8*8 -> 1 bit each)
|
// this is actually uint1_t[8][8] (8*8 -> 1 bit each)
|
||||||
bool _need_lod_texture_map_update = false;
|
bool _need_lod_texture_map_update = false;
|
||||||
|
|
||||||
ENTRY_MCLY _layers_info[4];
|
ENTRY_MCLY _layers_info[4]; // TODO rework this, don't need to store textureid and offset
|
||||||
|
|
||||||
std::optional<tmp_edit_alpha_values> tmp_edit_values;
|
std::optional<tmp_edit_alpha_values> tmp_edit_values;
|
||||||
|
|
||||||
|
|||||||
@@ -520,7 +520,10 @@ namespace Noggit
|
|||||||
|
|
||||||
connect( asset_browser_btn
|
connect( asset_browser_btn
|
||||||
, &QPushButton::clicked
|
, &QPushButton::clicked
|
||||||
, [=]() { mapView->getAssetBrowser()->setVisible(mapView->getAssetBrowser()->isHidden()); }
|
, [=]() {
|
||||||
|
_map_view->getAssetBrowserWidget()->set_browse_mode(Tools::AssetBrowser::asset_browse_mode::world);
|
||||||
|
mapView->getAssetBrowser()->setVisible(mapView->getAssetBrowser()->isHidden());
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
connect( object_palette_btn
|
connect( object_palette_btn
|
||||||
|
|||||||
@@ -721,7 +721,7 @@ namespace Noggit
|
|||||||
_render_type_group = new QButtonGroup(_render_group_box);
|
_render_type_group = new QButtonGroup(_render_group_box);
|
||||||
|
|
||||||
_render_active_sets = new QRadioButton("Effect Id/Set", this);
|
_render_active_sets = new QRadioButton("Effect Id/Set", this);
|
||||||
_render_active_sets->setToolTip("Render all the loaded effect sets for this texture in various colors");
|
_render_active_sets->setToolTip("Render all the loaded effect sets for this texture in matching colors");
|
||||||
_render_type_group->addButton(_render_active_sets);
|
_render_type_group->addButton(_render_active_sets);
|
||||||
render_layout->addWidget(_render_active_sets);
|
render_layout->addWidget(_render_active_sets);
|
||||||
|
|
||||||
@@ -730,8 +730,8 @@ namespace Noggit
|
|||||||
_render_type_group->addButton(_render_exclusion_map);
|
_render_type_group->addButton(_render_exclusion_map);
|
||||||
render_layout->addWidget(_render_exclusion_map);
|
render_layout->addWidget(_render_exclusion_map);
|
||||||
|
|
||||||
_render_placement_map = new QRadioButton("Selected set active", this); // if chunk contains texture/Effect : render as green or red if the effect layer is active or not
|
_render_placement_map = new QRadioButton("Selected Texture state", this); // if chunk contains texture/Effect : render as green or red if the effect layer is active or not
|
||||||
_render_placement_map->setToolTip("For the currently selected set, render as red if set is present in the chunk unit and NOT the current active layer, render as green if it's active.");
|
_render_placement_map->setToolTip("Render chunk unit as red if texture is present in the chunk and NOT the current active layer, render as green if it's active. \nThis defines which of the 4 textures' set is currently active, this is determined by which has the highest opacity.");
|
||||||
_render_type_group->addButton(_render_placement_map);
|
_render_type_group->addButton(_render_placement_map);
|
||||||
render_layout->addWidget(_render_placement_map);
|
render_layout->addWidget(_render_placement_map);
|
||||||
|
|
||||||
@@ -771,6 +771,8 @@ namespace Noggit
|
|||||||
_effect_sets_list->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
_effect_sets_list->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
||||||
_effect_sets_list->setSelectionBehavior(QAbstractItemView::SelectItems);
|
_effect_sets_list->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||||
_effect_sets_list->setUniformItemSizes(true);
|
_effect_sets_list->setUniformItemSizes(true);
|
||||||
|
_effect_sets_list->setFixedHeight(160);
|
||||||
|
_effect_sets_list->setIconSize(QSize(20, 20));
|
||||||
|
|
||||||
// _effect_sets_list->setMinimumHeight(_object_list->iconSize().height() * 6);
|
// _effect_sets_list->setMinimumHeight(_object_list->iconSize().height() * 6);
|
||||||
|
|
||||||
@@ -785,21 +787,39 @@ namespace Noggit
|
|||||||
auto settings_layout(new QFormLayout(settings_group));
|
auto settings_layout(new QFormLayout(settings_group));
|
||||||
settings_group->setLayout(settings_layout);
|
settings_group->setLayout(settings_layout);
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
// for (int i = 0; i < 4; i++)
|
||||||
{
|
// {
|
||||||
_button_effect_doodad[i] = new QPushButton(" -NONE- ", this);
|
// _button_effect_doodad[i] = new QPushButton(STRING_EMPTY_DISPLAY, this);
|
||||||
settings_layout->addRow(("Effect Doodad " + std::to_string(i) + " : ").c_str(), _button_effect_doodad[i]);
|
// settings_layout->addRow(("Effect Doodad " + std::to_string(i) + " : ").c_str(), _button_effect_doodad[i]);
|
||||||
}
|
// }
|
||||||
|
|
||||||
_object_list = new ObjectList(this);
|
|
||||||
|
// auto doodads_layout(new QGridLayout(settings_group));
|
||||||
|
// settings_layout->addRow(settings_layout);
|
||||||
|
|
||||||
|
_object_list = new QListWidget(this);
|
||||||
_object_list->setItemAlignment(Qt::AlignLeft);
|
_object_list->setItemAlignment(Qt::AlignLeft);
|
||||||
_object_list->setViewMode(QListView::IconMode);
|
_object_list->setViewMode(QListView::IconMode);
|
||||||
|
_object_list->setWrapping(false);
|
||||||
|
_object_list->setIconSize(QSize(100, 100));
|
||||||
|
_object_list->setFlow(QListWidget::LeftToRight);
|
||||||
|
_object_list->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
_object_list->setAcceptDrops(false);
|
||||||
|
_object_list->setMovement(QListView::Movement::Static);
|
||||||
|
_object_list->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||||
|
_object_list->setMinimumWidth(425);
|
||||||
|
_object_list->setMinimumHeight(120);
|
||||||
|
|
||||||
settings_layout->addRow(_object_list);
|
settings_layout->addRow(_object_list);
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
QListWidgetItem* list_item = new QListWidgetItem(_object_list);
|
QListWidgetItem* list_item = new QListWidgetItem(_object_list);
|
||||||
|
list_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
list_item->setIcon(Noggit::Ui::FontAwesomeIcon(Noggit::Ui::FontAwesome::plus));
|
list_item->setIcon(Noggit::Ui::FontAwesomeIcon(Noggit::Ui::FontAwesome::plus));
|
||||||
list_item->setText(" -NONE- ");
|
list_item->setText(STRING_EMPTY_DISPLAY);
|
||||||
|
|
||||||
|
// list_item->setData(Qt::DisplayRole, ""); // does the same as settext
|
||||||
|
list_item->setToolTip("");
|
||||||
_object_list->addItem(list_item);
|
_object_list->addItem(list_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -847,6 +867,22 @@ namespace Noggit
|
|||||||
auto apply_layout(new QVBoxLayout(apply_group));
|
auto apply_layout(new QVBoxLayout(apply_group));
|
||||||
apply_group->setLayout(apply_layout);
|
apply_group->setLayout(apply_layout);
|
||||||
|
|
||||||
|
// generate modes
|
||||||
|
{
|
||||||
|
auto generate_type_group = new QButtonGroup(apply_group);
|
||||||
|
|
||||||
|
auto generate_effect_zone = new QRadioButton("Current Zone", this);
|
||||||
|
generate_type_group->addButton(generate_effect_zone);
|
||||||
|
apply_layout->addWidget(generate_effect_zone);
|
||||||
|
|
||||||
|
auto generate_effect_area = new QRadioButton("Current Area(subzone)", this);
|
||||||
|
generate_type_group->addButton(generate_effect_area);
|
||||||
|
apply_layout->addWidget(generate_effect_area);
|
||||||
|
|
||||||
|
generate_effect_zone->setChecked(true);
|
||||||
|
generate_effect_zone->setAutoExclusive(true);
|
||||||
|
}
|
||||||
|
|
||||||
_apply_override_cb = new QCheckBox("Override", this);
|
_apply_override_cb = new QCheckBox("Override", this);
|
||||||
apply_layout->addWidget(_apply_override_cb);
|
apply_layout->addWidget(_apply_override_cb);
|
||||||
|
|
||||||
@@ -975,17 +1011,25 @@ namespace Noggit
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO fix this shit
|
// TODO fix this shit
|
||||||
for (int i = 0; i < 4; i++)
|
// for (int i = 0; i < 4; i++)
|
||||||
{
|
// {
|
||||||
connect(_button_effect_doodad[i], &QPushButton::clicked
|
// connect(_button_effect_doodad[i], &QPushButton::clicked
|
||||||
, [=]()
|
// , [=]()
|
||||||
|
// {
|
||||||
|
// active_doodad_widget = i;
|
||||||
|
// _map_view->getAssetBrowserWidget()->set_browse_mode(Tools::AssetBrowser::asset_browse_mode::detail_doodads);
|
||||||
|
// _map_view->getAssetBrowser()->setVisible(true);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
connect(_object_list, &QListWidget::itemClicked, this, [=](QListWidgetItem* item)
|
||||||
{
|
{
|
||||||
active_doodad_widget = i;
|
|
||||||
_map_view->getAssetBrowserWidget()->set_browse_mode(Tools::AssetBrowser::asset_browse_mode::detail_doodads);
|
_map_view->getAssetBrowserWidget()->set_browse_mode(Tools::AssetBrowser::asset_browse_mode::detail_doodads);
|
||||||
_map_view->getAssetBrowser()->setVisible(true);
|
_map_view->getAssetBrowser()->setVisible(true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ground_effect_tool::updateTerrainUniformParams()
|
void ground_effect_tool::updateTerrainUniformParams()
|
||||||
@@ -1080,10 +1124,10 @@ namespace Noggit
|
|||||||
|
|
||||||
void ground_effect_tool::updateSetsList()
|
void ground_effect_tool::updateSetsList()
|
||||||
{
|
{
|
||||||
|
_effect_sets_list->clear();
|
||||||
genEffectColors();
|
genEffectColors();
|
||||||
|
|
||||||
// _cbbox_effect_sets->clear();
|
// _cbbox_effect_sets->clear();
|
||||||
_effect_sets_list->clear();
|
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (auto& effect_set : _loaded_effects)
|
for (auto& effect_set : _loaded_effects)
|
||||||
@@ -1102,20 +1146,21 @@ namespace Noggit
|
|||||||
|
|
||||||
|
|
||||||
QListWidgetItem* list_item = new QListWidgetItem(effect_set.Name.c_str());
|
QListWidgetItem* list_item = new QListWidgetItem(effect_set.Name.c_str());
|
||||||
|
_effect_sets_list->addItem(list_item);
|
||||||
|
|
||||||
list_item->setData(Qt::BackgroundRole, color);
|
// list_item->setData(Qt::BackgroundRole, color); // same as setBackgroundColor
|
||||||
list_item->setBackground(color);
|
|
||||||
list_item->setBackgroundColor(color);
|
list_item->setBackgroundColor(color);
|
||||||
QPixmap pixmap(50, 50);
|
QPixmap pixmap(_effect_sets_list->iconSize());
|
||||||
pixmap.fill(color);
|
pixmap.fill(color);
|
||||||
QIcon icon(pixmap);
|
QIcon icon(pixmap);
|
||||||
list_item->setIcon(icon);
|
list_item->setIcon(icon);
|
||||||
_effect_sets_list->addItem(list_item);
|
|
||||||
|
|
||||||
// test
|
// test
|
||||||
QPalette pal = _effect_sets_list->palette();
|
// QPalette pal = _effect_sets_list->palette();
|
||||||
pal.setColor(_effect_sets_list->backgroundRole(), color);
|
// pal.setColor(_effect_sets_list->backgroundRole(), color);
|
||||||
_effect_sets_list->setPalette(pal);
|
// _effect_sets_list->setPalette(pal);
|
||||||
|
// list_item->setTextColor()
|
||||||
|
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
@@ -1139,28 +1184,27 @@ namespace Noggit
|
|||||||
{
|
{
|
||||||
_effects_colors.clear();
|
_effects_colors.clear();
|
||||||
|
|
||||||
int count = 1;
|
int color_count = 1;
|
||||||
for (auto& effect : _loaded_effects)
|
for (auto& effect : _loaded_effects)
|
||||||
{
|
{
|
||||||
// same formula as in the shader
|
// same formula as in the shader
|
||||||
float partr, partg, partb;
|
float partr, partg, partb;
|
||||||
// TODO : can use id instead of count ?
|
// TODO : can use id instead of count ?
|
||||||
float r = modf(sin(glm::dot(glm::vec2(count), glm::vec2(12.9898, 78.233))) * 43758.5453, &partr);
|
float r = modf(sin(glm::dot(glm::vec2(color_count), glm::vec2(12.9898, 78.233))) * 43758.5453, &partr);
|
||||||
float g = modf(sin(glm::dot(glm::vec2(count), glm::vec2(11.5591, 70.233))) * 43569.5451, &partg);
|
float g = modf(sin(glm::dot(glm::vec2(color_count), glm::vec2(11.5591, 70.233))) * 43569.5451, &partg);
|
||||||
float b = modf(sin(glm::dot(glm::vec2(count), glm::vec2(13.1234, 76.234))) * 43765.5452, &partg);
|
float b = modf(sin(glm::dot(glm::vec2(color_count), glm::vec2(13.1234, 76.234))) * 43765.5452, &partg);
|
||||||
|
|
||||||
// return vec3(r, g, b);
|
// return vec3(r, g, b);
|
||||||
count++;
|
color_count++;
|
||||||
|
|
||||||
_effects_colors.push_back(glm::vec3(r, g, b));
|
_effects_colors.push_back(glm::vec3(r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string active_texture = _texturing_tool->_current_texture->filename();
|
std::string active_texture = _texturing_tool->_current_texture->filename();
|
||||||
|
|
||||||
if (active_texture.empty() || active_texture == "tileset\\generic\\black.blp")
|
// check in loop instead to clear data everytime
|
||||||
return;
|
// if (active_texture.empty() || active_texture == "tileset\\generic\\black.blp")
|
||||||
|
// return;
|
||||||
std::unordered_map<unsigned int, ground_effect_set> ground_effect_cache;
|
|
||||||
|
|
||||||
for (MapTile* tile : _map_view->getWorld()->mapIndex.loaded_tiles())
|
for (MapTile* tile : _map_view->getWorld()->mapIndex.loaded_tiles())
|
||||||
{
|
{
|
||||||
@@ -1171,12 +1215,15 @@ namespace Noggit
|
|||||||
auto chunk = tile->getChunk(x, y);
|
auto chunk = tile->getChunk(x, y);
|
||||||
|
|
||||||
int chunk_index = chunk->px * 16 + chunk->py;
|
int chunk_index = chunk->px * 16 + chunk->py;
|
||||||
|
|
||||||
// reset to black by default
|
// reset to black by default
|
||||||
tile->renderer()->setChunkGroundEffectColor(chunk_index, glm::vec3(0.0, 0.0, 0.0));
|
tile->renderer()->setChunkGroundEffectColor(chunk_index, glm::vec3(0.0, 0.0, 0.0));
|
||||||
|
|
||||||
// ! Set the chunk active layer data
|
// ! Set the chunk active layer data
|
||||||
tile->renderer()->setChunkGroundEffectActiveData(chunk, active_texture);
|
tile->renderer()->setChunkGroundEffectActiveData(chunk, active_texture);
|
||||||
|
|
||||||
|
if (active_texture.empty() || active_texture == "tileset\\generic\\black.blp" || _loaded_effects.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
for (int layer_id = 0; layer_id < chunk->getTextureSet()->num(); layer_id++)
|
for (int layer_id = 0; layer_id < chunk->getTextureSet()->num(); layer_id++)
|
||||||
{
|
{
|
||||||
auto texture_name = chunk->getTextureSet()->filename(layer_id);
|
auto texture_name = chunk->getTextureSet()->filename(layer_id);
|
||||||
@@ -1197,12 +1244,15 @@ namespace Noggit
|
|||||||
_ground_effect_cache[effect_id] = ground_effect;
|
_ground_effect_cache[effect_id] = ground_effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = -1;
|
||||||
|
bool found_debug = false;
|
||||||
for (auto& effect_set : _loaded_effects)
|
for (auto& effect_set : _loaded_effects)
|
||||||
{
|
{
|
||||||
|
count++;
|
||||||
if (effect_id == effect_set.ID)
|
if (effect_id == effect_set.ID)
|
||||||
{
|
{
|
||||||
tile->renderer()->setChunkGroundEffectColor(chunk_index, _effects_colors[count]);
|
tile->renderer()->setChunkGroundEffectColor(chunk_index, _effects_colors[count]);
|
||||||
|
found_debug = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (_chkbox_merge_duplicates->isChecked() && (ground_effect == &effect_set)) // do deep comparison, find those that have the same effect as loaded effects, but diff id.
|
if (_chkbox_merge_duplicates->isChecked() && (ground_effect == &effect_set)) // do deep comparison, find those that have the same effect as loaded effects, but diff id.
|
||||||
@@ -1210,17 +1260,16 @@ namespace Noggit
|
|||||||
if (ground_effect.empty())
|
if (ground_effect.empty())
|
||||||
continue;
|
continue;
|
||||||
// same color
|
// same color
|
||||||
tile->renderer()->setChunkGroundEffectColor(chunk->px * 16 + chunk->py, _effects_colors[count]);
|
tile->renderer()->setChunkGroundEffectColor(chunk_index, _effects_colors[count]);
|
||||||
|
found_debug = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_render_placement_map->isChecked())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// in case some chunks couldn't be resolved, paint them in pure red
|
||||||
|
if (!found_debug)
|
||||||
|
tile->renderer()->setChunkGroundEffectColor(chunk_index, glm::vec3(1.0, 0.0, 0.0));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1233,7 +1282,7 @@ namespace Noggit
|
|||||||
{
|
{
|
||||||
// TODO : maybe load saved sets for the new texture
|
// TODO : maybe load saved sets for the new texture
|
||||||
|
|
||||||
active_doodad_widget = 0;
|
// active_doodad_widget = 0;
|
||||||
|
|
||||||
_loaded_effects.clear();
|
_loaded_effects.clear();
|
||||||
_ground_effect_cache.clear();
|
_ground_effect_cache.clear();
|
||||||
@@ -1247,7 +1296,7 @@ namespace Noggit
|
|||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
_button_effect_doodad[i]->setText(" -NONE- ");
|
// _button_effect_doodad[i]->setText(STRING_EMPTY_DISPLAY);
|
||||||
updateDoodadPreviewRender(i);
|
updateDoodadPreviewRender(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1257,18 +1306,25 @@ namespace Noggit
|
|||||||
const QFileInfo info(doodad_path);
|
const QFileInfo info(doodad_path);
|
||||||
const QString filename(info.fileName());
|
const QString filename(info.fileName());
|
||||||
|
|
||||||
_button_effect_doodad[active_doodad_widget]->setText(filename);
|
// _button_effect_doodad[active_doodad_widget]->setText(filename);
|
||||||
|
|
||||||
updateDoodadPreviewRender(active_doodad_widget);
|
if (_object_list->currentItem())
|
||||||
|
_object_list->currentItem()->setText(filename);
|
||||||
|
|
||||||
|
// _object_list->item(active_doodad_widget)->setText(filename);
|
||||||
|
|
||||||
|
updateDoodadPreviewRender(_object_list->currentRow());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ground_effect_tool::updateDoodadPreviewRender(int slot_index)
|
void ground_effect_tool::updateDoodadPreviewRender(int slot_index)
|
||||||
{
|
{
|
||||||
QString filename = _button_effect_doodad[slot_index]->text();
|
// QString filename = _button_effect_doodad[slot_index]->text();
|
||||||
|
|
||||||
QListWidgetItem* list_item = _object_list->item(slot_index); // new QListWidgetItem(_object_list);
|
QListWidgetItem* list_item = _object_list->item(slot_index); // new QListWidgetItem(_object_list);
|
||||||
|
|
||||||
if (filename.isEmpty() || filename == " -NONE- ")
|
QString filename = list_item->text();
|
||||||
|
|
||||||
|
if (filename.isEmpty() || filename == STRING_EMPTY_DISPLAY)
|
||||||
{
|
{
|
||||||
list_item->setIcon(Noggit::Ui::FontAwesomeIcon(Noggit::Ui::FontAwesome::plus)); // (Noggit::Ui::FontNoggitIcon(Noggit::Ui::FontNoggit::Icons::VISIBILITY_GROUNDEFFECTS));
|
list_item->setIcon(Noggit::Ui::FontAwesomeIcon(Noggit::Ui::FontAwesome::plus)); // (Noggit::Ui::FontNoggitIcon(Noggit::Ui::FontNoggit::Icons::VISIBILITY_GROUNDEFFECTS));
|
||||||
}
|
}
|
||||||
@@ -1279,17 +1335,18 @@ namespace Noggit
|
|||||||
_preview_renderer->setModelOffscreen(filepath.toStdString());
|
_preview_renderer->setModelOffscreen(filepath.toStdString());
|
||||||
list_item->setIcon(*_preview_renderer->renderToPixmap());
|
list_item->setIcon(*_preview_renderer->renderToPixmap());
|
||||||
|
|
||||||
_button_effect_doodad[slot_index]->setIcon(*_preview_renderer->renderToPixmap());
|
// _button_effect_doodad[slot_index]->setIcon(*_preview_renderer->renderToPixmap());
|
||||||
// list_item->setData(Qt::DisplayRole, filepath);
|
// list_item->setData(Qt::DisplayRole, filepath);
|
||||||
// list_item->setToolTip(filepath);
|
list_item->setToolTip(filepath);
|
||||||
|
|
||||||
}
|
}
|
||||||
list_item->setText(filename);
|
// list_item->setText(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
ground_effect_tool::~ground_effect_tool()
|
ground_effect_tool::~ground_effect_tool()
|
||||||
{
|
{
|
||||||
delete _preview_renderer;
|
delete _preview_renderer;
|
||||||
|
// _preview_renderer->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ground_effect_set> ground_effect_tool::getSelectedGroundEffect()
|
std::optional<ground_effect_set> ground_effect_tool::getSelectedGroundEffect()
|
||||||
@@ -1332,10 +1389,16 @@ namespace Noggit
|
|||||||
// TODO turn this into an array of elements
|
// TODO turn this into an array of elements
|
||||||
|
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
_button_effect_doodad[i]->setText(" -NONE- ");
|
{
|
||||||
else
|
// _button_effect_doodad[i]->setText(" -NONE- ");
|
||||||
_button_effect_doodad[i]->setText(filename);
|
_object_list->item(i)->setText(STRING_EMPTY_DISPLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// _button_effect_doodad[i]->setText(filename);
|
||||||
|
_object_list->item(i)->setText(filename);
|
||||||
|
}
|
||||||
updateDoodadPreviewRender(i);
|
updateDoodadPreviewRender(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ class World;
|
|||||||
class MapView;
|
class MapView;
|
||||||
class DBCFile::Record;
|
class DBCFile::Record;
|
||||||
|
|
||||||
|
inline constexpr const char* STRING_EMPTY_DISPLAY = "-NONE-";
|
||||||
|
|
||||||
namespace Noggit
|
namespace Noggit
|
||||||
{
|
{
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@@ -137,7 +139,7 @@ namespace Noggit
|
|||||||
|
|
||||||
void genEffectColors();
|
void genEffectColors();
|
||||||
|
|
||||||
int active_doodad_widget = 0;
|
// int active_doodad_widget = 0;
|
||||||
// std::unordered_map<unsigned int, int> _texture_effect_ids;
|
// std::unordered_map<unsigned int, int> _texture_effect_ids;
|
||||||
|
|
||||||
std::vector<ground_effect_set> _loaded_effects;
|
std::vector<ground_effect_set> _loaded_effects;
|
||||||
@@ -173,7 +175,7 @@ namespace Noggit
|
|||||||
|
|
||||||
// TODO create some nice UI for doodads
|
// TODO create some nice UI for doodads
|
||||||
QListWidget* _object_list; // for render previews
|
QListWidget* _object_list; // for render previews
|
||||||
QPushButton* _button_effect_doodad[4];
|
// QPushButton* _button_effect_doodad[4];
|
||||||
|
|
||||||
QSpinBox* _spinbox_doodads_amount;
|
QSpinBox* _spinbox_doodads_amount;
|
||||||
QComboBox* _cbbox_terrain_type;
|
QComboBox* _cbbox_terrain_type;
|
||||||
@@ -197,7 +199,7 @@ namespace Noggit
|
|||||||
, QWidget* parent = nullptr
|
, QWidget* parent = nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
~texturing_tool() { delete _ground_effect_tool; };
|
// ~texturing_tool() { _ground_effect_tool->deleteLater(); }; // { delete _ground_effect_tool; };
|
||||||
|
|
||||||
float brush_radius() const;
|
float brush_radius() const;
|
||||||
float hardness() const;
|
float hardness() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user