aboutsummaryrefslogtreecommitdiff
path: root/tools/ArtistTools/source/BlastPlugin/Window
diff options
context:
space:
mode:
authorAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
committerAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
commit236f03c0b9a4982328ed1201978f7f69d192d9b2 (patch)
treee486f2fa39dba203563895541e92c60ed3e25759 /tools/ArtistTools/source/BlastPlugin/Window
parentAdded screens to welcome page (diff)
downloadblast-236f03c0b9a4982328ed1201978f7f69d192d9b2.tar.xz
blast-236f03c0b9a4982328ed1201978f7f69d192d9b2.zip
Blast 1.1 release (windows / linux)
see docs/release_notes.txt for details
Diffstat (limited to 'tools/ArtistTools/source/BlastPlugin/Window')
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/BlastCompositePanel.cpp306
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/BlastCompositePanel.h59
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.cpp2386
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.h218
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.cpp743
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.h22
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.cpp153
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.h22
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.cpp520
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.h16
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.cpp668
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.h70
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureCutoutSettingsPanel.cpp155
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureCutoutSettingsPanel.h52
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.cpp276
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.h36
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureShellCutSettingsPanel.cpp40
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureShellCutSettingsPanel.h30
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.cpp189
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.h18
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.cpp57
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.h12
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.cpp340
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.h50
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.cpp252
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.h23
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.cpp171
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.cpp205
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.h8
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.cpp77
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.h17
-rw-r--r--tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.cpp14
32 files changed, 4661 insertions, 2544 deletions
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/BlastCompositePanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/BlastCompositePanel.cpp
deleted file mode 100644
index b42a4f5..0000000
--- a/tools/ArtistTools/source/BlastPlugin/Window/BlastCompositePanel.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-#include "BlastCompositePanel.h"
-#include "ui_BlastCompositePanel.h"
-#include "ProjectParams.h"
-#include <QtCore/QFileInfo>
-#include <QtWidgets/QInputDialog>
-#include <QtWidgets/QLineEdit>
-#include <QtWidgets/QMessageBox>
-
-BlastCompositePanel::BlastCompositePanel(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::BlastCompositePanel),
- _selectedAsset(-1)
-{
- ui->setupUi(this);
-
- ui->btnRemoveAsset->setEnabled(false);
- ui->btnModifyLandmark->setEnabled(false);
- ui->btnRemoveLandmark->setEnabled(false);
-}
-
-BlastCompositePanel::~BlastCompositePanel()
-{
- delete ui;
-}
-
-void BlastCompositePanel::updateValues()
-{
- BPParams& projectParams = BlastProject::ins().getParams();
- BPPComposite& composite = projectParams.blast.composite;
-
- ui->lineEditComposite->setText(composite.composite.buf);
-
- _updateAssetComboBox();
-
- _updateAssetInstanceListWidget();
-
- ui->spinBoxBondByThreshold->setValue(composite.bondThreshold);
- ui->spinBoxNewBondStrength->setValue(composite.bondStrength);
-
- _updateLandmarkListWidget();
-
- ui->checkBoxEnableLandmark->setChecked(false);
- ui->spinBoxLandmarkRadius->setValue(false);
-}
-
-void BlastCompositePanel::on_btnCollapse_clicked()
-{
-
-}
-
-void BlastCompositePanel::on_btnSave_clicked()
-{
- BPParams& projectParams = BlastProject::ins().getParams();
- BPPComposite& composite = projectParams.blast.composite;
-
- QByteArray tmp = ui->lineEditComposite->text().toUtf8();
- copy(composite.composite, tmp.data());
-}
-
-void BlastCompositePanel::on_comboBoxAsset_currentIndexChanged(int index)
-{
- _selectedAsset = index;
-}
-
-void BlastCompositePanel::on_btnAddAsset_clicked()
-{
- bool ok = false;
- QString name = QInputDialog::getText(this,
- tr("Blast Tool"),
- tr("Please input name for new blast instance:"),
- QLineEdit::Normal,
- "",
- &ok);
- bool nameExist = BlastProject::ins().isAssetInstanceNameExist(name.toUtf8().data());
- if (ok && !name.isEmpty() && !nameExist)
- {
- BlastProject::ins().addAssetInstance(_selectedAsset, name.toUtf8().data());
- _updateAssetInstanceListWidget();
- ui->listWidgetBlastAsset->setCurrentRow(ui->listWidgetBlastAsset->count() - 1);
- }
- else if (ok && nameExist)
- {
- QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!");
- }
- else if (ok && name.isEmpty())
- {
- QMessageBox::warning(this, "Blast Tool", "You need input a name for the new preset!");
- }
-}
-
-void BlastCompositePanel::on_btnRemoveAsset_clicked()
-{
- QList<QListWidgetItem*> items = ui->listWidgetBlastAsset->selectedItems();
- BlastProject::ins().removeAssetInstance(items.at(0)->text().toUtf8().data());
-}
-
-void BlastCompositePanel::on_listWidgetBlastAsset_itemSelectionChanged()
-{
- QList<QListWidgetItem*> items = ui->listWidgetBlastAsset->selectedItems();
- if (items.count() > 0)
- ui->btnRemoveAsset->setEnabled(true);
- else
- ui->btnRemoveAsset->setEnabled(false);
-}
-
-void BlastCompositePanel::on_spinBoxBondByThreshold_valueChanged(double arg1)
-{
- BPParams& projectParams = BlastProject::ins().getParams();
- BPPComposite& composite = projectParams.blast.composite;
- composite.bondThreshold = arg1;
-}
-
-void BlastCompositePanel::on_spinBoxNewBondStrength_valueChanged(double arg1)
-{
- BPParams& projectParams = BlastProject::ins().getParams();
- BPPComposite& composite = projectParams.blast.composite;
- composite.bondStrength = arg1;
-}
-
-void BlastCompositePanel::on_btnAddLandmark_clicked()
-{
- bool ok = false;
- QString name = QInputDialog::getText(this,
- tr("Blast Tool"),
- tr("Please input name for new landmark:"),
- QLineEdit::Normal,
- "",
- &ok);
- bool nameExist = BlastProject::ins().isLandmarkNameExist(name.toUtf8().data());
- if (ok && !name.isEmpty() && !nameExist)
- {
- BlastProject::ins().addLandmark(name.toUtf8().data());
- _updateLandmarkListWidget();
- ui->listWidgetLandmark->setCurrentRow(ui->listWidgetLandmark->count() - 1);
- }
- else if (ok && nameExist)
- {
- QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!");
- }
- else if (ok && name.isEmpty())
- {
- QMessageBox::warning(this, "Blast Tool", "You need input a name for the new landmark!");
- }
-}
-
-void BlastCompositePanel::on_btnModifyLandmark_clicked()
-{
- QList<QListWidgetItem*> items = ui->listWidgetLandmark->selectedItems();
- QByteArray tem = items.at(0)->text().toUtf8();
- const char* oldName = tem.data();
-
- bool ok = false;
- QString newName = QInputDialog::getText(this,
- tr("Blast Tool"),
- tr("Please input new name for the selected landmark:"),
- QLineEdit::Normal,
- oldName,
- &ok);
- bool nameExist = BlastProject::ins().isLandmarkNameExist(newName.toUtf8().data());
- if (ok && !newName.isEmpty() && !nameExist)
- {
- int selectIndex = ui->listWidgetLandmark->currentRow();
- BlastProject::ins().renameLandmark(oldName, newName.toUtf8().data());
- _updateLandmarkListWidget();
- ui->listWidgetLandmark->setCurrentRow(selectIndex);
- }
- else if (ok && nameExist)
- {
- QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!");
- }
- else if (ok && newName.isEmpty())
- {
- QMessageBox::warning(this, "Blast Tool", "You need input a name for the new landmark!");
- }
-}
-
-void BlastCompositePanel::on_btnRemoveLandmark_clicked()
-{
- QList<QListWidgetItem*> items = ui->listWidgetLandmark->selectedItems();
- QByteArray tem = items.at(0)->text().toUtf8();
- const char* name = tem.data();
- BlastProject::ins().removeLandmark(name);
- _updateLandmarkListWidget();
-}
-
-void BlastCompositePanel::on_listWidgetLandmark_itemSelectionChanged()
-{
- _updateLandmarkUIs();
-}
-
-void BlastCompositePanel::on_checkBoxEnableLandmark_stateChanged(int arg1)
-{
- QList<QListWidgetItem*> items = ui->listWidgetLandmark->selectedItems();
-
- int count = items.count();
- for (int i = 0; i < count; ++i)
- {
- BPPLandmark* landmark = BlastProject::ins().getLandmark(items.at(0)->text().toUtf8().data());
- if (landmark != nullptr)
- {
- landmark->enable = ui->checkBoxEnableLandmark->isChecked();
- }
- }
-}
-
-void BlastCompositePanel::on_spinBoxLandmarkRadius_valueChanged(double arg1)
-{
- QList<QListWidgetItem*> items = ui->listWidgetLandmark->selectedItems();
-
- int count = items.count();
- for (int i = 0; i < count; ++i)
- {
- BPPLandmark* landmark = BlastProject::ins().getLandmark(items.at(0)->text().toUtf8().data());
- if (landmark != nullptr)
- {
- landmark->radius = ui->spinBoxLandmarkRadius->value();
- }
- }
-}
-
-void BlastCompositePanel::_updateAssetComboBox()
-{
- BPParams& projectParams = BlastProject::ins().getParams();
- BPPAssetArray& blastAssetArray = projectParams.blast.blastAssets;
- BPPComposite& composite = projectParams.blast.composite;
-
- ui->comboBoxAsset->clear();
- int countAssets = blastAssetArray.arraySizes[0];
- if (countAssets > 0)
- {
- QStringList assets;
- for (int i = 0; i < countAssets; ++i)
- {
- QFileInfo fileInfo(blastAssetArray.buf[i].path.buf);
- assets.append(fileInfo.baseName());
- }
- ui->comboBoxAsset->addItems(assets);
- }
- else
- {
- ui->btnAddAsset->setEnabled(false);
- ui->btnRemoveAsset->setEnabled(false);
- }
-}
-
-void BlastCompositePanel::_updateAssetInstanceListWidget()
-{
- BPParams& projectParams = BlastProject::ins().getParams();
- BPPComposite& composite = projectParams.blast.composite;
-
- ui->listWidgetBlastAsset->clear();
- int countAssetInstances = composite.blastAssetInstances.arraySizes[0];
- if (countAssetInstances > 0)
- {
- QStringList assetInstances;
-
- for (int i = 0; i < countAssetInstances; ++i)
- {
- assetInstances.append(composite.blastAssetInstances.buf[i].name.buf);
- }
- ui->listWidgetBlastAsset->addItems(assetInstances);
- }
-}
-
-void BlastCompositePanel::_updateLandmarkListWidget()
-{
- BPParams& projectParams = BlastProject::ins().getParams();
- BPPComposite& composite = projectParams.blast.composite;
-
- ui->listWidgetLandmark->clear();
- int countJoints = composite.landmarks.arraySizes[0];
- if (countJoints > 0)
- {
- QStringList landmarks;
-
- for (int i = 0; i < countJoints; ++i)
- {
- landmarks.append(composite.landmarks.buf[i].name.buf);
- }
- ui->listWidgetLandmark->addItems(landmarks);
- }
-}
-
-void BlastCompositePanel::_updateLandmarkUIs()
-{
- QList<QListWidgetItem*> items = ui->listWidgetLandmark->selectedItems();
-
- if (items.count() > 0)
- {
- BPPLandmark* landmark = BlastProject::ins().getLandmark(items.at(0)->text().toUtf8().data());
- if (landmark != nullptr)
- {
- ui->btnModifyLandmark->setEnabled(true);
- ui->btnRemoveLandmark->setEnabled(true);
- ui->checkBoxEnableLandmark->setChecked(landmark->enable);
- ui->spinBoxLandmarkRadius->setValue(landmark->radius);
- }
- }
- else
- {
- ui->btnModifyLandmark->setEnabled(false);
- ui->btnRemoveLandmark->setEnabled(false);
- ui->checkBoxEnableLandmark->setChecked(false);
- ui->spinBoxLandmarkRadius->setValue(0.0f);
- }
-}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/BlastCompositePanel.h b/tools/ArtistTools/source/BlastPlugin/Window/BlastCompositePanel.h
deleted file mode 100644
index b4e5bcf..0000000
--- a/tools/ArtistTools/source/BlastPlugin/Window/BlastCompositePanel.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef BLASTCOMPOSITEPANEL_H
-#define BLASTCOMPOSITEPANEL_H
-
-#include <QtWidgets/QWidget>
-
-namespace Ui {
-class BlastCompositePanel;
-}
-
-class BlastCompositePanel : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit BlastCompositePanel(QWidget *parent = 0);
- ~BlastCompositePanel();
- void updateValues();
-
-private slots:
- void on_btnCollapse_clicked();
-
- void on_btnSave_clicked();
-
- void on_comboBoxAsset_currentIndexChanged(int index);
-
- void on_btnAddAsset_clicked();
-
- void on_btnRemoveAsset_clicked();
-
- void on_listWidgetBlastAsset_itemSelectionChanged();
-
- void on_spinBoxBondByThreshold_valueChanged(double arg1);
-
- void on_spinBoxNewBondStrength_valueChanged(double arg1);
-
- void on_btnAddLandmark_clicked();
-
- void on_btnModifyLandmark_clicked();
-
- void on_btnRemoveLandmark_clicked();
-
- void on_listWidgetLandmark_itemSelectionChanged();
-
- void on_checkBoxEnableLandmark_stateChanged(int arg1);
-
- void on_spinBoxLandmarkRadius_valueChanged(double arg1);
-
-private:
- void _updateAssetComboBox();
- void _updateAssetInstanceListWidget();
- void _updateLandmarkListWidget();
- void _updateLandmarkUIs();
-
-private:
- Ui::BlastCompositePanel *ui;
- int _selectedAsset;
-};
-
-#endif // BLASTCOMPOSITEPANEL_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.cpp b/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.cpp
index a6cdf64..ab0ca85 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.cpp
@@ -4,18 +4,50 @@
#include <QtWidgets/QPushButton>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QMenu>
+#include <QtWidgets/QShortcut>
#include <QtCore/QFileInfo>
+#include <QtGui/qevent.h>
+#include <QtGui/QPainter>
#include <assert.h>
#include "ProjectParams.h"
#include <SimpleScene.h>
#include <BlastController.h>
+#include "SelectionToolController.h"
+#include "GizmoToolController.h"
#include <SceneController.h>
#include <NvBlastExtPxAsset.h>
#include <NvBlastTkAsset.h>
#include <NvBlastAsset.h>
#include <BlastFamilyModelSimple.h>
#include "GlobalSettings.h"
+#include <deque>
+#include "ViewerOutput.h"
+static QIcon sCompositeIcon;
+static QIcon sAssetIcon;
+static QIcon sChunkUUIcon;
+static QIcon sChunkSUIcon;
+static QIcon sChunkSSIcon;
+static QIcon sBondIcon;
+static QIcon sProjectileIcon;
+
+static QPixmap sVisibleIcon = QPixmap(":/AppMainWindow/images/visibilityToggle_visible.png").scaled(QSize(24, 24), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+static QPixmap sInVisibleIcon = QPixmap(":/AppMainWindow/images/visibilityToggle_notVisible.png").scaled(QSize(24, 24), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+
+class BlastSceneTreeDataLock
+{
+public:
+ BlastSceneTreeDataLock()
+ {
+ BlastSceneTree::ins()->_updateData = false;
+ }
+ ~BlastSceneTreeDataLock()
+ {
+ BlastSceneTree::ins()->_updateData = true;
+ }
+};
+
+#if 0
bool isChunkVisible(std::vector<BlastFamily*>& fs, uint32_t chunkIndex)
{
int fsSize = fs.size();
@@ -35,6 +67,7 @@ bool isChunkVisible(std::vector<BlastFamily*>& fs, uint32_t chunkIndex)
}
return visible;
}
+#endif
void setChunkVisible(std::vector<BlastFamily*>& fs, uint32_t chunkIndex, bool visible)
{
@@ -60,13 +93,28 @@ void setChunkSelected(std::vector<BlastFamily*>& fs, uint32_t chunkIndex, bool s
for (int i = 0; i < fsSize; i++)
{
- fs[i]->setChunkSelected(chunkIndex, selected);
+ BlastFamily* bf = fs[i];
+ if(bf)
+ bf->setChunkSelected(chunkIndex, selected);
+ }
+}
+
+void BlastNode::traverse(BlastVisitorBase& visitor)
+{
+ visitor.visit(this);
+
+ for (BlastNode* node : children)
+ {
+ if (!visitor.continueTraversing())
+ break;
+
+ node->traverse(visitor);
}
}
void BlastChunkNode::setVisible(bool val)
{
- BPPChunk* pBPPChunk = (BPPChunk*)_data;
+ BPPChunk* pBPPChunk = (BPPChunk*)getData();
pBPPChunk->visible = val;
BlastAsset* pBlastAsset = (BlastAsset*)_assetPtr;
@@ -74,32 +122,88 @@ void BlastChunkNode::setVisible(bool val)
SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager();
std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = sampleManager.getAssetFamiliesMap();
- std::vector<BlastFamily*>& fs = AssetFamiliesMap[pBlastAsset];
+ std::map<BlastAsset*, std::vector<BlastFamily*>>::iterator it = AssetFamiliesMap.find(pBlastAsset);
+ if (it == AssetFamiliesMap.end())
+ {
+ return;
+ }
+ std::vector<BlastFamily*>& fs = it->second;
setChunkVisible(fs, pBPPChunk->ID, val);
}
void BlastChunkNode::setSelected(bool val)
{
- BPPChunk* pBPPChunk = (BPPChunk*)_data;
- pBPPChunk->visible = val;
+ BPPChunk* pBPPChunk = (BPPChunk*)getData();
BlastAsset* pBlastAsset = (BlastAsset*)_assetPtr;
SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager();
std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = sampleManager.getAssetFamiliesMap();
- std::vector<BlastFamily*>& fs = AssetFamiliesMap[pBlastAsset];
+ std::map<BlastAsset*, std::vector<BlastFamily*>>::iterator it = AssetFamiliesMap.find(pBlastAsset);
+ if (it == AssetFamiliesMap.end())
+ {
+ return;
+ }
+ std::vector<BlastFamily*>& fs = it->second;
setChunkSelected(fs, pBPPChunk->ID, val);
}
+void BlastAssetNode::setSelected(bool val)
+{
+ BPPAsset* pBPPAsset = (BPPAsset*)getData();
+ std::string strAsset = pBPPAsset->name.buf;
+
+ BlastAsset* pBlastAsset = nullptr;
+ SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager();
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = sampleManager.getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itAssetDescMap;
+ for (itAssetDescMap = AssetDescMap.begin();
+ itAssetDescMap != AssetDescMap.end(); itAssetDescMap++)
+ {
+ AssetList::ModelAsset& model = itAssetDescMap->second;
+ if (model.name == strAsset)
+ {
+ pBlastAsset = itAssetDescMap->first;
+ break;
+ }
+ }
+
+ sampleManager.setCurrentSelectedInstance(pBlastAsset, -1);
+
+ std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = sampleManager.getAssetFamiliesMap();
+ std::map<BlastAsset*, std::vector<BlastFamily*>>::iterator itAFM = AssetFamiliesMap.find(pBlastAsset);
+ if (itAFM == AssetFamiliesMap.end())
+ {
+ return;
+ }
+ std::vector<BlastFamily*>& fs = itAFM->second;
+ for (BlastFamily* pBlastFamily : fs)
+ {
+ pBlastFamily->highlightChunks();
+ }
+}
+
+bool BlastProjectileNode::getVisible()
+{
+ return SampleManager::ins()->getSceneController().getProjectileVisible((PhysXSceneActor*)getData());
+}
+
+void BlastProjectileNode::setVisible(bool val)
+{
+ SampleManager::ins()->getSceneController().setProjectileVisible((PhysXSceneActor*)getData(), val);
+}
+
void BlastAssetInstanceNode::setSelected(bool val)
{
- BPPAssetInstance* pBPPAssetInstance = (BPPAssetInstance*)_data;
- std::string name = pBPPAssetInstance->name;
+ BPPAssetInstance* pBPPAssetInstance = (BPPAssetInstance*)getData();
+ if (pBPPAssetInstance == nullptr)
+ return;
+ std::string name = pBPPAssetInstance->name.buf;
- std::string strAsset = name.substr(0, name.find_first_of("_"));
+ std::string strAsset = name.substr(0, name.find_last_of("_"));
BlastAsset* pBlastAsset = nullptr;
SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager();
std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = sampleManager.getAssetDescMap();
@@ -119,6 +223,9 @@ void BlastAssetInstanceNode::setSelected(bool val)
int nIndex = atoi(strIndex.c_str());
sampleManager.setCurrentSelectedInstance(pBlastAsset, nIndex);
+
+ std::vector<BlastFamily*> fs = { SampleManager::ins()->getFamilyByInstance(pBPPAssetInstance) };
+ setChunkSelected(fs, 0, val);
}
BlastTreeData& BlastTreeData::ins()
@@ -152,7 +259,7 @@ std::vector<BlastChunkNode*> BlastTreeData::getTopChunkNodes(std::vector<BlastCh
bool isCurNodeTop = true;
for (size_t j = 0; j < nodes.size(); ++j)
{
- if (i != j && isChild(nodes[i], nodes[j]))
+ if (i != j && isChild(nodes[j], nodes[i]))
{
isCurNodeTop = false;
break;
@@ -168,6 +275,18 @@ std::vector<BlastChunkNode*> BlastTreeData::getTopChunkNodes(std::vector<BlastCh
return result;
}
+int BlastTreeData::getDepth(BlastNode* node)
+{
+ int depth = -1; // here it's from -1 because it traverse from Blast asset node
+ while (nullptr != node && (eBond == node->getType() || eChunk == node->getType()))
+ {
+ ++depth;
+ node = node->getParent();
+ }
+
+ return depth;
+}
+
bool BlastTreeData::isRoot(BlastChunkNode* node)
{
if (node == nullptr || node->getParent() == nullptr)
@@ -197,6 +316,7 @@ void removeChunkNodeSupport(BlastChunkNode* node)
BPPChunk* chunk = static_cast<BPPChunk*>(node->getData());
chunk->support = false;
+ chunk->staticFlag = false;
for (BlastNode* curNode : node->children)
{
@@ -207,14 +327,72 @@ void removeChunkNodeSupport(BlastChunkNode* node)
}
}
+void setAncestorSupportFlag(BlastChunkNode* ancestor, BlastChunkNode* startChild)
+{
+ if (nullptr == ancestor || nullptr == startChild)
+ return;
+
+ {
+ BPPChunk* bppChunk = (BPPChunk*)(ancestor->getData());
+ bppChunk->support = false;
+ bppChunk->staticFlag = false;
+ }
+
+ std::deque<BlastChunkNode*> ancestors;
+ for (BlastNode* node : ancestor->children)
+ {
+ if (eChunk == node->getType())
+ {
+ ancestors.push_back(static_cast<BlastChunkNode*>(node));
+ }
+ }
+
+ while (ancestors.size() > 0)
+ {
+ BlastChunkNode* curAncestor = ancestors.front();
+ ancestors.pop_front();
+
+ bool isChild = BlastTreeData::isChild(curAncestor, startChild);
+ if (isChild)
+ {
+ if (curAncestor != startChild)
+ {
+ for (BlastNode* node : curAncestor->children)
+ {
+ if (eChunk == node->getType())
+ {
+ ancestors.push_back(static_cast<BlastChunkNode*>(node));
+ }
+ }
+ }
+ }
+ else
+ {
+ BPPChunk* bppChunk = (BPPChunk*)(curAncestor->getData());
+ bppChunk->support = true;
+ bppChunk->staticFlag = false;
+ }
+ }
+}
+
void BlastTreeData::makeSupport(BlastChunkNode* node)
{
if (node == nullptr)
return;
+
+ // 1 set flag for current node
BPPChunk* chunk = static_cast<BPPChunk*>(node->getData());
chunk->staticFlag = false;
chunk->support = true;
+ // 2 set flag for ancestors
+ BlastChunkNode* supportAncestor = ins().getSupportAncestor(node);
+ if (supportAncestor)
+ {
+ setAncestorSupportFlag(supportAncestor, node);
+ }
+
+ // 3 set flag for children
for (BlastNode* curNode : node->children)
{
if (eChunk == curNode->getType())
@@ -228,10 +406,20 @@ void BlastTreeData::makeStaticSupport(BlastChunkNode* node)
{
if (node == nullptr)
return;
+
+ // 1 set flag for current node
BPPChunk* chunk = static_cast<BPPChunk*>(node->getData());
chunk->staticFlag = true;
chunk->support = true;
+ // 2 set flag for ancestors
+ BlastChunkNode* supportAncestor = ins().getSupportAncestor(node);
+ if (supportAncestor)
+ {
+ setAncestorSupportFlag(supportAncestor, node);
+ }
+
+ // 3 set flag for children
for (BlastNode* curNode : node->children)
{
if (eChunk == curNode->getType())
@@ -259,8 +447,37 @@ void BlastTreeData::removeSupport(BlastChunkNode* node)
{
BPPChunk* curChunk = static_cast<BPPChunk*>(curNode->getData());
curChunk->support = true;
+ curChunk->staticFlag = false;
+ }
+ }
+}
+
+std::string BlastTreeData::getAssetName(BlastAsset* asset)
+{
+ std::map<BlastAsset*, AssetList::ModelAsset>& assetDescMap = SampleManager::ins()->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itrAssetDesc = assetDescMap.find(asset);
+
+ if (itrAssetDesc != assetDescMap.end())
+ {
+ return itrAssetDesc->second.name;
+ }
+
+ return "";
+}
+
+BlastAsset* BlastTreeData::getAsset(std::string assetName)
+{
+ std::map<BlastAsset*, AssetList::ModelAsset>& assetDescMap = SampleManager::ins()->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itrAssetDesc = assetDescMap.begin();
+ for (; itrAssetDesc != assetDescMap.end(); ++itrAssetDesc)
+ {
+ if (itrAssetDesc->second.name == assetName)
+ {
+ return itrAssetDesc->first;
}
}
+
+ return nullptr;
}
BlastNode* BlastTreeData::getBlastNodeByProjectData(void* data)
@@ -328,6 +545,53 @@ void BlastTreeData::remove(const BlastAssetInstanceNode* node)
//to do
}
+BlastAssetInstanceNode* BlastTreeData::getAssetInstanceNode(BlastFamily* family)
+{
+ BPPAssetInstance* instance = SampleManager::ins()->getInstanceByFamily(family);
+ return getAssetInstanceNode(instance);
+}
+
+BlastAssetInstanceNode* BlastTreeData::getAssetInstanceNode(BPPAssetInstance* instance)
+{
+ if (nullptr == instance)
+ return nullptr;
+
+ for (BlastNode* node : _assetInstancesNode->children)
+ {
+ if ((BPPAssetInstance*)(node->getData()) == instance)
+ {
+ return (BlastAssetInstanceNode*)node;
+ }
+ }
+
+ return nullptr;
+}
+
+std::vector<BlastAssetInstanceNode*> BlastTreeData::getAssetInstanceNodes(BlastChunkNode* chunkNode)
+{
+ std::vector<BlastAssetInstanceNode*> instanceNodes;
+
+ if (nullptr == chunkNode)
+ return instanceNodes;
+
+ BlastAsset* asset = getAsset(chunkNode);
+
+ if (isRoot(chunkNode))
+ {
+ BPPAssetInstance* instance = (BPPAssetInstance*)(chunkNode->getData());
+
+ for (BlastNode* instanceNode : _assetInstancesNode->children)
+ {
+ BPPAssetInstance* instance = (BPPAssetInstance*)(instanceNode->getData());
+ BlastFamily* family = SampleManager::ins()->getFamilyByInstance(instance);
+ if (&(family->getBlastAsset()) == asset)
+ instanceNodes.push_back((BlastAssetInstanceNode*)instanceNode);
+ }
+ }
+
+ return instanceNodes;
+}
+
void BlastTreeData::update()
{
_freeBlastNode();
@@ -352,269 +616,20 @@ void BlastTreeData::update()
BlastAssetVec.push_back(it->first);
}
int modelAssetsSize = AssetDescMap.size();
-
- std::vector<std::string> projectilesNames;
- sceneController.GetProjectilesNames(projectilesNames);
-
- // compoistie
- {
- BPPComposite& composite = blast.composite;
- composite.composite.buf = nullptr;
- composite.visible = true;
- copy(composite.composite, "BlastComposite");
-
- // asset instance array
- {
- BPPAssetInstanceArray& instanceArray = composite.blastAssetInstances;
- instanceArray.arraySizes[0] = familiesSize;
- if (familiesSize > 0)
- {
- instanceArray.buf = new BPPAssetInstance[familiesSize];
- int curInstanceIndex = 0;
- char instancename[MAX_PATH];
- std::map<BlastAsset*, std::vector<BlastFamily*>>::iterator itAssetFamiliesMap;
- for (itAssetFamiliesMap = AssetFamiliesMap.begin();
- itAssetFamiliesMap != AssetFamiliesMap.end(); itAssetFamiliesMap++)
- {
- BlastAsset* pBlastAsset = itAssetFamiliesMap->first;
- std::vector<BlastFamily*>& fs = itAssetFamiliesMap->second;
- int fsSize = fs.size();
- for (int i = 0; i < fsSize; i++)
- {
- BPPAssetInstance& instance = instanceArray.buf[curInstanceIndex];
- instance.name.buf = nullptr;
- instance.source.buf = nullptr;
- instance.visible = true;
-
- AssetList::ModelAsset desc = AssetDescMap[pBlastAsset];
- sprintf(instancename, "%s_Instance_%d", desc.name.c_str(), i);
- copy(instance.name, instancename);
-
- std::string assetFilePath = GlobalSettings::MakeFileName(GlobalSettings::Inst().m_projectFileDir.c_str(), std::string(desc.file + ".bpxa").c_str());
- sprintf(instancename, "%s", assetFilePath.c_str());
- copy(instance.source, instancename);
-
- PxVec3 p = desc.transform.p;
- PxQuat q = desc.transform.q;
- instanceArray.buf[curInstanceIndex].transform.position = nvidia::NvVec3(p.x, p.y, p.z);
- instanceArray.buf[curInstanceIndex].transform.rotation = nvidia::NvVec4(q.x, q.y, q.z, q.w);
-
- curInstanceIndex++;
- }
- }
- }
- }
-
- // landmark array
- if (0)
- {
- BPPLandmarkArray& landmarkArray = composite.landmarks;
- landmarkArray.buf = new BPPLandmark[2];
- landmarkArray.arraySizes[0] = 2;
- landmarkArray.buf[0].name.buf = nullptr;
- landmarkArray.buf[1].name.buf = nullptr;
-
- copy(landmarkArray.buf[0].name, "Landmark_1");
- copy(landmarkArray.buf[1].name, "Landmark_2");
- }
- }
-
- // asset array
- {
- BPPAssetArray& assetArray = blast.blastAssets;
- assetArray.arraySizes[0] = modelAssetsSize;
- if (modelAssetsSize > 0)
- {
- assetArray.buf = new BPPAsset[modelAssetsSize];
- int curAssetIndex = 0;
-
- blast.chunks.buf = nullptr;
- blast.chunks.arraySizes[0] = 0;
- blast.bonds.buf = nullptr;
- blast.bonds.arraySizes[0] = 0;
-
- std::map<BlastAsset*, AssetList::ModelAsset>::iterator itAssetDescMap;
- for (itAssetDescMap = AssetDescMap.begin();
- itAssetDescMap != AssetDescMap.end(); itAssetDescMap++)
- {
- BlastAsset* pBlastAsset = itAssetDescMap->first;
- AssetList::ModelAsset& desc = itAssetDescMap->second;
- std::vector<BlastFamily*>& fs = AssetFamiliesMap[pBlastAsset];
-
- BPPAsset& asset = assetArray.buf[curAssetIndex];
- asset.path.buf = nullptr;
- asset.activePreset.buf = nullptr;
- std::string assetFilePath = GlobalSettings::MakeFileName(GlobalSettings::Inst().m_projectFileDir.c_str(), std::string(desc.file + ".bpxa").c_str());
- copy(asset.path, assetFilePath.c_str());
-
- const ExtPxAsset* pExtPxAsset = pBlastAsset->getPxAsset();
- const ExtPxChunk* pExtPxChunk = pExtPxAsset->getChunks();
-
- const TkAsset& tkAsset = pExtPxAsset->getTkAsset();
- uint32_t chunkCount = tkAsset.getChunkCount();
- const NvBlastChunk* pNvBlastChunk = tkAsset.getChunks();
- uint32_t bondCount = tkAsset.getBondCount();
- const NvBlastBond* pNvBlastBond = tkAsset.getBonds();
-
- const NvBlastSupportGraph supportGraph = tkAsset.getGraph();
- uint32_t* chunkIndices = supportGraph.chunkIndices;
- uint32_t* adjacencyPartition = supportGraph.adjacencyPartition;
- uint32_t* adjacentNodeIndices = supportGraph.adjacentNodeIndices;
- uint32_t* adjacentBondIndices = supportGraph.adjacentBondIndices;
-
- ChunkSupport* pSupport = new ChunkSupport[chunkCount];
- BondChunkIndices* pBCIndices = new BondChunkIndices[bondCount];
-
- for (uint32_t node0 = 0; node0 < supportGraph.nodeCount; ++node0)
- {
- const uint32_t chunkIndex0 = supportGraph.chunkIndices[node0];
-
- pSupport[chunkIndex0].m_bSupport = true;
-
- for (uint32_t adjacencyIndex = adjacencyPartition[node0]; adjacencyIndex < adjacencyPartition[node0 + 1]; adjacencyIndex++)
- {
- uint32_t node1 = supportGraph.adjacentNodeIndices[adjacencyIndex];
-
- // add this condition if you don't want to iterate all bonds twice
- if (node0 > node1)
- continue;
-
- const uint32_t chunkIndex1 = supportGraph.chunkIndices[node1];
-
- uint32_t bondIndex = supportGraph.adjacentBondIndices[adjacencyIndex];
-
- pBCIndices[bondIndex].SetIndices(chunkIndex0, chunkIndex1);
- }
- }
-
- // chunks
- {
- BPPChunkArray curArray;
- curArray.buf = new BPPChunk[chunkCount];
- curArray.arraySizes[0] = chunkCount;
- char chunkname[10];
- for (int cc = 0; cc < chunkCount; ++cc)
- {
- BPPChunk& chunk = curArray.buf[cc];
- chunk.name.buf = nullptr;
- chunk.asset.buf = nullptr;
-
- std::vector<uint32_t> parentChunkIndexes;
- parentChunkIndexes.push_back(cc);
- uint32_t parentChunkIndex = cc;
- while ((parentChunkIndex = pNvBlastChunk[parentChunkIndex].parentChunkIndex) != -1)
- {
- parentChunkIndexes.push_back(parentChunkIndex);
- }
-
- std::string strChunkName = "Chunk";
- for (int pcIndex = parentChunkIndexes.size() - 1; pcIndex >= 0; pcIndex--)
- {
- sprintf(chunkname, "_%d", parentChunkIndexes[pcIndex]);
- strChunkName += chunkname;
- }
- copy(chunk.name, strChunkName.c_str());
-
- copy(chunk.asset, asset.path);
- chunk.ID = cc;
- chunk.parentID = pNvBlastChunk[cc].parentChunkIndex;
- chunk.staticFlag = pExtPxChunk[cc].isStatic;
- chunk.visible = isChunkVisible(fs, cc);
- chunk.support = pSupport[cc].m_bSupport;
- }
-
- merge(blast.chunks, curArray);
- freeBlast(curArray);
- }
-
- // bonds
- {
- BPPBondArray curArray;
- curArray.buf = new BPPBond[bondCount];
- curArray.arraySizes[0] = bondCount;
- char bondname[10];
- bool visible;
- for (int bc = 0; bc < bondCount; ++bc)
- {
- BPPBond& bond = curArray.buf[bc];
- bond.name.buf = nullptr;
- bond.asset.buf = nullptr;
-
- visible = isChunkVisible(fs, pBCIndices[bc].chunkIndices[0])
- || isChunkVisible(fs, pBCIndices[bc].chunkIndices[1]);
- bond.visible = visible;
- bond.fromChunk = pBCIndices[bc].chunkIndices[0];
- bond.toChunk = pBCIndices[bc].chunkIndices[1];
-
- sprintf(bondname, "Bond_%d_%d", bond.fromChunk, bond.toChunk);
- copy(bond.name, bondname);
- copy(bond.asset, asset.path);
-
- bond.support.healthMask.buf = nullptr;
- bond.support.bondStrength = 1.0;
- bond.support.enableJoint = false;
- }
-
- merge(blast.bonds, curArray);
- freeBlast(curArray);
- }
-
- delete[] pSupport;
- pSupport = nullptr;
- delete[] pBCIndices;
- pBCIndices = nullptr;
-
- curAssetIndex++;
- }
- }
- }
-
- // projectile
- {
- BPPProjectileArray& projectileArray = blast.projectiles;
- int BPPProjectileSize = projectilesNames.size();
- projectileArray.arraySizes[0] = BPPProjectileSize;
- if (BPPProjectileSize > 0)
- {
- projectileArray.buf = new BPPProjectile[BPPProjectileSize];
- for (int i = 0; i < BPPProjectileSize; i++)
- {
- projectileArray.buf[i].name.buf = nullptr;
- copy(projectileArray.buf[i].name, projectilesNames[i].c_str());
- projectileArray.buf[i].visible = true;
- }
- }
- }
-
- // graphics meshes
- if (0)
- {
- BPPGraphicsMeshArray& graphicsMeshArray = blast.graphicsMeshes;
- graphicsMeshArray.buf = new BPPGraphicsMesh[3];
- graphicsMeshArray.arraySizes[0] = 3;
- graphicsMeshArray.buf[0].name.buf = nullptr;
- copy(graphicsMeshArray.buf[0].name, "SurfaceMesh1");
- graphicsMeshArray.buf[0].visible = true;
-
- graphicsMeshArray.buf[1].name.buf = nullptr;
- copy(graphicsMeshArray.buf[1].name, "SurfaceMesh2");
- graphicsMeshArray.buf[1].visible = true;
-
- graphicsMeshArray.buf[2].name.buf = nullptr;
- copy(graphicsMeshArray.buf[2].name, "DisplayMesh1");
- graphicsMeshArray.buf[2].visible = true;
- }
}
BPPAssetArray& assetArray = blast.blastAssets;
int count = assetArray.arraySizes[0];
+ if (BlastAssetVec.size() != count)
+ {
+ return;
+ }
for (int c = 0; c < count; ++c)
{
BPPAsset& asset = assetArray.buf[c];
- QFileInfo fileInfo(asset.path.buf);
- BlastAssetNode* assetNode = new BlastAssetNode(fileInfo.baseName().toUtf8().data(), asset);
+ BlastAssetNode* assetNode = new BlastAssetNode(asset.name.buf, asset);
_assets.push_back(assetNode);
_blastProjectDataToNodeMap.insert(std::make_pair((void*)&asset, assetNode));
@@ -632,53 +647,41 @@ void BlastTreeData::update()
}
}
- BPPComposite& composite = blast.composite;
- _composite = new BlastCompositeNode(composite.composite.buf, composite);
- _blastProjectDataToNodeMap.insert(std::make_pair((void*)&composite, _composite));
- BPPAssetInstanceArray& assetInstanceArray = composite.blastAssetInstances;
+ _assetInstancesNode = new BlastAssetInstancesNode("BlastAssetInstances");
+ _blastProjectDataToNodeMap.insert(std::make_pair(nullptr, _assetInstancesNode));
+ BPPAssetInstanceArray& assetInstanceArray = blast.blastAssetInstances;
count = assetInstanceArray.arraySizes[0];
for (int i = 0; i < count; ++i)
{
- BPPAssetInstance& blastAssetInstance = composite.blastAssetInstances.buf[i];
+ BPPAssetInstance& blastAssetInstance = assetInstanceArray.buf[i];
BlastAssetInstanceNode* blastAssetInstanceNode = new BlastAssetInstanceNode(blastAssetInstance.name.buf, blastAssetInstance);
- _composite->children.push_back(blastAssetInstanceNode);
- blastAssetInstanceNode->setParent(_composite);
+ _assetInstancesNode->children.push_back(blastAssetInstanceNode);
+ blastAssetInstanceNode->setParent(_assetInstancesNode);
_blastProjectDataToNodeMap.insert(std::make_pair((void*)&blastAssetInstance, blastAssetInstanceNode));
}
- BPPLandmarkArray& landmarkArray = composite.landmarks;
- count = landmarkArray.arraySizes[0];
- for (int i = 0; i < count; ++i)
- {
- BPPLandmark& landmark = composite.landmarks.buf[i];
- BlastLandmarkNode* landmarkNode = new BlastLandmarkNode(landmark.name.buf, landmark);
- _composite->children.push_back(landmarkNode);
- landmarkNode->setParent(_composite);
- _blastProjectDataToNodeMap.insert(std::make_pair((void*)&landmark, landmarkNode));
- }
-
- BPPProjectileArray& projectileArray = blast.projectiles;
- count = projectileArray.arraySizes[0];
- for (int i = 0; i < count; ++i)
+ SceneController& sceneController = SampleManager::ins()->getSceneController();
+ std::vector<PhysXSceneActor*> projectiles = sceneController.getPrejectiles();
+ for (PhysXSceneActor* projectile : projectiles)
{
- BPPProjectile& projectile = projectileArray.buf[i];
- BlastProjectileNode* projectileNode = new BlastProjectileNode(projectile.name.buf, projectile);
+ BlastProjectileNode* projectileNode = new BlastProjectileNode(sceneController.getProjectileName(projectile), projectile);
_projectiles.push_back(projectileNode);
_blastProjectDataToNodeMap.insert(std::make_pair((void*)&projectile, projectileNode));
}
- BPPGraphicsMeshArray& graphicsMeshArray = blast.graphicsMeshes;
- count = graphicsMeshArray.arraySizes[0];
- for (int i = 0; i < count; ++i)
- {
- BPPGraphicsMesh& graphicsMesh = graphicsMeshArray.buf[i];
- BlastGraphicsMeshNode* projectileNode = new BlastGraphicsMeshNode(graphicsMesh.name.buf, graphicsMesh);
- _graphicsMeshes.push_back(projectileNode);
- }
+ //BPPGraphicsMeshArray& graphicsMeshArray = blast.graphicsMeshes;
+ //count = graphicsMeshArray.arraySizes[0];
+ //for (int i = 0; i < count; ++i)
+ //{
+ // BPPGraphicsMesh& graphicsMesh = graphicsMeshArray.buf[i];
+ // BlastGraphicsMeshNode* graphicsNode = new BlastGraphicsMeshNode(graphicsMesh.name.buf, graphicsMesh);
+ // _graphicsMeshes.push_back(graphicsNode);
+ //}
}
-void BlastTreeData::updateVisible(uint32_t assetIndex, uint32_t chunkIndex, bool visible)
+BlastNode* BlastTreeData::getNodeByIndex(uint32_t assetIndex, uint32_t chunkIndex)
{
+ BlastNode* pNode = nullptr;
BPPBlast& blast = BlastProject::ins().getParams().blast;
BPPAssetArray& assetArray = blast.blastAssets;
if (assetIndex < assetArray.arraySizes[0])
@@ -688,13 +691,13 @@ void BlastTreeData::updateVisible(uint32_t assetIndex, uint32_t chunkIndex, bool
std::vector<BPPChunk*> childChunks = BlastProject::ins().getChildrenChunks(asset);
if (chunkIndex < childChunks.size())
{
- BPPChunk& chunk = *(childChunks[chunkIndex]);
- chunk.visible = visible;
+ BPPChunk& chunk = *(childChunks[chunkIndex]);
+ pNode = getBlastNodeByProjectData(&chunk);
}
}
+ return pNode;
}
-
void BlastTreeData::update(const BlastAsset* asset)
{
//to do
@@ -744,15 +747,21 @@ BlastAsset* BlastTreeData::getAsset(BlastNode* node)
if (eAsset == node->getType())
{
- std::map<BlastAsset*, AssetList::ModelAsset>& assetDescMap = SampleManager::ins()->getAssetDescMap();
- std::map<BlastAsset*, AssetList::ModelAsset>::iterator itrAssetDesc = assetDescMap.begin();
- for (; itrAssetDesc != assetDescMap.end(); ++itrAssetDesc)
- {
- if (itrAssetDesc->second.name == node->name)
- {
- return itrAssetDesc->first;
- }
- }
+ return getAsset(node->name);
+ }
+
+ return nullptr;
+}
+
+BlastAssetNode* BlastTreeData::getAssetNode(BlastAsset* asset)
+{
+ if (nullptr == asset)
+ return nullptr;
+
+ for (BlastAssetNode* node : _assets)
+ {
+ if (node->name == getAssetName(asset))
+ return node;
}
return nullptr;
@@ -789,6 +798,250 @@ std::vector<BlastChunkNode*> BlastTreeData::getChunkNodeByBlastChunk(const Blast
return chunkNodes;
}
+std::vector<BlastNode*> _getNodesByDepth(BlastNode* curNode, uint32_t depth, int32_t curDepth)
+{
+ std::vector<BlastNode*> res;
+ if (depth == curDepth && curNode != nullptr)
+ {
+ res.push_back(curNode);
+ }
+ else if (curNode != nullptr)
+ {
+ for (BlastNode* node : curNode->children)
+ {
+ std::vector<BlastNode*> nodes = _getNodesByDepth(node, depth, curDepth + 1);
+ res.insert(res.begin(), nodes.begin(), nodes.end());
+ }
+ }
+
+ return res;
+}
+
+std::vector<BlastChunkNode*> BlastTreeData::getRootChunkNodeByInstance(const BlastAssetInstanceNode* node)
+{
+ std::vector<BlastChunkNode*> chunks;
+ if (nullptr != node)
+ {
+ const BPPAssetInstance* pBPPAssetInstance = (BPPAssetInstance*)(const_cast<BlastAssetInstanceNode*>(node)->getData());
+ BlastFamily* family = SampleManager::ins()->getFamilyByInstance(const_cast<BPPAssetInstance*>(pBPPAssetInstance));
+ if (family)
+ {
+ const BlastAsset& asset = family->getBlastAsset();
+ BlastAssetNode* assetNode = getAssetNode(const_cast<BlastAsset*>(&asset));
+ if (assetNode)
+ {
+ for (BlastNode* curNode : assetNode->children)
+ {
+ if (eChunk == curNode->getType())
+ {
+ chunks.push_back((BlastChunkNode*)curNode);
+ }
+ }
+ }
+ }
+ }
+ return chunks;
+}
+
+std::vector<BlastNode*> BlastTreeData::getNodesByDepth(BlastAssetNode* node, uint32_t depth)
+{
+ return _getNodesByDepth(node, depth, -1); // here it's from -1 because it traverse from Blast asset node
+}
+
+std::vector<BlastNode*> BlastTreeData::getNodesByDepth(uint32_t depth)
+{
+ std::vector<BlastNode*> res;
+ for (BlastAssetNode* node : _assets)
+ {
+ std::vector<BlastNode*> nodes = getNodesByDepth(node, depth);
+ res.insert(res.begin(), nodes.begin(), nodes.end());
+ }
+ return res;
+}
+
+std::vector<BlastNode*> BlastTreeData::getNodesByDepth(std::vector<uint32_t> depths)
+{
+ std::vector<BlastNode*> res;
+ for (uint32_t depth : depths)
+ {
+ std::vector<BlastNode*> nodes = getNodesByDepth(depth);
+ res.insert(res.begin(), nodes.begin(), nodes.end());
+ }
+ return res;
+}
+
+std::vector<BlastChunkNode*> _getSupportChunkNodes(BlastNode* curNode)
+{
+ std::vector<BlastChunkNode*> res;
+ if (nullptr != curNode && eChunk == curNode->getType() && static_cast<BlastChunkNode*>(curNode)->isSupport())
+ {
+ res.push_back(static_cast<BlastChunkNode*>(curNode));
+ }
+ else if (curNode != nullptr)
+ {
+ for (BlastNode* node : curNode->children)
+ {
+ std::vector<BlastChunkNode*> nodes = _getSupportChunkNodes(node);
+ res.insert(res.begin(), nodes.begin(), nodes.end());
+ }
+ }
+
+ return res;
+}
+
+std::vector<BlastChunkNode*> BlastTreeData::getSupportChunkNodes(BlastAssetNode* node)
+{
+ return _getSupportChunkNodes(node);
+}
+
+std::vector<BlastChunkNode*> BlastTreeData::getSupportChunkNodes()
+{
+ std::vector<BlastChunkNode*> res;
+ for (BlastAssetNode* node : _assets)
+ {
+ std::vector<BlastChunkNode*> nodes = getSupportChunkNodes(node);
+ res.insert(res.begin(), nodes.begin(), nodes.end());
+ }
+ return res;
+}
+
+const std::vector<BlastNode*>& _getAllChunkNodes(std::vector<BlastNode*>& res, BlastNode* curNode)
+{
+ if (nullptr == curNode)
+ return res;
+ if (eChunk == curNode->getType())
+ {
+ res.push_back(static_cast<BlastNode*>(curNode));
+ }
+ for (BlastNode* node : curNode->children)
+ {
+ _getAllChunkNodes(res, node);
+ }
+
+ return res;
+}
+
+std::vector<BlastChunkNode*> BlastTreeData::getSiblingChunkNodes(BlastChunkNode* node)
+{
+ std::vector<BlastChunkNode*> res;
+
+ if (nullptr == node)
+ return res;
+
+ BlastNode* parent = node->getParent();
+ if (nullptr == parent || eChunk != parent->getType())
+ {
+ return res;
+ }
+
+ BlastChunkNode* chunkNodeParent = static_cast<BlastChunkNode*>(parent);
+
+ for (BlastNode* child : chunkNodeParent->children)
+ {
+ if (eChunk == child->getType() && child != node)
+ res.push_back(static_cast<BlastChunkNode*>(child));
+ }
+ return res;
+}
+
+BlastChunkNode* BlastTreeData::getSupportAncestor(BlastChunkNode* node)
+{
+ if (nullptr == node)
+ return nullptr;
+
+ BlastNode* parent = node->getParent();
+ while (parent && eChunk == parent->getType())
+ {
+ BlastChunkNode* chunkNodeParent = static_cast<BlastChunkNode*>(parent);
+ BPPChunk* bppChunk = (BPPChunk*)(chunkNodeParent->getData());
+ if (bppChunk->support)
+ return chunkNodeParent;
+ parent = chunkNodeParent->getParent();
+ }
+
+ return nullptr;
+}
+
+const std::vector<BlastNode*>& BlastTreeData::getAllChunkNodes(std::vector<BlastNode*>& res, BlastAssetNode* node)
+{
+ return _getAllChunkNodes(res, node);
+}
+
+const std::vector<BlastNode*>& BlastTreeData::getAllChunkNodes(std::vector<BlastNode*>& res)
+{
+ for (BlastAssetNode* node : _assets)
+ {
+ getAllChunkNodes(res, node);
+ }
+ return res;
+}
+
+const std::vector<BlastNode*>& _getAllLeavesChunkNodes(std::vector<BlastNode*>& res, BlastNode* curNode)
+{
+ if (nullptr == curNode)
+ return res;
+ if (eChunk == curNode->getType())
+ {
+ if (BlastTreeData::isLeaf(dynamic_cast<BlastChunkNode*>(curNode)))
+ res.push_back(curNode);
+ }
+ for (BlastNode* node : curNode->children)
+ {
+ _getAllLeavesChunkNodes(res, node);
+ }
+
+ return res;
+}
+
+const std::vector<BlastNode*>& BlastTreeData::getAllLeavesChunkNodes(std::vector<BlastNode*>& res, BlastAssetNode* node)
+{
+ return _getAllLeavesChunkNodes(res, node);
+}
+
+const std::vector<BlastNode*>& BlastTreeData::getAllLeavesChunkNodes(std::vector<BlastNode*>& res)
+{
+ for (BlastAssetNode* node : _assets)
+ {
+ getAllLeavesChunkNodes(res, node);
+ }
+ return res;
+}
+
+// start from -1 because asset also takes one level.
+const std::vector<BlastNode*>& _getChunkNodesFullCoverage(std::vector<BlastNode*>& res, BlastNode* curNode, int depth, int currDepth = -1)
+{
+ if (nullptr == curNode)
+ return res;
+ if (eChunk == curNode->getType())
+ {
+ if((currDepth == depth) || ((currDepth < depth) && BlastTreeData::isLeaf(dynamic_cast<BlastChunkNode*>(curNode))))
+ res.push_back(curNode);
+ }
+ if (currDepth < depth)
+ {
+ for (BlastNode* node : curNode->children)
+ {
+ _getChunkNodesFullCoverage(res, node, depth, currDepth + 1);
+ }
+ }
+
+ return res;
+}
+
+const std::vector<BlastNode*>& BlastTreeData::getChunkNodesFullCoverage(std::vector<BlastNode*>& res, BlastAssetNode* node, int depth)
+{
+ return _getChunkNodesFullCoverage(res, node, depth);
+}
+
+const std::vector<BlastNode*>& BlastTreeData::getChunkNodesFullCoverage(std::vector<BlastNode*>& res, int depth)
+{
+ for (BlastAssetNode* node : _assets)
+ {
+ getChunkNodesFullCoverage(res, node, depth);
+ }
+ return res;
+}
+
bool isCompleteSupport(BlastChunkNode* node)
{
if (node == nullptr)
@@ -894,36 +1147,83 @@ bool BlastTreeData::isOverlapSupportAsset(const BlastAssetNode* node)
return false;
}
+void BlastTreeData::traverse(BlastVisitorBase& visitor)
+{
+ for (BlastAssetNode* assetNode : _assets)
+ {
+ if (!visitor.continueTraversing())
+ break;
+
+ assetNode->traverse(visitor);
+ }
+}
+
BlastTreeData::BlastTreeData()
{
+ _assetInstancesNode = new BlastAssetInstancesNode("BlastAssetInstances");
+ _blastProjectDataToNodeMap.clear();
}
-void BlastTreeData::_addChunkNode(const BPPChunk& parentData, BPPAsset& asset, BlastChunkNode* parentNode, void* assetPtr)
+void BlastTreeData::_addChunkNode(BPPChunk& parentData, BPPAsset& asset, BlastChunkNode* parentNode, void* assetPtr)
{
- if (parentNode != nullptr)
+ if (parentNode == nullptr)
{
- std::vector<BPPBond*> bonds = BlastProject::ins().getBondsByChunk(asset, parentData.ID);
- for (size_t i = 0; i < bonds.size(); ++i)
+ return;
+ }
+
+ std::vector<BPPBond*> bonds = BlastProject::ins().getBondsByChunk(asset, parentData.ID);
+ for (size_t i = 0; i < bonds.size(); ++i)
+ {
+ BPPBond* bond = bonds[i];
+ BlastBondNode* bondNode = new BlastBondNode(bond->name.buf, *bond);
+ parentNode->children.push_back(bondNode);
+ bondNode->setParent(parentNode);
+ _blastProjectDataToNodeMap.insert(std::make_pair((void*)bond, bondNode));
+ }
+
+ std::vector<BPPChunk*> childChunks = BlastProject::ins().getChildrenChunks(asset, parentData.ID);
+ for (size_t i = 0; i < childChunks.size(); ++i)
+ {
+ BPPChunk& chunk = *(childChunks[i]);
+ BlastChunkNode* chunkNode = new BlastChunkNode(chunk.name.buf, chunk, assetPtr);
+ parentNode->children.push_back(chunkNode);
+ chunkNode->setParent(parentNode);
+ _blastProjectDataToNodeMap.insert(std::make_pair((void*)&chunk, chunkNode));
+ _addChunkNode(chunk, asset, chunkNode, assetPtr);
+ }
+}
+
+void BlastTreeData::_removeChunkNode(BPPAsset& asset)
+{
+ std::vector<BPPChunk*> childChunks = BlastProject::ins().getChildrenChunks(asset);
+ int childChunksSize = childChunks.size();
+ for (size_t i = 0; i < childChunksSize; i++)
+ {
+ std::map<void*, BlastNode*>::iterator it = _blastProjectDataToNodeMap.find(childChunks[i]);
+ if (it == _blastProjectDataToNodeMap.end())
{
- BPPBond* bond = bonds[i];
- BlastBondNode* bondNode = new BlastBondNode(bond->name.buf, *bond);
- parentNode->children.push_back(bondNode);
- bondNode->setParent(parentNode);
- _blastProjectDataToNodeMap.insert(std::make_pair((void*)bond, bondNode));
+ continue;
}
- std::vector<BPPChunk*> childChunks = BlastProject::ins().getChildrenChunks(asset, parentData.ID);
+ BlastNode* node = it->second;
+ _blastProjectDataToNodeMap.erase(it);
+ delete node;
+ }
- for (size_t i = 0; i < childChunks.size(); ++i)
+ std::vector<BPPBond*> childBonds = BlastProject::ins().getChildrenBonds(asset);
+ int childBondsSize = childBonds.size();
+ for (size_t i = 0; i < childBondsSize; i++)
+ {
+ std::map<void*, BlastNode*>::iterator it = _blastProjectDataToNodeMap.find(childBonds[i]);
+ if (it == _blastProjectDataToNodeMap.end())
{
- BPPChunk& chunk = *(childChunks[i]);
- BlastChunkNode* chunkNode = new BlastChunkNode(chunk.name.buf, chunk, assetPtr);
- parentNode->children.push_back(chunkNode);
- chunkNode->setParent(parentNode);
- _blastProjectDataToNodeMap.insert(std::make_pair((void*)&chunk, chunkNode));
- _addChunkNode(chunk, asset, chunkNode, assetPtr);
+ continue;
}
+
+ BlastNode* node = it->second;
+ _blastProjectDataToNodeMap.erase(it);
+ delete node;
}
}
@@ -951,15 +1251,15 @@ void freeChunkNode(BlastChunkNode* chunkNode)
void BlastTreeData::_freeBlastNode()
{
- if (_composite)
+ if (_assetInstancesNode)
{
- size_t count = _composite->children.size();
+ size_t count = _assetInstancesNode->children.size();
for (size_t i = 0; i < count; ++i)
{
- delete _composite->children[i];
+ delete _assetInstancesNode->children[i];
}
- delete _composite;
- _composite = nullptr;
+ delete _assetInstancesNode;
+ _assetInstancesNode = nullptr;
}
size_t count = _assets.size();
@@ -1009,76 +1309,78 @@ BlastAssetNode* BlastTreeData::_getAssetNode(const BlastAsset* asset)
return foundAssetNode;
}
-VisualButton::VisualButton(QWidget* parent, BlastNode* blastItem)
- : QWidget(parent)
- , _button(new QPushButton(parent))
- , _blastItem(blastItem)
+QRect _getVisualIconArea(const QStyleOptionViewItem &option)
{
- connect(_button, SIGNAL(toggled(bool)), this, SLOT(on_visualbility_toggled(bool)));
- _button->setCheckable(true);
- _button->setChecked(blastItem->getVisible());
- if (blastItem->getVisible())
- _button->setIcon(QIcon(":/AppMainWindow/images/visibilityToggle_visible.png"));
- else
- _button->setIcon(QIcon(":/AppMainWindow/images/visibilityToggle_notVisible.png"));
- _button->setFixedSize(20, 20);
- this->setLayoutDirection(Qt::RightToLeft);
- this->setLayout(new QHBoxLayout);
- this->layout()->setMargin(0);
- this->layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
- this->layout()->addWidget(_button);
+ int iconLen = option.rect.height() - 2;
+ return QRect(option.rect.right() - iconLen, option.rect.top() + 1, iconLen, iconLen);
}
-void VisualButton::on_visualbility_toggled(bool checked)
+BlastTreeViewDelegate::BlastTreeViewDelegate(QObject* parent, QStandardItemModel* model)
+ : QStyledItemDelegate(parent)
+ , _treeModel(model)
{
- if (checked)
- {
- _button->setIcon(QIcon(":/AppMainWindow/images/visibilityToggle_visible.png"));
- }
- else
- {
- _button->setIcon(QIcon(":/AppMainWindow/images/visibilityToggle_notVisible.png"));
- }
-
- if (_blastItem)
- {
- _blastItem->setVisible(checked);
- }
+ setObjectName("BlastTreeViewDelegate");
}
-void VisualButton::_updateBlast(bool visible)
+void BlastTreeViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
- EBlastNodeType type = _blastItem->getType();
+ QStyledItemDelegate::paint(painter, option, index);
+
+ QStandardItem *treeItem = _treeModel->itemFromIndex(index);
+ BlastSceneTree* tree = BlastSceneTree::ins();
+ BlastNode* blastNode = tree->getBlastNodeByItem(treeItem);
+ PhysXSceneActor* projectileActor = tree->getProjectileActorByItem(treeItem);
- switch (type)
+ if ((nullptr == blastNode && nullptr == projectileActor))
+ return;
+
+ if(nullptr != blastNode && eChunk != blastNode->getType() && eBond != blastNode->getType())
+ return;
+
+ if (nullptr != blastNode)
+ painter->drawPixmap(_getVisualIconArea(option), blastNode->getVisible() ? sVisibleIcon : sInVisibleIcon);
+ else if (nullptr != projectileActor)
+ painter->drawPixmap(_getVisualIconArea(option), SampleManager::ins()->getSceneController().getProjectileVisible(projectileActor) ? sVisibleIcon : sInVisibleIcon);
+}
+
+bool BlastTreeViewDelegate::editorEvent(QEvent* evt, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index)
+{
+ if (evt->type() == QEvent::MouseButtonRelease)
{
- case eBond:
- ((BPPBond*)_blastItem->getData())->visible = visible;
- break;
- case eChunk:
- ((BPPChunk*)_blastItem->getData())->visible = visible;
- break;
- case eAsset:
- ((BPPAsset*)_blastItem->getData())->visible = visible;
- break;
- case eProjectile:
- ((BPPBond*)_blastItem->getData())->visible = visible;
- break;
- case eGraphicsMesh:
- ((BPPGraphicsMesh*)_blastItem->getData())->visible = visible;
- break;
- case eAssetInstance:
- ((BPPAssetInstance*)_blastItem->getData())->visible = visible;
- break;
- case eLandmark:
- ((BPPLandmark*)_blastItem->getData())->visible = visible;
- break;
- case eComposite:
- ((BPPComposite*)_blastItem->getData())->visible = visible;
- break;
- default:
- break;
+ QMouseEvent* mouseEvt = (QMouseEvent*)evt;
+ if (_getVisualIconArea(option).contains(mouseEvt->pos()))
+ {
+ QStandardItem *treeItem = _treeModel->itemFromIndex(index);
+ BlastSceneTree* tree = BlastSceneTree::ins();
+ BlastNode* blastNode = tree->getBlastNodeByItem(treeItem);
+ PhysXSceneActor* projectileActor = tree->getProjectileActorByItem(treeItem);
+
+ if ((nullptr == blastNode && nullptr == projectileActor))
+ return QStyledItemDelegate::editorEvent(evt, model, option, index);
+
+ if (nullptr != blastNode && eChunk != blastNode->getType() && eBond != blastNode->getType())
+ return QStyledItemDelegate::editorEvent(evt, model, option, index);
+
+ if (nullptr != blastNode)
+ {
+ blastNode->setVisible(!blastNode->getVisible());
+ }
+ else if (nullptr != projectileActor)
+ {
+ SceneController& sceneController = SampleManager::ins()->getSceneController();
+ sceneController.setProjectileVisible(projectileActor, !sceneController.getProjectileVisible(projectileActor));
+ }
+
+ BlastSceneTree::ins()->update();
+ return true;
+ }
}
+ return QStyledItemDelegate::editorEvent(evt, model, option, index);
+}
+
+bool BlastTreeViewDelegate::eventFilter(QObject* object, QEvent* event)
+{
+ return true;
}
static BlastSceneTree* sBlastSceneTree = nullptr;
@@ -1094,37 +1396,74 @@ BlastSceneTree::BlastSceneTree(QWidget *parent)
_updateData = true;
sBlastSceneTree = this;
- ui.blastSceneTree->setStyleSheet("QTreeWidget::item{height:24px}");
- ui.blastSceneTree->setColumnWidth(0, 260);
- ui.blastSceneTree->setColumnWidth(1, 20);
+ sCompositeIcon = QIcon(":/AppMainWindow/images/AssetComposite.png");
+ sAssetIcon = QIcon(":/AppMainWindow/images/Asset.png");
+ sChunkUUIcon = QIcon(":/AppMainWindow/images/Chunk_Unsupport_Unstatic.png");
+ sChunkSUIcon = QIcon(":/AppMainWindow/images/Chunk_Support_Unstatic.png");
+ sChunkSSIcon = QIcon(":/AppMainWindow/images/Chunk_Support_Static.png");
+ sBondIcon = QIcon(":/AppMainWindow/images/Bond.png");
+ sProjectileIcon = QIcon(":/AppMainWindow/images/Projectile.png");
+ _treeModel = new QStandardItemModel();
+ ui.blastSceneTree->setModel(_treeModel);
+ QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel();
+ connect(selectionModel, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(on_blastSceneTree_itemSelectionChanged(const QItemSelection&, const QItemSelection&)));
+
+ BlastTreeViewDelegate* itemDelegate = new BlastTreeViewDelegate(ui.blastSceneTree, _treeModel);
+ ui.blastSceneTree->setItemDelegate((QAbstractItemDelegate*)itemDelegate);
+
+ ui.blastSceneTree->setStyleSheet("QTreeView::item{height:24px}");
ui.blastSceneTree->setContextMenuPolicy(Qt::CustomContextMenu);
- _treeChunkContextMenu = new QMenu(this);
+ _treeContextMenu = new QMenu(this);
_makeSupportAction = new QAction(tr("Make Support"), this);
- _treeChunkContextMenu->addAction(_makeSupportAction);
+ _treeContextMenu->addAction(_makeSupportAction);
connect(_makeSupportAction, SIGNAL(triggered()), this, SLOT(onMakeSupportMenuItemClicked()));
_makeStaticSupportAction = new QAction(tr("Make Static Support"), this);
- _treeChunkContextMenu->addAction(_makeStaticSupportAction);
+ _treeContextMenu->addAction(_makeStaticSupportAction);
connect(_makeStaticSupportAction, SIGNAL(triggered()), this, SLOT(onMakeStaticSupportMenuItemClicked()));
_removeSupportAction = new QAction(tr("Remove Support"), this);
- _treeChunkContextMenu->addAction(_removeSupportAction);
+ _treeContextMenu->addAction(_removeSupportAction);
connect(_removeSupportAction, SIGNAL(triggered()), this, SLOT(onRemoveSupportMenuItemClicked()));
- _treeBondContextMenu = new QMenu(this);
- _bondChunksAction = new QAction(tr("Bond Chunks"), this);
- _treeBondContextMenu->addAction(_bondChunksAction);
- connect(_bondChunksAction, SIGNAL(triggered()), this, SLOT(onBondChunksMenuItemClicked()));
+ _makeWorldAction = new QAction(tr("Make World"), this);
+ _treeContextMenu->addAction(_makeWorldAction);
+ connect(_makeWorldAction, SIGNAL(triggered()), this, SLOT(onMakeWorldMenuItemClicked()));
+
+ _removeWorldAction = new QAction(tr("Remove World"), this);
+ _treeContextMenu->addAction(_removeWorldAction);
+ connect(_removeWorldAction, SIGNAL(triggered()), this, SLOT(onRemoveWorldMenuItemClicked()));
+
+ //_bondChunksAction = new QAction(tr("Bond Chunks"), this);
+ //_treeContextMenu->addAction(_bondChunksAction);
+ //connect(_bondChunksAction, SIGNAL(triggered()), this, SLOT(onBondChunksMenuItemClicked()));
+
+
+ //_bondChunksWithJointsAction = new QAction(tr("Bond Chunks With Joints"), this);
+ //_treeContextMenu->addAction(_bondChunksWithJointsAction);
+ //connect(_bondChunksWithJointsAction, SIGNAL(triggered()), this, SLOT(onBondChunksWithJointsMenuItemClicked()));
- _bondChunksWithJointsAction = new QAction(tr("Bond Chunks With Joints"), this);
- _treeBondContextMenu->addAction(_bondChunksWithJointsAction);
- connect(_bondChunksWithJointsAction, SIGNAL(triggered()), this, SLOT(onBondChunksWithJointsMenuItemClicked()));
+ //_removeAllBondsAction = new QAction(tr("Remove All Bonds"), this);
+ //_treeContextMenu->addAction(_removeAllBondsAction);
+ //connect(_removeAllBondsAction, SIGNAL(triggered()), this, SLOT(onRemoveAllBondsMenuItemClicked()));
- _removeAllBondsAction = new QAction(tr("Remove All Bonds"), this);
- _treeBondContextMenu->addAction(_removeAllBondsAction);
- connect(_removeAllBondsAction, SIGNAL(triggered()), this, SLOT(onRemoveAllBondsMenuItemClicked()));
+ QShortcut* shortCut;
+ shortCut = new QShortcut(QKeySequence("Alt+C"), this);
+ connect(shortCut, SIGNAL(activated()), this, SLOT(onCollapseExpandClicked()));
+ /*
+ BlastAssetInstancesNode* assetInstancesNode = BlastTreeData::ins().getBlastAssetInstancesNode();
+ _compositeTreeItem = new QStandardItem();
+ _treeModel->appendRow(_compositeTreeItem);
+ _compositeTreeItem->setText(assetInstancesNode->name.c_str());
+ _compositeTreeItem->setIcon(sCompositeIcon);
+ _treeItemDataMap.insert(_compositeTreeItem, assetInstancesNode);
+ _treeDataItemMap.insert(assetInstancesNode, _compositeTreeItem);
+ */
+
+ m_pNewBlastAsset = nullptr;
+ m_NewChunkIndexes.clear();
}
BlastSceneTree::~BlastSceneTree()
@@ -1139,14 +1478,94 @@ void BlastSceneTree::updateValues(bool updataData)
BlastTreeData::ins().update();
}
+ std::map<BPPAssetInstance*, std::set<uint32_t>> selectChunks;
+
+ SelectionToolController* m_selectionToolController = &SampleManager::ins()->getSelectionToolController();
+ GizmoToolController* m_gizmoToolController = &SampleManager::ins()->getGizmoToolController();
+ BlastController* m_blastController = &SampleManager::ins()->getBlastController();
+
+ if (m_selectionToolController->IsEnabled())
+ {
+ std::set<PxActor*> actors = m_selectionToolController->getTargetActors();
+ for (PxActor* actor : actors)
+ {
+ BlastFamily* pBlastFamily = m_blastController->getFamilyByPxActor(*actor);
+ if (pBlastFamily)
+ {
+ BPPAssetInstance* assetInstance = SampleManager::ins()->getInstanceByFamily(pBlastFamily);
+ uint32_t chunkIndex = pBlastFamily->getChunkIndexByPxActor(*actor);
+ selectChunks[assetInstance].insert(chunkIndex);
+ }
+ }
+ }
+ else if (m_gizmoToolController->IsEnabled())
+ {
+ PxActor* actor = m_gizmoToolController->getTargetActor();
+
+ if (actor)
+ {
+ BlastFamily* pBlastFamily = m_blastController->getFamilyByPxActor(*actor);
+ if (pBlastFamily)
+ {
+ BPPAssetInstance* assetInstance = SampleManager::ins()->getInstanceByFamily(pBlastFamily);
+ uint32_t chunkIndex = pBlastFamily->getChunkIndexByPxActor(*actor);
+ selectChunks[assetInstance].insert(chunkIndex);
+ }
+ }
+ }
+
_updateTreeUIs();
+
+ BlastSceneTreeDataLock lock;
+ std::set<PxActor*> actors;
+ for (std::map<BPPAssetInstance*, std::set<uint32_t>>::iterator itr = selectChunks.begin(); itr != selectChunks.end(); ++itr)
+ {
+ BlastFamily* family = SampleManager::ins()->getFamilyByInstance(itr->first);
+ std::set<uint32_t>& chunkIndexes = itr->second;
+
+ if (nullptr != family)
+ {
+ for (uint32_t chunkIndex : chunkIndexes)
+ {
+ PxActor* actor = nullptr;
+ family->getPxActorByChunkIndex(chunkIndex, &actor);
+
+ if (actor)
+ actors.insert(actor);
+ }
+ }
+ }
+
+ if (m_selectionToolController->IsEnabled())
+ {
+ m_selectionToolController->setTargetActors(actors);
+ }
+ else if (m_gizmoToolController->IsEnabled())
+ {
+ if (actors.size() > 0)
+ m_gizmoToolController->setTargetActor(*actors.begin());
+ }
+}
+
+void BlastSceneTree::clear()
+{
+ _treeModel->clear();
+ _treeItemDataMap.clear();
+ _treeDataItemMap.clear();
+
+ // notify no selection
+ std::vector<BlastNode*> nodes;
+ for (size_t i = 0; i < _observers.size(); ++i)
+ {
+ _observers[i]->dataSelected(nodes);
+ }
}
void BlastSceneTree::dataSelected(std::vector<BlastNode*> selections)
{
for (size_t i = 0; i < selections.size(); ++i)
{
- _selectTreeItem(selections[i]);
+ selectTreeItem(selections[i]);
}
}
@@ -1167,7 +1586,11 @@ void BlastSceneTree::removeObserver(ISceneObserver* observer)
void BlastSceneTree::updateVisible(uint32_t assetIndex, uint32_t chunkIndex, bool visible)
{
- BlastTreeData::ins().updateVisible(assetIndex, chunkIndex, visible);
+ BlastNode* node = BlastTreeData::ins().getNodeByIndex(assetIndex, chunkIndex);
+ if (node != nullptr && eChunk == node->getType())
+ {
+ static_cast<BlastChunkNode*>(node)->setVisible(visible);
+ }
}
void BlastSceneTree::updateChunkItemSelection()
@@ -1188,7 +1611,7 @@ void BlastSceneTree::updateChunkItemSelection()
for (BlastChunkNode* node : chunkNodes)
{
- _selectTreeItem(node);
+ selectTreeItem(node, false);
}
_updateData = true;
@@ -1197,10 +1620,11 @@ void BlastSceneTree::updateChunkItemSelection()
void BlastSceneTree::makeSupport()
{
std::vector<BlastChunkNode*> selectedChunkNodes;
- QList<QTreeWidgetItem*> selectedItems = ui.blastSceneTree->selectedItems();
- for (int i = 0; i < selectedItems.size(); ++i)
+ QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel();
+ QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
+ for (int i = 0; i < selectedIndexes.count(); ++i)
{
- QMap<QTreeWidgetItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(selectedItems.at(i));
+ QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i)));
if (eChunk == itr.value()->getType())
{
@@ -1209,22 +1633,36 @@ void BlastSceneTree::makeSupport()
}
std::vector<BlastChunkNode*> topChunkNodes = BlastTreeData::getTopChunkNodes(selectedChunkNodes);
- for (size_t i = 0; i < topChunkNodes.size(); ++i)
+ std::set<BlastAsset*> assets;
+ for (BlastChunkNode* chunkNode : topChunkNodes)
{
- BlastChunkNode* chunkNode = topChunkNodes[i];
+ if (chunkNode->isSupport() && !((BPPChunk*)chunkNode->getData())->staticFlag)
+ continue;
BlastTreeData::makeSupport(chunkNode);
+ BlastAsset* pBlastAsset = BlastTreeData::ins().getAsset(chunkNode);
+ assets.insert(pBlastAsset);
}
- _updateChunkTreeItems();
+ if (0 == assets.size())
+ return;
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ for (BlastAsset* asset : assets)
+ {
+ pSampleManager->refreshAsset(asset);
+ }
+
+ return;
}
void BlastSceneTree::makeStaticSupport()
{
std::vector<BlastChunkNode*> selectedChunkNodes;
- QList<QTreeWidgetItem*> selectedItems = ui.blastSceneTree->selectedItems();
- for (int i = 0; i < selectedItems.size(); ++i)
+ QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel();
+ QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
+ for (int i = 0; i < selectedIndexes.count(); ++i)
{
- QMap<QTreeWidgetItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(selectedItems.at(i));
+ QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i)));
if (eChunk == itr.value()->getType())
{
@@ -1233,22 +1671,36 @@ void BlastSceneTree::makeStaticSupport()
}
std::vector<BlastChunkNode*> topChunkNodes = BlastTreeData::getTopChunkNodes(selectedChunkNodes);
- for (size_t i = 0; i < topChunkNodes.size(); ++i)
+ std::set<BlastAsset*> assets;
+ for (BlastChunkNode* chunkNode : topChunkNodes)
{
- BlastChunkNode* chunkNode = topChunkNodes[i];
+ if (chunkNode->isSupport() && ((BPPChunk*)chunkNode->getData())->staticFlag)
+ continue;
BlastTreeData::makeStaticSupport(chunkNode);
+ BlastAsset* pBlastAsset = BlastTreeData::ins().getAsset(chunkNode);
+ assets.insert(pBlastAsset);
}
- _updateChunkTreeItems();
+ if (0 == assets.size())
+ return;
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ for (BlastAsset* asset : assets)
+ {
+ pSampleManager->refreshAsset(asset);
+ }
+
+ return;
}
void BlastSceneTree::removeSupport()
{
std::vector<BlastChunkNode*> selectedChunkNodes;
- QList<QTreeWidgetItem*> selectedItems = ui.blastSceneTree->selectedItems();
- for (int i = 0; i < selectedItems.size(); ++i)
+ QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel();
+ QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
+ for (int i = 0; i < selectedIndexes.count(); ++i)
{
- QMap<QTreeWidgetItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(selectedItems.at(i));
+ QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i)));
if (eChunk == itr.value()->getType())
{
@@ -1257,13 +1709,110 @@ void BlastSceneTree::removeSupport()
}
std::vector<BlastChunkNode*> topChunkNodes = BlastTreeData::getTopChunkNodes(selectedChunkNodes);
- for (size_t i = 0; i < topChunkNodes.size(); ++i)
+ std::set<BlastAsset*> assets;
+ for (BlastChunkNode* chunkNode : topChunkNodes)
{
- BlastChunkNode* chunkNode = topChunkNodes[i];
+ if (!chunkNode->isSupport() || BlastTreeData::isLeaf(chunkNode))
+ continue;
BlastTreeData::removeSupport(chunkNode);
+ BlastAsset* pBlastAsset = BlastTreeData::ins().getAsset(chunkNode);
+ assets.insert(pBlastAsset);
+ }
+
+ if (0 == assets.size())
+ return;
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ for (BlastAsset* asset : assets)
+ {
+ pSampleManager->refreshAsset(asset);
+ }
+
+ return;
+}
+
+void BlastSceneTree::makeWorld()
+{
+ std::vector<BlastBondNode*> selectedBondNodes;
+ QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel();
+ QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
+ for (int i = 0; i < selectedIndexes.count(); ++i)
+ {
+ QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i)));
+
+ if (eBond == itr.value()->getType())
+ {
+ selectedBondNodes.push_back((BlastBondNode*)itr.value());
+ }
+ }
+ if (selectedBondNodes.size() == 0)
+ {
+ return;
+ }
+
+ std::vector<BlastBondNode*>::iterator itSBN;
+ std::map<BlastAsset*, BlastAsset*> UniqueAssets;
+ for (itSBN = selectedBondNodes.begin(); itSBN != selectedBondNodes.end(); itSBN++)
+ {
+ BlastBondNode* node = *itSBN;
+
+ BPPBond* bond = static_cast<BPPBond*>(node->getData());
+ bond->toChunk = 0xFFFFFFFF;
+
+ BlastAsset* pBlastAsset = BlastTreeData::ins().getAsset(node);
+ UniqueAssets[pBlastAsset] = pBlastAsset;
+ }
+
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ std::map<BlastAsset*, BlastAsset*>::iterator itUA;
+ for (itUA = UniqueAssets.begin(); itUA != UniqueAssets.end(); itUA++)
+ {
+ BlastAsset* pBlastAsset = itUA->second;
+ pSampleManager->refreshAsset(pBlastAsset);
+ }
+}
+
+void BlastSceneTree::removeWorld()
+{
+ std::vector<BlastBondNode*> selectedBondNodes;
+ QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel();
+ QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
+ for (int i = 0; i < selectedIndexes.count(); ++i)
+ {
+ QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i)));
+
+ if (eBond == itr.value()->getType())
+ {
+ selectedBondNodes.push_back((BlastBondNode*)itr.value());
+ }
}
+ if (selectedBondNodes.size() == 0)
+ {
+ return;
+ }
+
+ std::vector<BlastBondNode*>::iterator itSBN;
+ std::map<BlastAsset*, BlastAsset*> UniqueAssets;
+ for (itSBN = selectedBondNodes.begin(); itSBN != selectedBondNodes.end(); itSBN++)
+ {
+ BlastBondNode* node = *itSBN;
- _updateChunkTreeItems();
+ BPPBond* bond = static_cast<BPPBond*>(node->getData());
+ bond->toChunk = 0xFFFFFFFF - 1;
+
+ BlastAsset* pBlastAsset = BlastTreeData::ins().getAsset(node);
+ UniqueAssets[pBlastAsset] = pBlastAsset;
+ }
+
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ std::map<BlastAsset*, BlastAsset*>::iterator itUA;
+ for (itUA = UniqueAssets.begin(); itUA != UniqueAssets.end(); itUA++)
+ {
+ BlastAsset* pBlastAsset = itUA->second;
+ pSampleManager->refreshAsset(pBlastAsset);
+ }
}
void BlastSceneTree::bondChunks()
@@ -1281,84 +1830,210 @@ void BlastSceneTree::removeAllBonds()
}
+void BlastSceneTree::setChunkSelected(std::vector<uint32_t> depths, bool selected)
+{
+ std::vector<BlastNode*> nodes = BlastTreeData::ins().getNodesByDepth(depths);
+ for (BlastNode* node : nodes)
+ {
+ if (eChunk == node->getType())
+ {
+ static_cast<BlastChunkNode*>(node)->setSelected(selected);
+ selectTreeItem(node);
+ }
+ }
+}
+
+void BlastSceneTree::setChunkVisible(std::vector<uint32_t> depths, bool bVisible)
+{
+ std::vector<BlastNode*> nodes = BlastTreeData::ins().getNodesByDepth(depths);
+ for (BlastNode* node : nodes)
+ {
+ if (eChunk == node->getType())
+ {
+ static_cast<BlastChunkNode*>(node)->setVisible(bVisible);
+ }
+ }
+}
+
+void BlastSceneTree::hideAllChunks()
+{
+ std::vector<BlastNode*> nodes;
+ BlastTreeData::ins().getAllChunkNodes(nodes);
+ for (BlastNode* node : nodes)
+ {
+ if (eChunk == node->getType())
+ {
+ static_cast<BlastChunkNode*>(node)->setVisible(false);
+ }
+ }
+}
+
+void BlastSceneTree::setChunkVisibleFullCoverage(int depth)
+{
+ std::vector<BlastNode*> nodes;
+ BlastTreeData::ins().getChunkNodesFullCoverage(nodes, depth);
+ for (BlastNode* node : nodes)
+ {
+ if (eChunk == node->getType())
+ {
+ static_cast<BlastChunkNode*>(node)->setVisible(true);
+ }
+ }
+}
+
void BlastSceneTree::on_btnAsset_clicked()
{
- QMessageBox::information(NULL, "test", "on_btnAsset_clicked");
+ QMessageBox::information(NULL, "Blast Tool", "This feature isn't implemented currently!");
}
void BlastSceneTree::on_assetComposite_clicked()
{
- QMessageBox::information(NULL, "test", "on_assetComposite_clicked");
+ QMessageBox::information(NULL, "Blast Tool", "This feature isn't implemented currently!");
}
void BlastSceneTree::on_btnChunk_clicked()
{
- QMessageBox::information(NULL, "test", "on_btnChunk_clicked");
+ QMessageBox::information(NULL, "Blast Tool", "This feature isn't implemented currently!");
}
void BlastSceneTree::on_btnBond_clicked()
{
- QMessageBox::information(NULL, "test", "on_btnBond_clicked");
+ QMessageBox::information(NULL, "Blast Tool", "This feature isn't implemented currently!");
}
void BlastSceneTree::on_btnProjectile_clicked()
{
- QMessageBox::information(NULL, "test", "on_btnProjectile_clicked");
+ QMessageBox::information(NULL, "Blast Tool", "This feature isn't implemented currently!");
+}
+
+void BlastSceneTree::on_btnExpandCollapse_clicked()
+{
+ onCollapseExpandClicked();
}
void BlastSceneTree::on_blastSceneTree_customContextMenuRequested(const QPoint &pos)
{
- QList<QTreeWidgetItem*> items = ui.blastSceneTree->selectedItems();
+ QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel();
+ QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
- if (items.count() == 1)
+ std::vector<BlastChunkNode*> chunkNodes;
+ std::vector<BlastBondNode*> bondNodes;
+ for (int i = 0; i < selectedIndexes.count(); ++i)
{
- QTreeWidgetItem* curItem = items.at(0);
-
- QMap<QTreeWidgetItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(curItem);
+ QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i)));
if (itr != _treeItemDataMap.end())
{
- if (eChunk == itr.value()->getType() || eBond == itr.value()->getType())
+ if (eChunk == itr.value()->getType())
{
- _treeChunkContextMenu->exec(QCursor::pos());
+ chunkNodes.push_back((BlastChunkNode*)itr.value());
+ }
+ else if (eBond == itr.value()->getType())
+ {
+ bondNodes.push_back((BlastBondNode*)itr.value());
}
}
}
- else if (items.count() > 1)
+
{
- bool allSupportChunk = true;
- for (int i = 0; i < items.count(); ++i)
+ std::vector<BlastChunkNode*> topChunkNodes = BlastTreeData::getTopChunkNodes(chunkNodes);
+ _makeSupportAction->setEnabled(true);
+ _makeStaticSupportAction->setEnabled(true);
+ _removeSupportAction->setEnabled(true);
+ _makeWorldAction->setEnabled(true);
+ _removeWorldAction->setEnabled(true);
+
+ //select chunk nodes have parent child relation ship, disable all menu items
+ if (topChunkNodes.size() < chunkNodes.size())
+ {
+ _makeSupportAction->setEnabled(false);
+ _makeStaticSupportAction->setEnabled(false);
+ _removeSupportAction->setEnabled(false);
+ }
+ else
{
- QMap<QTreeWidgetItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(items.at(i));
- if (itr != _treeItemDataMap.end())
+ bool allSupported = true, allStaticSupport = true, allUnSupported = true, hasLeaf = false;
+
+ for (BlastChunkNode* chunkNode : chunkNodes)
{
- if (eChunk != itr.value()->getType())
+ BPPChunk* chunk = (BPPChunk*)(chunkNode->getData());
+ if (chunk->support)
+ {
+ allUnSupported = false;
+ }
+ else
{
- allSupportChunk = false;
- break;
+ allSupported = false;
+ }
+
+ if (!chunk->staticFlag)
+ {
+ allStaticSupport = false;
+ }
+
+ if (BlastTreeData::isLeaf(chunkNode))
+ {
+ hasLeaf = true;
}
}
- }
- if (allSupportChunk)
- {
- _treeBondContextMenu->exec(QCursor::pos());
+ if (allSupported && !allStaticSupport)
+ {
+ _makeSupportAction->setEnabled(false);
+ }
+
+ if (allStaticSupport)
+ {
+ _makeStaticSupportAction->setEnabled(false);
+ }
+
+ if (allUnSupported || hasLeaf)
+ {
+ _removeSupportAction->setEnabled(false);
+ }
}
}
+ if (chunkNodes.size() > 0 && bondNodes.size() > 0)
+ {
+ _makeSupportAction->setEnabled(false);
+ _makeStaticSupportAction->setEnabled(false);
+ _removeSupportAction->setEnabled(false);
+ _makeWorldAction->setEnabled(false);
+ _removeWorldAction->setEnabled(false);
+ }
+ else if (chunkNodes.size() > 0 && bondNodes.size() == 0)
+ {
+ _makeWorldAction->setEnabled(false);
+ _removeWorldAction->setEnabled(false);
+ }
+ else if (chunkNodes.size() == 0 && bondNodes.size() > 0)
+ {
+ _makeSupportAction->setEnabled(false);
+ _makeStaticSupportAction->setEnabled(false);
+ _removeSupportAction->setEnabled(false);
+ }
+
+ if (0 < chunkNodes.size() || 0 < bondNodes.size())
+ {
+ _treeContextMenu->exec(QCursor::pos());
+ }
+
}
-void BlastSceneTree::on_blastSceneTree_itemSelectionChanged()
+void BlastSceneTree::on_blastSceneTree_itemSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
{
if (!_updateData)
return;
SampleManager::ins()->clearChunksSelected();
- QList<QTreeWidgetItem*> selectedItems = ui.blastSceneTree->selectedItems();
+ QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel();
+ QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
+
std::vector<BlastNode*> nodes;
- for (int i = 0; i < selectedItems.count(); ++i)
+ for (int i = 0; i < selectedIndexes.count(); ++i)
{
- QMap<QTreeWidgetItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(selectedItems.at(i));
+ QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i)));
if (itr != _treeItemDataMap.end())
{
nodes.push_back(itr.value());
@@ -1367,10 +2042,32 @@ void BlastSceneTree::on_blastSceneTree_itemSelectionChanged()
if (eChunk == node->getType())
{
((BlastChunkNode*)node)->setSelected(true);
+
+ if (BlastTreeData::isRoot((BlastChunkNode*)node))
+ {
+ std::vector<BlastAssetInstanceNode*> instanceNodes = BlastTreeData::ins().getAssetInstanceNodes((BlastChunkNode*)node);
+ for (BlastAssetInstanceNode* instanceNode : instanceNodes)
+ {
+ selectTreeItem(instanceNode, false);
+ nodes.push_back(instanceNode);
+ }
+ }
}
else if (eAssetInstance == node->getType())
{
((BlastAssetInstanceNode*)node)->setSelected(true);
+
+ BlastSceneTreeDataLock lock;
+ std::vector<BlastChunkNode*> chunkNodes = BlastTreeData::ins().getRootChunkNodeByInstance((BlastAssetInstanceNode*)node);
+ for (BlastChunkNode* chunkNode : chunkNodes)
+ {
+ selectTreeItem(chunkNode, false);
+ nodes.push_back(chunkNode);
+ }
+ }
+ else if (eAsset == node->getType())
+ {
+ ((BlastAssetNode*)node)->setSelected(true);
}
}
}
@@ -1396,6 +2093,16 @@ void BlastSceneTree::onRemoveSupportMenuItemClicked()
removeSupport();
}
+void BlastSceneTree::onMakeWorldMenuItemClicked()
+{
+ makeWorld();
+}
+
+void BlastSceneTree::onRemoveWorldMenuItemClicked()
+{
+ removeWorld();
+}
+
void BlastSceneTree::onBondChunksMenuItemClicked()
{
bondChunks();
@@ -1411,35 +2118,54 @@ void BlastSceneTree::onRemoveAllBondsMenuItemClicked()
removeAllBonds();
}
+void BlastSceneTree::onCollapseExpandClicked()
+{
+ static bool expand = true;
+ if (expand)
+ {
+ ui.blastSceneTree->collapseAll();
+ expand = false;
+ }
+ else
+ {
+ ui.blastSceneTree->expandAll();
+ expand = true;
+ }
+}
+
void BlastSceneTree::_updateTreeUIs()
{
- ui.blastSceneTree->clear();
+#ifdef _DEBUG
+ static int gcounter = 0;
+ static char gbuf[128];
+ sprintf(gbuf, "_updateTreeUIs called %d", ++gcounter);
+ viewer_msg(gbuf);
+#endif
+ //ui.blastSceneTree->setUpdatesEnabled(false);
+ _treeModel->clear();
_treeItemDataMap.clear();
_treeDataItemMap.clear();
- BlastCompositeNode* compositeNode = BlastTreeData::ins().getCompsiteNode();
- if (compositeNode != nullptr)
+ BlastAssetInstancesNode* assetInstancesNode = BlastTreeData::ins().getBlastAssetInstancesNode();
+ if (assetInstancesNode != nullptr)
{
- QTreeWidgetItem* compositeTreeWidgetItem = new QTreeWidgetItem(ui.blastSceneTree);
- compositeTreeWidgetItem->setText(0, compositeNode->name.c_str());
- compositeTreeWidgetItem->setIcon(0, QIcon(":/AppMainWindow/images/AssetComposite.png"));
- VisualButton* btn = new VisualButton(this, compositeNode);
- ui.blastSceneTree->setItemWidget(compositeTreeWidgetItem, 1, btn);
- _treeItemDataMap.insert(compositeTreeWidgetItem, compositeNode);
- _treeDataItemMap.insert(compositeNode, compositeTreeWidgetItem);
-
- size_t count = compositeNode->children.size();
+ QStandardItem* compositeTreeItem = new QStandardItem();
+ compositeTreeItem->setText(assetInstancesNode->name.c_str());
+ compositeTreeItem->setIcon(sCompositeIcon);
+ _treeItemDataMap.insert(compositeTreeItem, assetInstancesNode);
+ _treeDataItemMap.insert(assetInstancesNode, compositeTreeItem);
+ _treeModel->appendRow(compositeTreeItem);
+ size_t count = assetInstancesNode->children.size();
for (size_t i = 0; i < count; ++i)
{
- BlastNode* assetInstanceNode = compositeNode->children[i];
- QTreeWidgetItem* assetInstanceWidgetItem = new QTreeWidgetItem(compositeTreeWidgetItem);
- assetInstanceWidgetItem->setText(0, assetInstanceNode->name.c_str());
+ BlastNode* assetInstanceNode = assetInstancesNode->children[i];
+ QStandardItem* assetInstanceItem = new QStandardItem();
+ compositeTreeItem->appendRow(assetInstanceItem);
+ assetInstanceItem->setText(assetInstanceNode->name.c_str());
if (assetInstanceNode->getType() == eAssetInstance)
- assetInstanceWidgetItem->setIcon(0, QIcon(":/AppMainWindow/images/Asset.png"));
- VisualButton* btn = new VisualButton(this, assetInstanceNode);
- ui.blastSceneTree->setItemWidget(assetInstanceWidgetItem, 1, btn);
- _treeItemDataMap.insert(assetInstanceWidgetItem, assetInstanceNode);
- _treeDataItemMap.insert(assetInstanceNode, assetInstanceWidgetItem);
+ assetInstanceItem->setIcon(QIcon(":/AppMainWindow/images/Asset.png"));
+ _treeItemDataMap.insert(assetInstanceItem, assetInstanceNode);
+ _treeDataItemMap.insert(assetInstanceNode, assetInstanceItem);
}
}
@@ -1449,11 +2175,10 @@ void BlastSceneTree::_updateTreeUIs()
{
BlastAssetNode* assetNode = assets[i];
- QTreeWidgetItem* assetTreeWidgetItem = new QTreeWidgetItem(ui.blastSceneTree);
- assetTreeWidgetItem->setText(0, assetNode->name.c_str());
- assetTreeWidgetItem->setIcon(0, QIcon(":/AppMainWindow/images/Asset.png"));
- VisualButton* btn = new VisualButton(this, assetNode);
- ui.blastSceneTree->setItemWidget(assetTreeWidgetItem, 1, btn);
+ QStandardItem* assetTreeWidgetItem = new QStandardItem();
+ _treeModel->appendRow(assetTreeWidgetItem);
+ assetTreeWidgetItem->setText(assetNode->name.c_str());
+ assetTreeWidgetItem->setIcon(sAssetIcon);
_treeItemDataMap.insert(assetTreeWidgetItem, assetNode);
_treeDataItemMap.insert(assetNode, assetTreeWidgetItem);
@@ -1466,13 +2191,12 @@ void BlastSceneTree::_updateTreeUIs()
{
BlastProjectileNode* projectileNode = projectiles[i];
- QTreeWidgetItem* projectileTreeWidgetItem = new QTreeWidgetItem(ui.blastSceneTree);
- projectileTreeWidgetItem->setText(0, projectileNode->name.c_str());
- projectileTreeWidgetItem->setIcon(0, QIcon(":/AppMainWindow/images/Projectile.png"));
- VisualButton* btn = new VisualButton(this, projectileNode);
- ui.blastSceneTree->setItemWidget(projectileTreeWidgetItem, 1, btn);
- _treeItemDataMap.insert(projectileTreeWidgetItem, projectileNode);
- _treeDataItemMap.insert(projectileNode, projectileTreeWidgetItem);
+ QStandardItem* projectileTreeItem = new QStandardItem();
+ _treeModel->appendRow(projectileTreeItem);
+ projectileTreeItem->setText(projectileNode->name.c_str());
+ projectileTreeItem->setIcon(sProjectileIcon);
+ _treeItemDataMap.insert(projectileTreeItem, projectileNode);
+ _treeDataItemMap.insert(projectileNode, projectileTreeItem);
}
std::vector<BlastGraphicsMeshNode*>& graphicsMeshes = BlastTreeData::ins().getGraphicsMeshNodes();
@@ -1481,23 +2205,52 @@ void BlastSceneTree::_updateTreeUIs()
{
BlastGraphicsMeshNode* graphicsMesheNode = graphicsMeshes[i];
- QTreeWidgetItem* graphicsMesheTreeWidgetItem = new QTreeWidgetItem(ui.blastSceneTree);
- graphicsMesheTreeWidgetItem->setText(0, graphicsMesheNode->name.c_str());
- VisualButton* btn = new VisualButton(this, graphicsMesheNode);
- ui.blastSceneTree->setItemWidget(graphicsMesheTreeWidgetItem, 1, btn);
+ QStandardItem* graphicsMesheTreeWidgetItem = new QStandardItem();
+ _treeModel->appendRow(graphicsMesheTreeWidgetItem);
+ graphicsMesheTreeWidgetItem->setText(graphicsMesheNode->name.c_str());
_treeItemDataMap.insert(graphicsMesheTreeWidgetItem, graphicsMesheNode);
_treeDataItemMap.insert(graphicsMesheNode, graphicsMesheTreeWidgetItem);
}
- //for (int j = 0; j < ui.blastSceneTree->topLevelItemCount(); ++j)
+ ui.blastSceneTree->expandAll();
+
+ // notify no selection
+ //std::vector<BlastNode*> nodes;
+ //for (size_t i = 0; i < _observers.size(); ++i)
//{
- // QTreeWidgetItem* topLevelItem = ui.blastSceneTree->topLevelItem(j);
- // ui.blastSceneTree->expandItem(topLevelItem);
+ // _observers[i]->dataSelected(nodes);
//}
- ui.blastSceneTree->expandAll();
+
+ bool autoSelectNewChunks = BlastProject::ins().getParams().fracture.general.autoSelectNewChunks;
+ if (!autoSelectNewChunks)
+ {
+ m_pNewBlastAsset = nullptr;
+ m_NewChunkIndexes.clear();
+ return;
+ }
+
+ if (m_pNewBlastAsset == nullptr || m_NewChunkIndexes.size() == 0)
+ {
+ return;
+ }
+
+ _updateData = false;
+ ui.blastSceneTree->clearSelection();
+ std::vector<BlastChunkNode*> chunkNodes =
+ BlastTreeData::ins().getChunkNodeByBlastChunk(m_pNewBlastAsset, m_NewChunkIndexes);
+ for (BlastChunkNode* node : chunkNodes)
+ {
+ node->setVisible(true);
+ selectTreeItem(node);
+ }
+
+ m_pNewBlastAsset = nullptr;
+ m_NewChunkIndexes.clear();
+
+ _updateData = true;
}
-void BlastSceneTree::_addChunkUI(const BlastNode* parentNode, QTreeWidgetItem* parentTreeItem)
+void BlastSceneTree::_addChunkUI(const BlastNode* parentNode, QStandardItem* parentTreeItem)
{
if (parentNode != nullptr && parentTreeItem != nullptr)
{
@@ -1507,43 +2260,47 @@ void BlastSceneTree::_addChunkUI(const BlastNode* parentNode, QTreeWidgetItem* p
if (node == nullptr)
continue;
- QTreeWidgetItem* treeWidgetItem = nullptr;
+ QStandardItem* treeWidgetItem = new QStandardItem();
+ parentTreeItem->appendRow(treeWidgetItem);
if (node->getType() == eChunk)
{
- BlastChunkNode* chunk = static_cast<BlastChunkNode*>(node);
- treeWidgetItem = new QTreeWidgetItem(parentTreeItem);
- treeWidgetItem->setText(0, chunk->name.c_str());
- if (chunk->isSupport())
+ BlastChunkNode* chunkNode = static_cast<BlastChunkNode*>(node);
+ treeWidgetItem->setText(chunkNode->name.c_str());
+
+ BPPChunk* chunk = static_cast<BPPChunk*>(chunkNode->getData());
+ if (!chunk->support)
{
- treeWidgetItem->setIcon(0, QIcon(":/AppMainWindow/images/Chunk_Support_Unstatic.png"));
+ treeWidgetItem->setIcon(sChunkUUIcon);
}
- else
+ else if (chunk->support && !chunk->staticFlag)
+ {
+ treeWidgetItem->setIcon(sChunkSUIcon);
+ }
+ else if (chunk->support && chunk->staticFlag)
{
- treeWidgetItem->setIcon(0, QIcon(":/AppMainWindow/images/Chunk_Unsupport_Unstatic.png"));
+ treeWidgetItem->setIcon(sChunkSSIcon);
}
- _addChunkUI(chunk, treeWidgetItem);
+ _addChunkUI(chunkNode, treeWidgetItem);
}
else if (node->getType() == eBond)
{
BlastBondNode* bond = static_cast<BlastBondNode*>(node);
- treeWidgetItem = new QTreeWidgetItem(parentTreeItem);
- treeWidgetItem->setIcon(0, QIcon(":/AppMainWindow/images/Bond.png"));
- treeWidgetItem->setText(0, bond->name.c_str());
+ treeWidgetItem->setIcon(sBondIcon);
+ treeWidgetItem->setText(bond->name.c_str());
}
if (treeWidgetItem == nullptr)
continue;
- VisualButton* btn = new VisualButton(this, node);
- ui.blastSceneTree->setItemWidget(treeWidgetItem, 1, btn);
+
_treeItemDataMap.insert(treeWidgetItem, node);
_treeDataItemMap.insert(node, treeWidgetItem);
}
}
}
-void BlastSceneTree::_updateChunkTreeItemAndMenu(BPPChunk* chunk, QTreeWidgetItem* chunkItem)
+void BlastSceneTree::_updateChunkTreeItemAndMenu(BPPChunk* chunk, QStandardItem* chunkItem)
{
assert(chunk != nullptr);
@@ -1554,309 +2311,368 @@ void BlastSceneTree::_updateChunkTreeItemAndMenu(BPPChunk* chunk, QTreeWidgetIte
if (!chunk->support && !chunk->staticFlag)
{
_removeSupportAction->setEnabled(false);
- chunkItem->setIcon(0, QIcon(":/AppMainWindow/images/Chunk_Unsupport_Unstatic.png"));
+ chunkItem->setIcon(sChunkUUIcon);
}
else if (chunk->support && !chunk->staticFlag)
{
_makeSupportAction->setEnabled(false);
- chunkItem->setIcon(0, QIcon(":/AppMainWindow/images/Chunk_Support_Unstatic.png"));
+ chunkItem->setIcon(sChunkSUIcon);
}
else if (chunk->support && chunk->staticFlag)
{
_makeStaticSupportAction->setEnabled(false);
- chunkItem->setIcon(0, QIcon(":/AppMainWindow/images/Chunk_Support_Static.png"));
+ chunkItem->setIcon(sChunkSSIcon);
}
}
void BlastSceneTree::_updateChunkTreeItems()
{
- for (QMap<BlastNode*, QTreeWidgetItem*>::iterator itr = _treeDataItemMap.begin(); itr != _treeDataItemMap.end(); ++itr)
+ for (QMap<BlastNode*, QStandardItem*>::iterator itr = _treeDataItemMap.begin(); itr != _treeDataItemMap.end(); ++itr)
{
BlastNode* node = itr.key();
- QTreeWidgetItem* treeItem = itr.value();
+ QStandardItem* treeItem = itr.value();
if (eChunk == node->getType())
{
BPPChunk* chunk = static_cast<BPPChunk*>(node->getData());
- if (!chunk->support && !chunk->staticFlag)
+ if (!chunk->support)
{
- treeItem->setIcon(0, QIcon(":/AppMainWindow/images/Chunk_Unsupport_Unstatic.png"));
+ treeItem->setIcon(sChunkUUIcon);
}
else if (chunk->support && !chunk->staticFlag)
{
- treeItem->setIcon(0, QIcon(":/AppMainWindow/images/Chunk_Support_Unstatic.png"));
+ treeItem->setIcon(sChunkSUIcon);
}
else if (chunk->support && chunk->staticFlag)
{
- treeItem->setIcon(0, QIcon(":/AppMainWindow/images/Chunk_Support_Static.png"));
+ treeItem->setIcon(sChunkSSIcon);
+ }
+ }
+ }
+}
+
+void BlastSceneTree::ApplyAutoSelectNewChunks(BlastAsset* pNewBlastAsset, std::vector<uint32_t>& NewChunkIndexes)
+{
+ if (pNewBlastAsset == nullptr || NewChunkIndexes.size() == 0)
+ {
+ return;
+ }
+
+ m_pNewBlastAsset = pNewBlastAsset;
+ m_NewChunkIndexes.clear();
+ for (uint32_t nci : NewChunkIndexes)
+ {
+ m_NewChunkIndexes.push_back(nci);
+ }
+}
+
+/*
+BlastAssetNode* BlastTreeData::addBlastAsset(BPPAsset& asset)
+{
+ BlastAsset* pBlastAsset = nullptr;
+ SampleManager* pSampleManager = SampleManager::ins();
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator it;
+ for (it = AssetDescMap.begin(); it != AssetDescMap.end(); it++)
+ {
+ std::string assetname = asset.name.buf;
+ if (it->second.name == assetname)
+ {
+ pBlastAsset = it->first;
+ }
+ }
+
+ BlastAssetNode* assetNode = new BlastAssetNode(asset.name.buf, asset);
+ _assets.push_back(assetNode);
+ _blastProjectDataToNodeMap.insert(std::make_pair((void*)&asset, assetNode));
+
+ std::vector<BPPChunk*> childChunks = BlastProject::ins().getChildrenChunks(asset, -1);
+ int childChunksSize = childChunks.size();
+ for (size_t i = 0; i < childChunksSize; ++i)
+ {
+ BPPChunk& chunk = *(childChunks[i]);
+ BlastChunkNode* chunkNode = new BlastChunkNode(chunk.name.buf, chunk, pBlastAsset);
+ assetNode->children.push_back(chunkNode);
+ chunkNode->setParent(assetNode);
+ _blastProjectDataToNodeMap.insert(std::make_pair((void*)&chunk, chunkNode));
+
+ _addChunkNode(chunk, asset, chunkNode, pBlastAsset);
+ }
+
+ return assetNode;
+}
+
+void BlastTreeData::removeBlastAsset(BPPAsset& asset)
+{
+ _removeChunkNode(asset);
+
+ std::map<void*, BlastNode*>::iterator it = _blastProjectDataToNodeMap.find(&asset);
+ if (it == _blastProjectDataToNodeMap.end())
+ {
+ return;
+ }
+
+ BlastNode* node = it->second;
+ _blastProjectDataToNodeMap.erase(it);
+ std::vector<BlastAssetNode*>::iterator itAsset;
+ for (itAsset = _assets.begin(); itAsset != _assets.end(); itAsset++)
+ {
+ if (node == *itAsset)
+ {
+ _assets.erase(itAsset);
+ break;
+ }
+ }
+
+ delete node;
+}
+
+BlastAssetInstanceNode* BlastTreeData::addBlastInstance(BPPAssetInstance& instance)
+{
+ BlastAssetInstanceNode* blastAssetInstanceNode = new BlastAssetInstanceNode(instance.name.buf, instance);
+ _assetInstancesNode->children.push_back(blastAssetInstanceNode);
+ blastAssetInstanceNode->setParent(_assetInstancesNode);
+ void* pointer = (void*)&instance;
+ _blastProjectDataToNodeMap.insert(std::make_pair(pointer, blastAssetInstanceNode));
+ return blastAssetInstanceNode;
+}
+
+void BlastTreeData::removeBlastInstance(BPPAssetInstance& instance)
+{
+ void* pointer = (void*)&instance;
+ std::map<void*, BlastNode*>::iterator it = _blastProjectDataToNodeMap.find(pointer);
+ if (it == _blastProjectDataToNodeMap.end())
+ {
+ return;
+ }
+
+ BlastNode* node = it->second;
+ _blastProjectDataToNodeMap.erase(it);
+ delete node;
+
+ int count = _assetInstancesNode->children.size();
+ for (int i = count - 1; i >= 0; --i)
+ {
+ BlastNode* pBN = _assetInstancesNode->children[i];
+ if (pBN == node)
+ {
+ _assetInstancesNode->children.erase(_assetInstancesNode->children.begin() + i);
+ }
+ else
+ {
+ BlastAssetInstanceNode* blastAssetInstanceNode = dynamic_cast<BlastAssetInstanceNode*>(_assetInstancesNode->children[i]);
+ if (blastAssetInstanceNode && blastAssetInstanceNode->getData() == &instance)
+ {
+ _assetInstancesNode->children.erase(_assetInstancesNode->children.begin() + i);
}
}
}
}
-void BlastSceneTree::_selectTreeItem(BlastNode* node)
+BlastProjectileNode* BlastTreeData::addProjectile(PhysXSceneActor* projectile)
{
- QMap<BlastNode*, QTreeWidgetItem*>::iterator itr = _treeDataItemMap.find(node);
+ SceneController& sceneController = SampleManager::ins()->getSceneController();
+ BlastProjectileNode* projectileNode = new BlastProjectileNode(sceneController.getProjectileName(projectile), projectile);
+ _projectiles.push_back(projectileNode);
+ return projectileNode;
+}
+
+void BlastTreeData::clearProjectile()
+{
+ std::vector<BlastProjectileNode*>::iterator it;
+ for (it = _projectiles.begin(); it != _projectiles.end(); it++)
+ {
+ delete *it;
+ }
+ _projectiles.clear();
+}
+
+void BlastTreeData::refreshProjectDataToNodeMap(std::map<BPPAsset*, BPPAsset*>& changeMap)
+{
+ std::map<BPPAsset*, BPPAsset*>::iterator it;
+ std::map<void*, BlastNode*>::iterator itNode;
+ for (it = changeMap.begin(); it != changeMap.end(); it++)
+ {
+ itNode = _blastProjectDataToNodeMap.find(it->first);
+ if (itNode == _blastProjectDataToNodeMap.end())
+ {
+ continue;
+ }
+
+ BlastNode* node = itNode->second;
+ _blastProjectDataToNodeMap.erase(itNode);
+ _blastProjectDataToNodeMap[it->second] = node;
+ }
+}
+
+void BlastTreeData::refreshProjectDataToNodeMap(std::map<BPPAssetInstance*, BPPAssetInstance*>& changeMap)
+{
+ std::map<BPPAssetInstance*, BPPAssetInstance*>::iterator it;
+ std::map<void*, BlastNode*>::iterator itNode;
+ for (it = changeMap.begin(); it != changeMap.end(); it++)
+ {
+ itNode = _blastProjectDataToNodeMap.find(it->first);
+ if (itNode == _blastProjectDataToNodeMap.end())
+ {
+ continue;
+ }
+
+ BlastNode* node = itNode->second;
+ _blastProjectDataToNodeMap.erase(itNode);
+ _blastProjectDataToNodeMap[it->second] = node;
+ node->setData(it->second);
+ }
+}
+
+void BlastSceneTree::addBlastAsset(BPPAsset& asset)
+{
+ BlastAssetNode* assetNode = BlastTreeData::ins().addBlastAsset(asset);
+ if (assetNode == nullptr)
+ {
+ return;
+ }
+
+ QStandardItem* assetTreeWidgetItem = new QStandardItem();
+ _treeModel->appendRow(assetTreeWidgetItem);
+ assetTreeWidgetItem->setText(assetNode->name.c_str());
+ assetTreeWidgetItem->setIcon(sAssetIcon);
+ _treeItemDataMap.insert(assetTreeWidgetItem, assetNode);
+ _treeDataItemMap.insert(assetNode, assetTreeWidgetItem);
+
+ _addChunkUI(assetNode, assetTreeWidgetItem);
+
+ ui.blastSceneTree->expandAll();
+}
+
+void BlastSceneTree::removeBlastAsset(BPPAsset& asset)
+{
+ BlastNode* node = BlastTreeData::ins().getBlastNodeByProjectData(&asset);
+
+ QMap<BlastNode*, QStandardItem*>::iterator it = _treeDataItemMap.find(node);
+ if (it != _treeDataItemMap.end())
+ {
+ QStandardItem* item = it.value();
+
+ if (item != nullptr)
+ {
+ _treeModel->removeRow(_treeModel->indexFromItem(item).row());
+ ui.blastSceneTree->expandAll();
+ }
+ }
+
+ BlastTreeData::ins().removeBlastAsset(asset);
+}
+
+void BlastSceneTree::addBlastInstance(BPPAssetInstance& instance)
+{
+ BlastAssetInstanceNode* assetInstanceNode = BlastTreeData::ins().addBlastInstance(instance);
+ if (assetInstanceNode == nullptr)
+ {
+ return;
+ }
+
+ QStandardItem* assetInstanceItem = new QStandardItem();
+ _compositeTreeItem->appendRow(assetInstanceItem);
+ assetInstanceItem->setText(assetInstanceNode->name.c_str());
+ if (assetInstanceNode->getType() == eAssetInstance)
+ assetInstanceItem->setIcon(sAssetIcon);
+ _treeItemDataMap.insert(assetInstanceItem, assetInstanceNode);
+ _treeDataItemMap.insert(assetInstanceNode, assetInstanceItem);
+
+ ui.blastSceneTree->expandAll();
+}
+
+void BlastSceneTree::removeBlastInstance(BPPAssetInstance& instance)
+{
+ BlastNode* node = BlastTreeData::ins().getBlastNodeByProjectData(&instance);
+
+ QMap<BlastNode*, QStandardItem*>::iterator it = _treeDataItemMap.find(node);
+ if (it != _treeDataItemMap.end())
+ {
+ QStandardItem* item = it.value();
+
+ if (item != nullptr)
+ {
+ _compositeTreeItem->removeRow(_treeModel->indexFromItem(_compositeTreeItem).row());
+ ui.blastSceneTree->expandAll();
+ }
+ }
+
+ BlastTreeData::ins().removeBlastInstance(instance);
+}
+
+void BlastSceneTree::removeBlastInstances(BPPAsset& asset)
+{
+ std::vector<BPPAssetInstance*> instances;
+ BlastProject::ins().getAssetInstances(asset.ID, instances);
+
+ std::vector<BPPAssetInstance*>::iterator it;
+ for (it = instances.begin(); it != instances.end(); it++)
+ {
+ removeBlastInstance(**it);
+ BlastTreeData::ins().removeBlastInstance(**it);
+ }
+}
+
+void BlastSceneTree::addProjectile(PhysXSceneActor* projectile)
+{
+ BlastProjectileNode* projectileNode = BlastTreeData::ins().addProjectile(projectile);
+ if (projectileNode == nullptr)
+ {
+ return;
+ }
+
+ QStandardItem* projectileTreeItem = new QStandardItem();
+ projectileTreeItem->setText(projectileNode->name.c_str());
+ projectileTreeItem->setIcon(sProjectileIcon);
+ _treeModel->appendRow(projectileTreeItem);
+ _projectileItemActorMap[projectileTreeItem] = projectile;;
+}
+
+void BlastSceneTree::clearProjectile()
+{
+ QMap<QStandardItem*, PhysXSceneActor*>::iterator it;
+ for (it =_projectileItemActorMap.begin(); it != _projectileItemActorMap.end(); it++)
+ {
+ _treeModel->removeRow(_treeModel->indexFromItem(it.key()).row());
+ }
+ _projectileItemActorMap.clear();
+
+ BlastTreeData::ins().clearProjectile();
+}
+*/
+BlastNode* BlastSceneTree::getBlastNodeByItem(QStandardItem* item)
+{
+ QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(item);
+ if (itr == _treeItemDataMap.end())
+ return nullptr;
+
+ return itr.value();
+}
+
+PhysXSceneActor* BlastSceneTree::getProjectileActorByItem(QStandardItem* item)
+{
+ QMap<QStandardItem*, PhysXSceneActor*>::iterator itr = _projectileItemActorMap.find(item);
+ if (itr == _projectileItemActorMap.end())
+ return nullptr;
+
+ return itr.value();
+}
+
+void BlastSceneTree::selectTreeItem(BlastNode* node, bool updateData)
+{
+ _updateData = updateData;
+ QMap<BlastNode*, QStandardItem*>::iterator itr = _treeDataItemMap.find(node);
if (itr != _treeDataItemMap.end())
{
- ui.blastSceneTree->setItemSelected(itr.value(), true);
- }
-}
-
-//void BlastSceneTree::_createTestData()
-//{
-// BPPBlast& blast = BlastProject::ins().getParams().blast;
-//
-// // compoistie
-// {
-// BPPComposite& composite = blast.composite;
-// composite.composite.buf = nullptr;
-// composite.visible = true;
-//
-// copy(composite.composite, "BlastComposite");
-//
-// // asset instance array
-// {
-// BPPAssetInstanceArray& instanceArray = composite.blastAssetInstances;
-// instanceArray.buf = new BPPAssetInstance[4];
-// instanceArray.arraySizes[0] = 4;
-// instanceArray.buf[0].name.buf = nullptr;
-// instanceArray.buf[1].name.buf = nullptr;
-// instanceArray.buf[2].name.buf = nullptr;
-// instanceArray.buf[3].name.buf = nullptr;
-// instanceArray.buf[0].source.buf = nullptr;
-// instanceArray.buf[1].source.buf = nullptr;
-// instanceArray.buf[2].source.buf = nullptr;
-// instanceArray.buf[3].source.buf = nullptr;
-//
-// copy(instanceArray.buf[0].name, "BlastAsset_instance1");
-// instanceArray.buf[0].visible = true;
-//
-// copy(instanceArray.buf[1].name, "BlastAsset_instance2");
-// instanceArray.buf[1].visible = true;
-//
-// copy(instanceArray.buf[2].name, "BlastAsset1_instance1");
-// instanceArray.buf[2].visible = true;
-//
-// copy(instanceArray.buf[3].name, "BlastAsset1_instance2");
-// instanceArray.buf[3].visible = true;
-// }
-//
-// // landmark array
-// {
-// BPPLandmarkArray& landmarkArray = composite.landmarks;
-// landmarkArray.buf = new BPPLandmark[2];
-// landmarkArray.arraySizes[0] = 2;
-// landmarkArray.buf[0].name.buf = nullptr;
-// landmarkArray.buf[1].name.buf = nullptr;
-//
-// copy(landmarkArray.buf[0].name, "Landmark_1");
-// copy(landmarkArray.buf[1].name, "Landmark_2");
-// }
-// }
-//
-// // asset array
-// {
-// BPPAssetArray& assetArray = blast.blastAssets;
-// assetArray.buf = new BPPAsset[2];
-// assetArray.arraySizes[0] = 2;
-//
-// // asset 0
-// {
-// BPPAsset& asset = assetArray.buf[0];
-// asset.path.buf = nullptr;
-// asset.activePreset.buf = nullptr;
-// asset.bonds.buf = nullptr;
-// asset.chunks.buf = nullptr;
-//
-// copy(asset.path, "c:/temp/BlastAsset.asset");
-//
-// // chunks
-// {
-// asset.chunks.buf = new BPPChunk[10];
-// asset.chunks.arraySizes[0] = 10;
-// for (int i = 0; i < 10; ++i)
-// {
-// asset.chunks.buf[i].name.buf = nullptr;
-// asset.chunks.buf[i].visible = true;
-// asset.chunks.buf[i].staticFlag = false;
-// }
-//
-// copy(asset.chunks.buf[0].name, "Chunk_L0_00");
-// asset.chunks.buf[0].ID = 0;
-// asset.chunks.buf[0].parentID = -1;
-// asset.chunks.buf[0].support = false;
-//
-// copy(asset.chunks.buf[1].name, "Chunk_L0_01");
-// asset.chunks.buf[1].ID = 1;
-// asset.chunks.buf[1].parentID = -1;
-// asset.chunks.buf[1].support = false;
-//
-// copy(asset.chunks.buf[2].name, "Chunk_L1_02");
-// asset.chunks.buf[2].ID = 2;
-// asset.chunks.buf[2].parentID = 0;
-// asset.chunks.buf[2].support = false;
-//
-// copy(asset.chunks.buf[3].name, "Chunk_L1_03");
-// asset.chunks.buf[3].ID = 3;
-// asset.chunks.buf[3].parentID = 0;
-// asset.chunks.buf[3].support = false;
-//
-// copy(asset.chunks.buf[4].name, "Chunk_L1_04");
-// asset.chunks.buf[4].ID = 4;
-// asset.chunks.buf[4].parentID = 1;
-// asset.chunks.buf[4].support = false;
-//
-// copy(asset.chunks.buf[5].name, "Chunk_L1_05");
-// asset.chunks.buf[5].ID = 5;
-// asset.chunks.buf[5].parentID = 1;
-// asset.chunks.buf[5].support = false;
-//
-// copy(asset.chunks.buf[6].name, "Chunk_L2_06");
-// asset.chunks.buf[6].ID = 6;
-// asset.chunks.buf[6].parentID = 2;
-// asset.chunks.buf[6].support = true;
-//
-// copy(asset.chunks.buf[7].name, "Chunk_L2_07");
-// asset.chunks.buf[7].ID = 7;
-// asset.chunks.buf[7].parentID = 2;
-// asset.chunks.buf[7].support = true;
-//
-// copy(asset.chunks.buf[8].name, "Chunk_L2_08");
-// asset.chunks.buf[8].ID = 8;
-// asset.chunks.buf[8].parentID = 3;
-// asset.chunks.buf[8].support = true;
-//
-// copy(asset.chunks.buf[9].name, "Chunk_L2_09");
-// asset.chunks.buf[9].ID = 9;
-// asset.chunks.buf[9].parentID = 3;
-// asset.chunks.buf[9].support = true;
-// }
-//
-// // bonds
-// {
-// asset.bonds.buf = new BPPBond[4];
-// asset.bonds.arraySizes[0] = 4;
-// for (int i = 0; i < 4; ++i)
-// {
-// asset.bonds.buf[i].name.buf = nullptr;
-// asset.bonds.buf[i].visible = true;
-// asset.bonds.buf[i].support.healthMask.buf = nullptr;
-// }
-//
-// copy(asset.bonds.buf[0].name, "Chunk_L2_08");
-// asset.bonds.buf[0].fromChunk = 6;
-// asset.bonds.buf[0].toChunk = 8;
-//
-// copy(asset.bonds.buf[1].name, "Chunk_L2_06");
-// asset.bonds.buf[1].fromChunk = 6;
-// asset.bonds.buf[1].toChunk = 8;
-//
-// copy(asset.bonds.buf[2].name, "Chunk_L2_09");
-// asset.bonds.buf[2].fromChunk = 7;
-// asset.bonds.buf[2].toChunk = 9;
-//
-// copy(asset.bonds.buf[3].name, "Chunk_L2_07");
-// asset.bonds.buf[3].fromChunk = 7;
-// asset.bonds.buf[3].toChunk = 9;
-// }
-// }
-//
-// // asset 1
-// {
-// BPPAsset& asset = assetArray.buf[1];
-// asset.path.buf = nullptr;
-// asset.activePreset.buf = nullptr;
-// asset.bonds.buf = nullptr;
-// asset.chunks.buf = nullptr;
-//
-// copy(asset.path, "c:/temp/BlastAsset1.asset");
-// {
-// asset.chunks.buf = new BPPChunk[10];
-// asset.chunks.arraySizes[0] = 10;
-// for (int i = 0; i < 10; ++i)
-// {
-// asset.chunks.buf[i].name.buf = nullptr;
-// asset.chunks.buf[i].visible = true;
-// }
-//
-// copy(asset.chunks.buf[0].name, "Chunk_L0_00");
-// asset.chunks.buf[0].ID = 0;
-// asset.chunks.buf[0].parentID = -1;
-// asset.chunks.buf[0].support = false;
-//
-// copy(asset.chunks.buf[1].name, "Chunk_L0_01");
-// asset.chunks.buf[1].ID = 1;
-// asset.chunks.buf[1].parentID = -1;
-// asset.chunks.buf[1].support = false;
-//
-// copy(asset.chunks.buf[2].name, "Chunk_L1_02");
-// asset.chunks.buf[2].ID = 2;
-// asset.chunks.buf[2].parentID = 0;
-// asset.chunks.buf[2].support = false;
-//
-// copy(asset.chunks.buf[3].name, "Chunk_L1_03");
-// asset.chunks.buf[3].ID = 3;
-// asset.chunks.buf[3].parentID = 0;
-// asset.chunks.buf[3].support = false;
-//
-// copy(asset.chunks.buf[4].name, "Chunk_L1_04");
-// asset.chunks.buf[4].ID = 4;
-// asset.chunks.buf[4].parentID = 1;
-// asset.chunks.buf[4].support = false;
-//
-// copy(asset.chunks.buf[5].name, "Chunk_L1_05");
-// asset.chunks.buf[5].ID = 5;
-// asset.chunks.buf[5].parentID = 1;
-// asset.chunks.buf[5].support = false;
-//
-// copy(asset.chunks.buf[6].name, "Chunk_L2_06");
-// asset.chunks.buf[6].ID = 6;
-// asset.chunks.buf[6].parentID = 2;
-// asset.chunks.buf[6].support = true;
-//
-// copy(asset.chunks.buf[7].name, "Chunk_L2_07");
-// asset.chunks.buf[7].ID = 7;
-// asset.chunks.buf[7].parentID = 2;
-// asset.chunks.buf[7].support = true;
-//
-// copy(asset.chunks.buf[8].name, "Chunk_L2_08");
-// asset.chunks.buf[8].ID = 8;
-// asset.chunks.buf[8].parentID = 3;
-// asset.chunks.buf[8].support = true;
-//
-// copy(asset.chunks.buf[9].name, "Chunk_L2_09");
-// asset.chunks.buf[9].ID = 9;
-// asset.chunks.buf[9].parentID = 3;
-// asset.chunks.buf[9].support = true;
-// }
-// }
-// }
-//
-// // projectile
-// {
-// BPPProjectileArray& projectileArray = blast.projectiles;
-// projectileArray.buf = new BPPProjectile[1];
-// projectileArray.arraySizes[0] = 1;
-// projectileArray.buf[0].name.buf = nullptr;
-// copy(projectileArray.buf[0].name, "Projectile");
-// projectileArray.buf[0].visible = true;
-// }
-//
-// // graphics meshes
-// {
-// BPPGraphicsMeshArray& graphicsMeshArray = blast.graphicsMeshes;
-// graphicsMeshArray.buf = new BPPGraphicsMesh[3];
-// graphicsMeshArray.arraySizes[0] = 3;
-// graphicsMeshArray.buf[0].name.buf = nullptr;
-// copy(graphicsMeshArray.buf[0].name, "SurfaceMesh1");
-// graphicsMeshArray.buf[0].visible = true;
-//
-// graphicsMeshArray.buf[1].name.buf = nullptr;
-// copy(graphicsMeshArray.buf[1].name, "SurfaceMesh2");
-// graphicsMeshArray.buf[1].visible = true;
-//
-// graphicsMeshArray.buf[2].name.buf = nullptr;
-// copy(graphicsMeshArray.buf[2].name, "DisplayMesh1");
-// graphicsMeshArray.buf[2].visible = true;
-// }
-//}
+ QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel();
+ selectionModel->select(_treeModel->indexFromItem(itr.value()), QItemSelectionModel::Select);
+ }
+
+ _updateData = true;
+}
+
+void BlastSceneTree::selectTreeItem(BlastFamily* family)
+{
+ BlastAssetInstanceNode* instanceNode = BlastTreeData::ins().getAssetInstanceNode(family);
+ selectTreeItem(instanceNode, false);
+} \ No newline at end of file
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.h b/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.h
index d8495ee..423c2b7 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.h
@@ -7,9 +7,14 @@
#include <vector>
#include <string>
#include <QtCore/QMap>
+#include <QtGui/QStandardItemModel>
+#include <QtWidgets/QStyledItemDelegate>
class QTreeWidgetItem;
class BlastAsset;
+class PhysXSceneActor;
+class BlastNode;
+class BlastFamily;
enum EBlastNodeType
{
@@ -19,8 +24,21 @@ enum EBlastNodeType
eProjectile,
eGraphicsMesh,
eAssetInstance,
- eLandmark,
- eComposite,
+ eAssetInstances,
+};
+
+class BlastVisitorBase
+{
+public:
+ BlastVisitorBase() : _continueTraversing(true)
+ {
+ }
+
+ virtual void visit(BlastNode *pNode) { return; }
+ inline bool continueTraversing(void) const { return _continueTraversing; }
+
+protected:
+ bool _continueTraversing;
};
class BlastNode
@@ -33,9 +51,15 @@ public:
{
}
- void* getData() { return _data; }
+ virtual ~BlastNode()
+ {
+ }
+
+ inline void* getData() { return _data; }
void setParent(BlastNode* parent) { _parent = parent; }
BlastNode* getParent() { return _parent; }
+ void traverse(BlastVisitorBase& visitor);
+
virtual EBlastNodeType getType() = 0;
virtual bool getVisible() = 0;
virtual void setVisible(bool val) = 0;
@@ -44,6 +68,9 @@ public:
std::vector<BlastNode*> children;
protected:
+ inline void setData(void* data) { _data = data; }
+
+private:
void* _data;
BlastNode* _parent;
};
@@ -56,8 +83,9 @@ public:
{
}
virtual EBlastNodeType getType() { return eBond; }
- virtual bool getVisible() { return ((BPPBond*)_data)->visible; }
- virtual void setVisible(bool val) { ((BPPBond*)_data)->visible = val; }
+ virtual bool getVisible() { return ((BPPBond*)getData())->visible; }
+ virtual void setVisible(bool val) { ((BPPBond*)getData())->visible = val; }
+ bool isWolrd() { return ((BPPBond*)getData())->toChunk == 0xFFFFFFFF; }
private:
std::vector<BlastNode*> children;
@@ -72,10 +100,11 @@ public:
_assetPtr = assetPtr;
}
virtual EBlastNodeType getType() { return eChunk; }
- virtual bool getVisible() { return ((BPPChunk*)_data)->visible; }
- virtual void setVisible(bool val);// { ((BPPChunk*)_data)->visible = val; }
+ virtual bool getVisible() { return ((BPPChunk*)getData())->visible; }
+ virtual void setVisible(bool val);// { ((BPPChunk*)getData())->visible = val; }
void setSelected(bool val);
- bool isSupport() { return ((BPPChunk*)_data)->support; }
+ bool isSupport() { return ((BPPChunk*)getData())->support; }
+ bool isStatic() { return ((BPPChunk*)getData())->staticFlag; }
void* _assetPtr;
};
@@ -87,20 +116,21 @@ public:
{
}
virtual EBlastNodeType getType() { return eAsset; }
- virtual bool getVisible() { return ((BPPAsset*)_data)->visible; }
- virtual void setVisible(bool val) { ((BPPAsset*)_data)->visible = val; }
+ virtual bool getVisible() { return ((BPPAsset*)getData())->visible; }
+ virtual void setVisible(bool val) { ((BPPAsset*)getData())->visible = val; }
+ void setSelected(bool val);
};
class BlastProjectileNode : public BlastNode
{
public:
- BlastProjectileNode(const std::string& inName, BPPProjectile& inData)
- : BlastNode(inName, &inData)
+ BlastProjectileNode(const std::string& inName, PhysXSceneActor* inData)
+ : BlastNode(inName, inData)
{
}
virtual EBlastNodeType getType() { return eProjectile; }
- virtual bool getVisible() { return ((BPPProjectile*)_data)->visible; }
- virtual void setVisible(bool val) { ((BPPProjectile*)_data)->visible = val; }
+ virtual bool getVisible();
+ virtual void setVisible(bool val);
};
class BlastGraphicsMeshNode : public BlastNode
@@ -111,8 +141,8 @@ public:
{
}
virtual EBlastNodeType getType() { return eGraphicsMesh; }
- virtual bool getVisible() { return ((BPPGraphicsMesh*)_data)->visible; }
- virtual void setVisible(bool val) { ((BPPGraphicsMesh*)_data)->visible = val; }
+ virtual bool getVisible() { return true; }
+ virtual void setVisible(bool val) { }
};
class BlastAssetInstanceNode : public BlastNode
@@ -122,34 +152,25 @@ public:
: BlastNode(inName, &inData)
{
}
- virtual EBlastNodeType getType() { return eAssetInstance; }
- virtual bool getVisible() { return ((BPPAssetInstance*)_data)->visible; }
- virtual void setVisible(bool val) { ((BPPAssetInstance*)_data)->visible = val; }
- void setSelected(bool val);
-};
-
-class BlastLandmarkNode : public BlastNode
-{
-public:
- BlastLandmarkNode(const std::string& inName, BPPLandmark& inData)
- : BlastNode(inName, &inData)
+ ~BlastAssetInstanceNode()
{
}
- virtual EBlastNodeType getType() { return eLandmark; }
- virtual bool getVisible() { return ((BPPLandmark*)_data)->visible; }
- virtual void setVisible(bool val) { ((BPPLandmark*)_data)->visible = val; }
+ virtual EBlastNodeType getType() { return eAssetInstance; }
+ virtual bool getVisible() { return ((BPPAssetInstance*)getData())->visible; }
+ virtual void setVisible(bool val) { ((BPPAssetInstance*)getData())->visible = val; }
+ void setSelected(bool val);
};
-class BlastCompositeNode : public BlastNode
+class BlastAssetInstancesNode : public BlastNode
{
public:
- BlastCompositeNode(const std::string& inName, BPPComposite& inData)
- : BlastNode(inName, &inData)
+ BlastAssetInstancesNode(const std::string& inName)
+ : BlastNode(inName, nullptr)
{
}
- virtual EBlastNodeType getType() { return eComposite; }
- virtual bool getVisible() { return ((BPPComposite*)_data)->visible; }
- virtual void setVisible(bool val) { ((BPPComposite*)_data)->visible = val; }
+ virtual EBlastNodeType getType() { return eAssetInstances; }
+ virtual bool getVisible() { return true; }
+ virtual void setVisible(bool val) { return; }
};
class BlastTreeData
@@ -158,19 +179,38 @@ public:
static BlastTreeData& ins();
static bool isChild(BlastChunkNode* parent, BlastChunkNode* child);
static std::vector<BlastChunkNode*> getTopChunkNodes(std::vector<BlastChunkNode*>& nodes);
+ static int getDepth(BlastNode* node);// if node is not a chunk or bond, then depth is -1.
static bool isRoot(BlastChunkNode* node);
static bool isLeaf(BlastChunkNode* node);
static void makeSupport(BlastChunkNode* node);
static void makeStaticSupport(BlastChunkNode* node);
static void removeSupport(BlastChunkNode* node);
+ static std::string getAssetName(BlastAsset* asset);
+ static BlastAsset* getAsset(std::string assetName);
BlastNode* getBlastNodeByProjectData(void* blastProjectData);
- BlastCompositeNode* getCompsiteNode() { return _composite; }
+ BlastAssetInstancesNode* getBlastAssetInstancesNode() { return _assetInstancesNode; }
std::vector<BlastAssetNode*>& getAssetNodes() { return _assets; }
BlastAsset* getAsset(BlastNode* node);
+ BlastAssetNode* getAssetNode(BlastAsset* asset);
std::vector<BlastProjectileNode*>& getProjectileNodes() { return _projectiles; }
std::vector<BlastGraphicsMeshNode*>& getGraphicsMeshNodes() { return _graphicsMeshes; }
std::vector<BlastChunkNode*> getChunkNodeByBlastChunk(const BlastAsset* asset, const std::vector<uint32_t>& chunkIndexes);
+ std::vector<BlastChunkNode*> getRootChunkNodeByInstance(const BlastAssetInstanceNode* node);
+ std::vector<BlastNode*> getNodesByDepth(BlastAssetNode* node, uint32_t depth);
+ std::vector<BlastNode*> getNodesByDepth(uint32_t depth);
+ std::vector<BlastNode*> getNodesByDepth(std::vector<uint32_t> depths);
+ BlastNode* getNodeByIndex(uint32_t assetIndex, uint32_t chunkIndex);
+ std::vector<BlastChunkNode*> getSupportChunkNodes(BlastAssetNode* node);
+ std::vector<BlastChunkNode*> getSupportChunkNodes();
+ std::vector<BlastChunkNode*> getSiblingChunkNodes(BlastChunkNode* node);
+ BlastChunkNode* getSupportAncestor(BlastChunkNode* node);
+ const std::vector<BlastNode*>& getAllChunkNodes(std::vector<BlastNode*>& res, BlastAssetNode* node);
+ const std::vector<BlastNode*>& getAllChunkNodes(std::vector<BlastNode*>& res);
+ const std::vector<BlastNode*>& getAllLeavesChunkNodes(std::vector<BlastNode*>& res, BlastAssetNode* node);
+ const std::vector<BlastNode*>& getAllLeavesChunkNodes(std::vector<BlastNode*>& res);
+ const std::vector<BlastNode*>& getChunkNodesFullCoverage(std::vector<BlastNode*>& res, BlastAssetNode* node, int depth);
+ const std::vector<BlastNode*>& getChunkNodesFullCoverage(std::vector<BlastNode*>& res, int depth);
bool isCompleteSupportAsset(const BlastAsset* asset);
bool isCompleteSupportAsset(const BlastAssetNode* node);
@@ -181,19 +221,37 @@ public:
BlastAssetInstanceNode* addAssetInstance(const BlastAsset* asset);
void remove(const BlastAssetNode* node);
void remove(const BlastAssetInstanceNode* node);
+ BlastAssetInstanceNode* getAssetInstanceNode(BlastFamily* family);
+ BlastAssetInstanceNode* getAssetInstanceNode(BPPAssetInstance* instance);
+ std::vector<BlastAssetInstanceNode*> getAssetInstanceNodes(BlastChunkNode* chunkNode);
void update();
void update(const BlastAsset* asset);
- void updateVisible(uint32_t assetIndex, uint32_t chunkIndex, bool visible);
-
+ /*
+ BlastAssetNode* addBlastAsset(BPPAsset& asset);
+ void removeBlastAsset(BPPAsset& asset);
+
+ BlastAssetInstanceNode* addBlastInstance(BPPAssetInstance& instance);
+ void removeBlastInstance(BPPAssetInstance& instance);
+
+ BlastProjectileNode* addProjectile(PhysXSceneActor* projectile);
+ void clearProjectile();
+
+ void refreshProjectDataToNodeMap(std::map<BPPAsset*, BPPAsset*>& changeMap);
+ void refreshProjectDataToNodeMap(std::map<BPPAssetInstance*, BPPAssetInstance*>& changeMap);
+ */
+
+ void traverse(BlastVisitorBase& visitor);
+
private:
BlastTreeData();
- void _addChunkNode(const BPPChunk& parentData, BPPAsset& asset, BlastChunkNode* parentNode, void* assetPtr);
+ void _addChunkNode(BPPChunk& parentData, BPPAsset& asset, BlastChunkNode* parentNode, void* assetPtr);
+ void _removeChunkNode(BPPAsset& asset);
void _freeBlastNode();
BlastAssetNode* _getAssetNode(const BlastAsset* asset);
private:
- BlastCompositeNode* _composite;
+ BlastAssetInstancesNode* _assetInstancesNode;
std::vector<BlastAssetNode*> _assets;
std::vector<BlastProjectileNode*> _projectiles;
std::vector<BlastGraphicsMeshNode*> _graphicsMeshes;
@@ -206,26 +264,29 @@ public:
virtual void dataSelected(std::vector<BlastNode*> selections) = 0;
};
-class VisualButton : public QWidget
+class BlastTreeViewDelegate : QStyledItemDelegate
{
Q_OBJECT
+
public:
- VisualButton(QWidget* parent, BlastNode* blastItem);
+ BlastTreeViewDelegate(QObject* parent, QStandardItemModel* model);
+ void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
+ bool editorEvent(QEvent* evt, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index);
-protected slots:
- void on_visualbility_toggled(bool checked);
-private:
- void _updateBlast(bool visible);
+protected:
+ bool eventFilter(QObject* object, QEvent* event);
private:
- QPushButton* _button;
- BlastNode* _blastItem;
+ QStandardItemModel* _treeModel;
};
+class BlastSceneTreeDataLock;
+
class BlastSceneTree : public QDockWidget, public ISceneObserver
{
Q_OBJECT
+ friend class BlastSceneTreeDataLock;
public:
static BlastSceneTree* ins();
@@ -234,6 +295,8 @@ public:
void updateValues(bool updataData = true);
+ void clear();
+
virtual void dataSelected(std::vector<BlastNode*> selections);
void addObserver(ISceneObserver* observer);
@@ -245,49 +308,82 @@ public:
void makeSupport();
void makeStaticSupport();
void removeSupport();
+ void makeWorld();
+ void removeWorld();
void bondChunks();
void bondChunksWithJoints();
void removeAllBonds();
+ void setChunkSelected(std::vector<uint32_t> depths, bool selected);
+ void setChunkVisible(std::vector<uint32_t> depths, bool bVisible);
+
+ void setChunkVisibleFullCoverage(int depth);
+ void hideAllChunks();
+ /*
+ void addBlastAsset(BPPAsset& asset);
+ void removeBlastAsset(BPPAsset& asset);
+
+ void addBlastInstance(BPPAssetInstance& instance);
+ void removeBlastInstance(BPPAssetInstance& instance);
+ void removeBlastInstances(BPPAsset& asset);
+
+ void addProjectile(PhysXSceneActor* projectile);
+ void clearProjectile();
+ */
+ BlastNode* getBlastNodeByItem(QStandardItem* item);
+ PhysXSceneActor* getProjectileActorByItem(QStandardItem* item);
+
+ void selectTreeItem(BlastNode* node, bool updateData = true);
+ void selectTreeItem(BlastFamily* family);
+
+ void ApplyAutoSelectNewChunks(BlastAsset* pNewBlastAsset, std::vector<uint32_t>& NewChunkIndexes);
+
protected slots:
void on_btnAsset_clicked();
void on_assetComposite_clicked();
void on_btnChunk_clicked();
void on_btnBond_clicked();
void on_btnProjectile_clicked();
- void on_blastSceneTree_customContextMenuRequested(const QPoint &pos);
- void on_blastSceneTree_itemSelectionChanged();
+ void on_btnExpandCollapse_clicked();
+ void on_blastSceneTree_customContextMenuRequested(const QPoint& pos);
+ void on_blastSceneTree_itemSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
void onMakeSupportMenuItemClicked();
void onMakeStaticSupportMenuItemClicked();
void onRemoveSupportMenuItemClicked();
+ void onMakeWorldMenuItemClicked();
+ void onRemoveWorldMenuItemClicked();
void onBondChunksMenuItemClicked();
void onBondChunksWithJointsMenuItemClicked();
void onRemoveAllBondsMenuItemClicked();
+ void onCollapseExpandClicked();
private:
void _updateTreeUIs();
- void _addChunkUI(const BlastNode* parentNode, QTreeWidgetItem* parentTreeItem);
- void _updateChunkTreeItemAndMenu(BPPChunk* chunk, QTreeWidgetItem* chunkItem);
+ void _addChunkUI(const BlastNode* parentNode, QStandardItem* parentTreeItem);
+ void _updateChunkTreeItemAndMenu(BPPChunk* chunk, QStandardItem* chunkItem);
void _updateChunkTreeItems();
- void _selectTreeItem(BlastNode* node);
-
- //void _createTestData();
-
private:
Ui::BlastSceneTree ui;
- QMap<QTreeWidgetItem*, BlastNode*> _treeItemDataMap;
- QMap<BlastNode*, QTreeWidgetItem*> _treeDataItemMap;
- QMenu* _treeChunkContextMenu;
- QMenu* _treeBondContextMenu;
+ QStandardItemModel* _treeModel;
+ QMap<QStandardItem*, BlastNode*> _treeItemDataMap;
+ QMap<BlastNode*, QStandardItem*> _treeDataItemMap;
+ QMenu* _treeContextMenu;
QAction* _makeSupportAction;
QAction* _makeStaticSupportAction;
QAction* _removeSupportAction;
+ QAction* _makeWorldAction;
+ QAction* _removeWorldAction;
QAction* _bondChunksAction;
QAction* _bondChunksWithJointsAction;
QAction* _removeAllBondsAction;
std::vector<ISceneObserver*> _observers;
bool _updateData;
+// QStandardItem* _compositeTreeItem;
+ QMap<QStandardItem*, PhysXSceneActor*> _projectileItemActorMap;
+
+ BlastAsset* m_pNewBlastAsset;
+ std::vector<uint32_t> m_NewChunkIndexes;
};
#endif // BLASTSCENETREE_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.cpp b/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.cpp
index c5a743a..3d48059 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.cpp
@@ -5,8 +5,33 @@
#include "PhysXController.h"
#include "QtUtil.h"
+#include "SampleManager.h"
+#include "SceneController.h"
+#include "DamageToolController.h"
+#include "SelectionToolController.h"
+#include "ExplodeToolController.h"
+#include "GizmoToolController.h"
+#include "BlastController.h"
+#include "SourceAssetOpenDlg.h"
+#include "BlastPlugin.h"
+#include <QtWidgets/QButtonGroup>
+#include <QtWidgets/QActionGroup>
+#include "Shlwapi.h"
+#include "BlastSceneTree.h"
+#include "BlastFamily.h"
+#include "FileReferencesPanel.h"
+#include "GlobalSettings.h"
+#include "PxScene.h"
+#include "PxRigidDynamic.h"
+#include "ViewerOutput.h"
+
+#include <QtCore/QTimer>
+QTimer gDropTimer;
+int nExplodedViewState = 0;
+
BlastToolbar::BlastToolbar(QWidget* parent)
: QDockWidget(parent)
+ , m_fullCoverage(false)
{
// to hide the title bar completely must replace the default widget with a generic one
QWidget* titleWidget = new QWidget(this);
@@ -29,7 +54,7 @@ BlastToolbar::BlastToolbar(QWidget* parent)
sizePolicy1.setVerticalStretch(0);
btnOpenProject = new QPushButton(widget);
- setStyledToolTip(btnOpenProject, "Open Blast Asset");
+ setStyledToolTip(btnOpenProject, "Open Project");
const QFont& font = btnOpenProject->font();
QFont fontCopy(font);
fontCopy.setPixelSize(9);
@@ -43,7 +68,7 @@ BlastToolbar::BlastToolbar(QWidget* parent)
hLayout->addWidget(btnOpenProject);
btnSaveProject = new QPushButton(widget);
- setStyledToolTip(btnSaveProject, "Not Implement");
+ setStyledToolTip(btnSaveProject, "Save Project and assets");
btnSaveProject->setObjectName(QStringLiteral("btnSaveProject"));
sizePolicy1.setHeightForWidth(btnOpenProject->sizePolicy().hasHeightForWidth());
btnSaveProject->setSizePolicy(sizePolicy1);
@@ -53,7 +78,7 @@ BlastToolbar::BlastToolbar(QWidget* parent)
hLayout->addWidget(btnSaveProject);
btnExportAssets = new QPushButton(widget);
- setStyledToolTip(btnExportAssets, "Not Implement");
+ setStyledToolTip(btnExportAssets, "Export Blast assets");
btnExportAssets->setObjectName(QStringLiteral("btnExportAssets"));
sizePolicy1.setHeightForWidth(btnExportAssets->sizePolicy().hasHeightForWidth());
btnExportAssets->setSizePolicy(sizePolicy1);
@@ -93,6 +118,7 @@ BlastToolbar::BlastToolbar(QWidget* parent)
leExportFilepath->setMinimumSize(QSize(150, 20));
leExportFilepath->setMaximumSize(QSize(150, 20));
leExportFilepath->setText(QApplication::translate("AppMainToolbar", "", 0));
+ leExportFilepath->setEnabled(false); // do not allow direct change to make sure the folder exists.
vLayoutExport->addWidget(leExportFilepath);
hLayout->addLayout(vLayoutExport);
@@ -130,10 +156,10 @@ BlastToolbar::BlastToolbar(QWidget* parent)
hlExactCoverage = new QHBoxLayout();
hlExactCoverage->setObjectName(QStringLiteral("hlExactCoverage"));
- lbDepthPreview = new QLabel(widget);
- lbDepthPreview->setObjectName(QStringLiteral("hlExactCoverage"));
- lbDepthPreview->setText(QApplication::translate("AppMainToolbar", "Exact Coverage", 0));
- hlExactCoverage->addWidget(lbDepthPreview);
+ lbExactCoverage = new QLabel(widget);
+ lbExactCoverage->setObjectName(QStringLiteral("lbExactCoverage"));
+ lbExactCoverage->setText(QApplication::translate("AppMainToolbar", "Full Coverage", 0));
+ hlExactCoverage->addWidget(lbExactCoverage);
cbExactCoverage = new QCheckBox(widget);
cbExactCoverage->setObjectName(QStringLiteral("cbExactCoverage"));
@@ -151,7 +177,9 @@ BlastToolbar::BlastToolbar(QWidget* parent)
fSeparate->setFrameShape(QFrame::VLine);
fSeparate->setFrameShadow(QFrame::Sunken);
hLayout->addWidget(fSeparate);
-
+
+ QButtonGroup* gizmoGroup = new QButtonGroup(this);
+
btnSelectTool = new QPushButton(widget);
setStyledToolTip(btnSelectTool, "Switch to Selection Mode");
btnSelectTool->setObjectName(QStringLiteral("btnSelectTool"));
@@ -160,19 +188,99 @@ BlastToolbar::BlastToolbar(QWidget* parent)
btnSelectTool->setMinimumSize(QSize(40, 40));
btnSelectTool->setMaximumSize(QSize(40, 40));
btnSelectTool->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnSelectTool.png"));
- btnSelectTool->setIconSize(QSize(40, 40));
- QAction* pointselect_action = new QAction(tr("point select"), this);
- QAction* rectselect_action = new QAction(tr("rect select"), this);
- QAction* drawselect_action = new QAction(tr("draw select"), this);
- connect(pointselect_action, SIGNAL(triggered()), this, SLOT(on_pointselect_action()));
- connect(rectselect_action, SIGNAL(triggered()), this, SLOT(on_rectselect_action()));
- connect(drawselect_action, SIGNAL(triggered()), this, SLOT(on_drawselect_action()));
- QMenu* menu = new QMenu(btnSelectTool);
- menu->addAction(pointselect_action);
- menu->addAction(rectselect_action);
- menu->addAction(drawselect_action);
- btnSelectTool->setMenu(menu);
+ btnSelectTool->setIconSize(QSize(36, 36));
+ // because we can detect click or draw rect. we do not need menu by now.
+ //QAction* pointselect_action = new QAction(tr("point select"), this);
+ //QAction* rectselect_action = new QAction(tr("rect select"), this);
+ //QAction* drawselect_action = new QAction(tr("draw select"), this);
+ //pointselect_action->setCheckable(true);
+ //rectselect_action->setCheckable(true);
+ //drawselect_action->setCheckable(true);
+ //QActionGroup* selectGroup = new QActionGroup(this);
+ //selectGroup->addAction(pointselect_action);
+ //selectGroup->addAction(rectselect_action);
+ //selectGroup->addAction(drawselect_action);
+ //connect(pointselect_action, SIGNAL(triggered()), this, SLOT(on_pointselect_action()));
+ //connect(rectselect_action, SIGNAL(triggered()), this, SLOT(on_rectselect_action()));
+ //connect(drawselect_action, SIGNAL(triggered()), this, SLOT(on_drawselect_action()));
+ //QMenu* menu = new QMenu(btnSelectTool);
+ //menu->addAction(pointselect_action);
+ //menu->addAction(rectselect_action);
+ //menu->addAction(drawselect_action);
+ //btnSelectTool->setMenu(menu);
hLayout->addWidget(btnSelectTool);
+ btnSelectTool->setCheckable(true);
+ gizmoGroup->addButton(btnSelectTool);
+
+ btnExplodedViewTool = new QPushButton(widget);
+ setStyledToolTip(btnExplodedViewTool, "Exploded View Tool");
+ btnExplodedViewTool->setObjectName(QStringLiteral("btnExplodedViewTool"));
+ sizePolicy1.setHeightForWidth(btnExplodedViewTool->sizePolicy().hasHeightForWidth());
+ btnExplodedViewTool->setSizePolicy(sizePolicy1);
+ btnExplodedViewTool->setMinimumSize(QSize(40, 40));
+ btnExplodedViewTool->setMaximumSize(QSize(40, 40));
+ btnExplodedViewTool->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnExplodedViewTool.png"));
+ btnExplodedViewTool->setIconSize(QSize(36, 36));
+ btnExplodedViewTool->setCheckable(true);
+ hLayout->addWidget(btnExplodedViewTool);
+ gizmoGroup->addButton(btnExplodedViewTool);
+
+ btnTranslate = new QPushButton(widget);
+ setStyledToolTip(btnTranslate, "Translate Tool");
+ btnTranslate->setObjectName(QStringLiteral("btnTranslate"));
+ sizePolicy1.setHeightForWidth(btnTranslate->sizePolicy().hasHeightForWidth());
+ btnTranslate->setSizePolicy(sizePolicy1);
+ btnTranslate->setMinimumSize(QSize(40, 40));
+ btnTranslate->setMaximumSize(QSize(40, 40));
+ btnTranslate->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnTranslate.png"));
+ btnTranslate->setIconSize(QSize(36, 36));
+ hLayout->addWidget(btnTranslate);
+ btnTranslate->setCheckable(true);
+ gizmoGroup->addButton(btnTranslate);
+
+ btnRotate = new QPushButton(widget);
+ setStyledToolTip(btnRotate, "Rotate Tool");
+ btnRotate->setObjectName(QStringLiteral("btnRotate"));
+ sizePolicy1.setHeightForWidth(btnRotate->sizePolicy().hasHeightForWidth());
+ btnRotate->setSizePolicy(sizePolicy1);
+ btnRotate->setMinimumSize(QSize(40, 40));
+ btnRotate->setMaximumSize(QSize(40, 40));
+ btnRotate->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnRotate.png"));
+ btnRotate->setIconSize(QSize(36, 36));
+ hLayout->addWidget(btnRotate);
+ btnRotate->setCheckable(true);
+ gizmoGroup->addButton(btnRotate);
+
+ btnScale = new QPushButton(widget);
+ setStyledToolTip(btnScale, "Scale Tool");
+ btnScale->setObjectName(QStringLiteral("btnScale"));
+ sizePolicy1.setHeightForWidth(btnScale->sizePolicy().hasHeightForWidth());
+ btnScale->setSizePolicy(sizePolicy1);
+ btnScale->setMinimumSize(QSize(40, 40));
+ btnScale->setMaximumSize(QSize(40, 40));
+ btnScale->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnScale.png"));
+ btnScale->setIconSize(QSize(36, 36));
+ hLayout->addWidget(btnScale);
+ btnScale->setCheckable(true);
+ gizmoGroup->addButton(btnScale);
+
+ btnGizmoWithLocal = new QPushButton(widget);
+ setStyledToolTip(btnGizmoWithLocal, "Gizmo in Global Mode");
+ btnGizmoWithLocal->setObjectName(QStringLiteral("btnGizmoWithLocal"));
+ sizePolicy1.setHeightForWidth(btnGizmoWithLocal->sizePolicy().hasHeightForWidth());
+ btnGizmoWithLocal->setSizePolicy(sizePolicy1);
+ btnGizmoWithLocal->setMinimumSize(QSize(40, 40));
+ btnGizmoWithLocal->setMaximumSize(QSize(40, 40));
+ btnGizmoWithLocal->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnGizmoWithGlobal.png"));
+ btnGizmoWithLocal->setIconSize(QSize(36, 36));
+ hLayout->addWidget(btnGizmoWithLocal);
+ btnGizmoWithLocal->setCheckable(true);
+
+ //fSeparate = new QFrame(widget);
+ //fSeparate->setObjectName(QStringLiteral("fSeparate"));
+ //fSeparate->setFrameShape(QFrame::VLine);
+ //fSeparate->setFrameShadow(QFrame::Sunken);
+ //hLayout->addWidget(fSeparate);
btnPaintbrush = new QPushButton(widget);
setStyledToolTip(btnPaintbrush, "Not Implement");
@@ -182,7 +290,7 @@ BlastToolbar::BlastToolbar(QWidget* parent)
btnPaintbrush->setMinimumSize(QSize(40, 40));
btnPaintbrush->setMaximumSize(QSize(40, 40));
btnPaintbrush->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnPaintbrush.png"));
- btnPaintbrush->setIconSize(QSize(40, 40));
+ btnPaintbrush->setIconSize(QSize(36, 36));
hLayout->addWidget(btnPaintbrush);
btnFractureTool = new QPushButton(widget);
@@ -196,17 +304,6 @@ BlastToolbar::BlastToolbar(QWidget* parent)
btnFractureTool->setFont(fontCopy);
hLayout->addWidget(btnFractureTool);
- btnExplodedViewTool = new QPushButton(widget);
- setStyledToolTip(btnExplodedViewTool, "Not Implement");
- btnExplodedViewTool->setObjectName(QStringLiteral("btnExplodedViewTool"));
- sizePolicy1.setHeightForWidth(btnExplodedViewTool->sizePolicy().hasHeightForWidth());
- btnExplodedViewTool->setSizePolicy(sizePolicy1);
- btnExplodedViewTool->setMinimumSize(QSize(40, 40));
- btnExplodedViewTool->setMaximumSize(QSize(40, 40));
- btnExplodedViewTool->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnExplodedViewTool.png"));
- btnExplodedViewTool->setIconSize(QSize(40, 40));
- hLayout->addWidget(btnExplodedViewTool);
-
btnJointsTool = new QPushButton(widget);
setStyledToolTip(btnJointsTool, "Not Implement");
btnJointsTool->setObjectName(QStringLiteral("btnJointsTool"));
@@ -215,7 +312,7 @@ BlastToolbar::BlastToolbar(QWidget* parent)
btnJointsTool->setMinimumSize(QSize(40, 40));
btnJointsTool->setMaximumSize(QSize(40, 40));
btnJointsTool->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnJointsTool.png"));
- btnJointsTool->setIconSize(QSize(40, 40));
+ btnJointsTool->setIconSize(QSize(36, 36));
hLayout->addWidget(btnJointsTool);
btnFuseSelectedChunks = new QPushButton(widget);
@@ -226,7 +323,7 @@ BlastToolbar::BlastToolbar(QWidget* parent)
btnFuseSelectedChunks->setMinimumSize(QSize(40, 40));
btnFuseSelectedChunks->setMaximumSize(QSize(40, 40));
btnFuseSelectedChunks->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnFuseSelectedChunks.png"));
- btnFuseSelectedChunks->setIconSize(QSize(40, 40));
+ btnFuseSelectedChunks->setIconSize(QSize(36, 36));
hLayout->addWidget(btnFuseSelectedChunks);
fSeparate = new QFrame(widget);
@@ -235,6 +332,8 @@ BlastToolbar::BlastToolbar(QWidget* parent)
fSeparate->setFrameShadow(QFrame::Sunken);
hLayout->addWidget(fSeparate);
+ QButtonGroup* editSimModeGroup = new QButtonGroup(this);
+
btnReset = new QPushButton(widget);
setStyledToolTip(btnReset, "Reset Chunks and Switch to Edition Mode");
btnReset->setObjectName(QStringLiteral("btnReset"));
@@ -243,8 +342,10 @@ BlastToolbar::BlastToolbar(QWidget* parent)
btnReset->setMinimumSize(QSize(40, 40));
btnReset->setMaximumSize(QSize(40, 40));
btnReset->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnReset.png"));
- btnReset->setIconSize(QSize(40, 40));
+ btnReset->setIconSize(QSize(36, 36));
hLayout->addWidget(btnReset);
+ btnReset->setCheckable(true);
+ editSimModeGroup->addButton(btnReset);
btnSimulatePlay = new QPushButton(widget);
setStyledToolTip(btnSimulatePlay, "Switch to Simulate Mode");
@@ -254,8 +355,10 @@ BlastToolbar::BlastToolbar(QWidget* parent)
btnSimulatePlay->setMinimumSize(QSize(40, 40));
btnSimulatePlay->setMaximumSize(QSize(40, 40));
btnSimulatePlay->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnSimulatePlay.png"));
- btnSimulatePlay->setIconSize(QSize(40, 40));
+ btnSimulatePlay->setIconSize(QSize(36, 36));
hLayout->addWidget(btnSimulatePlay);
+ btnSimulatePlay->setCheckable(true);
+ editSimModeGroup->addButton(btnSimulatePlay);
btnFrameStepForward = new QPushButton(widget);
setStyledToolTip(btnFrameStepForward, "Switch to StepForward Mode");
@@ -265,8 +368,10 @@ BlastToolbar::BlastToolbar(QWidget* parent)
btnFrameStepForward->setMinimumSize(QSize(40, 40));
btnFrameStepForward->setMaximumSize(QSize(40, 40));
btnFrameStepForward->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnFrameStepForward.png"));
- btnFrameStepForward->setIconSize(QSize(40, 40));
+ btnFrameStepForward->setIconSize(QSize(36, 36));
hLayout->addWidget(btnFrameStepForward);
+ btnFrameStepForward->setCheckable(true);
+ editSimModeGroup->addButton(btnFrameStepForward);
fSeparate = new QFrame(widget);
fSeparate->setObjectName(QStringLiteral("fSeparate"));
@@ -274,16 +379,18 @@ BlastToolbar::BlastToolbar(QWidget* parent)
fSeparate->setFrameShadow(QFrame::Sunken);
hLayout->addWidget(fSeparate);
- btnBomb = new QPushButton(widget);
- setStyledToolTip(btnBomb, "Not Implement");
- btnBomb->setObjectName(QStringLiteral("btnBomb"));
- sizePolicy1.setHeightForWidth(btnBomb->sizePolicy().hasHeightForWidth());
- btnBomb->setSizePolicy(sizePolicy1);
- btnBomb->setMinimumSize(QSize(40, 40));
- btnBomb->setMaximumSize(QSize(40, 40));
- btnBomb->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnBomb.png"));
- btnBomb->setIconSize(QSize(40, 40));
- hLayout->addWidget(btnBomb);
+ // use btnDamage for Damage function.
+ btnDamage = new QPushButton(widget);
+ setStyledToolTip(btnDamage, "Switch on/off Damage Mode");
+ btnDamage->setObjectName(QStringLiteral("btnDamage"));
+ sizePolicy1.setHeightForWidth(btnDamage->sizePolicy().hasHeightForWidth());
+ btnDamage->setSizePolicy(sizePolicy1);
+ btnDamage->setMinimumSize(QSize(40, 40));
+ btnDamage->setMaximumSize(QSize(40, 40));
+ btnDamage->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnDamage.png"));
+ btnDamage->setIconSize(QSize(36, 36));
+ btnDamage->setCheckable(true);
+ hLayout->addWidget(btnDamage);
btnProjectile = new QPushButton(widget);
setStyledToolTip(btnProjectile, "Throw a Box to Chunks");
@@ -293,18 +400,18 @@ BlastToolbar::BlastToolbar(QWidget* parent)
btnProjectile->setMinimumSize(QSize(40, 40));
btnProjectile->setMaximumSize(QSize(40, 40));
btnProjectile->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnProjectile.png"));
- btnProjectile->setIconSize(QSize(40, 40));
+ btnProjectile->setIconSize(QSize(36, 36));
hLayout->addWidget(btnProjectile);
btnDropObject = new QPushButton(widget);
- setStyledToolTip(btnDropObject, "Not Implement");
+ setStyledToolTip(btnDropObject, "Drop the object and simulate");
btnDropObject->setObjectName(QStringLiteral("btnDropObject"));
sizePolicy1.setHeightForWidth(btnDropObject->sizePolicy().hasHeightForWidth());
btnDropObject->setSizePolicy(sizePolicy1);
btnDropObject->setMinimumSize(QSize(40, 40));
btnDropObject->setMaximumSize(QSize(40, 40));
btnDropObject->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnDropObject.png"));
- btnDropObject->setIconSize(QSize(40, 40));
+ btnDropObject->setIconSize(QSize(36, 36));
hLayout->addWidget(btnDropObject);
fSeparate = new QFrame(widget);
@@ -321,7 +428,7 @@ BlastToolbar::BlastToolbar(QWidget* parent)
btnPreferences->setMinimumSize(QSize(40, 40));
btnPreferences->setMaximumSize(QSize(40, 40));
btnPreferences->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnPreferences.png"));
- btnPreferences->setIconSize(QSize(40, 40));
+ btnPreferences->setIconSize(QSize(36, 36));
hLayout->addWidget(btnPreferences);
QSpacerItem *horizontalSpacer;
@@ -330,6 +437,7 @@ BlastToolbar::BlastToolbar(QWidget* parent)
this->setWidget(widget);
+ connect(&gDropTimer, SIGNAL(timeout()), this, SLOT(on_btnDropObject_clicked()));
connect(btnOpenProject, SIGNAL(clicked()), this, SLOT(on_btnOpenProject_clicked()));
connect(btnSaveProject, SIGNAL(clicked()), this, SLOT(on_btnSaveProject_clicked()));
connect(btnExportAssets, SIGNAL(clicked()), this, SLOT(on_btnExportAssets_clicked()));
@@ -337,6 +445,10 @@ BlastToolbar::BlastToolbar(QWidget* parent)
connect(ssbiDepthPreview, SIGNAL(valueChanged(int)), this, SLOT(on_ssbiDepthPreview_valueChanged(int)));
connect(cbExactCoverage, SIGNAL(stateChanged(int)), this, SLOT(on_cbExactCoverage_stateChanged(int)));
connect(btnSelectTool, SIGNAL(clicked()), this, SLOT(on_btnSelectTool_clicked()));
+ connect(btnTranslate, SIGNAL(clicked()), this, SLOT(on_Translate_clicked()));
+ connect(btnRotate, SIGNAL(clicked()), this, SLOT(on_Rotation_clicked()));
+ connect(btnScale, SIGNAL(clicked()), this, SLOT(on_Scale_clicked()));
+ connect(btnGizmoWithLocal, SIGNAL(clicked()), this, SLOT(on_btnGizmoWithLocal_clicked()));
connect(btnPaintbrush, SIGNAL(clicked()), this, SLOT(on_btnPaintbrush_clicked()));
connect(btnFractureTool, SIGNAL(clicked()), this, SLOT(on_btnFractureTool_clicked()));
connect(btnExplodedViewTool, SIGNAL(clicked()), this, SLOT(on_btnExplodedViewTool_clicked()));
@@ -345,96 +457,142 @@ BlastToolbar::BlastToolbar(QWidget* parent)
connect(btnReset, SIGNAL(clicked()), this, SLOT(on_btnReset_clicked()));
connect(btnSimulatePlay, SIGNAL(clicked()), this, SLOT(on_btnSimulatePlay_clicked()));
connect(btnFrameStepForward, SIGNAL(clicked()), this, SLOT(on_btnFrameStepForward_clicked()));
- connect(btnBomb, SIGNAL(clicked()), this, SLOT(on_btnBomb_clicked()));
+ connect(btnDamage, SIGNAL(clicked()), this, SLOT(on_btnDamage_clicked()));
connect(btnProjectile, SIGNAL(clicked()), this, SLOT(on_btnProjectile_clicked()));
connect(btnDropObject, SIGNAL(clicked()), this, SLOT(on_btnDropObject_clicked()));
connect(btnPreferences, SIGNAL(clicked()), this, SLOT(on_btnPreferences_clicked()));
+
+ QPushButton* unImplementButtons[] =
+ {
+ btnPaintbrush, btnFractureTool, btnJointsTool, btnFuseSelectedChunks, btnPreferences
+ };
+ int buttonSize = sizeof(unImplementButtons) / sizeof(QPushButton*);
+ for (int bs = 0; bs < buttonSize; bs++)
+ {
+ unImplementButtons[bs]->setVisible(false);
+ }
}
void BlastToolbar::updateValues()
{
-}
+ leExportFilepath->setText(GlobalSettings::Inst().m_projectFileDir.c_str());
+ btnGizmoWithLocal->setChecked(AppMainWindow::Inst().m_bGizmoWithLocal);
-#include <Sample.h>
-#include <SimpleScene.h>
-#include <SampleManager.h>
-#include <SceneController.h>
-#include <SourceAssetOpenDlg.h>
+ SampleManager* pSampleManager = SampleManager::ins();
+ DamageToolController& damageToolController = pSampleManager->getDamageToolController();
+ bool bChecked = damageToolController.IsEnabled() && damageToolController.IsEnabled() && damageToolController.isDamageMode();
+ btnDamage->setChecked(bChecked);
+}
void BlastToolbar::on_btnOpenProject_clicked()
{
- qDebug("%s", __FUNCTION__);
-
- SourceAssetOpenDlg dlg(true, &AppMainWindow::Inst());
- int res = dlg.exec();
- if (res != QDialog::Accepted || dlg.getFile().isEmpty())
- return;
-
- QFileInfo fileInfo(dlg.getFile());
- std::string dir = QDir::toNativeSeparators(fileInfo.absoluteDir().absolutePath()).toLocal8Bit();
- std::string file = fileInfo.baseName().toLocal8Bit();
-
- physx::PxTransform t(physx::PxIdentity);
- {
- QVector3D Position = dlg.getPosition();
- t.p = physx::PxVec3(Position.x(), Position.y(), Position.z());
-
- QVector3D RotationAxis = dlg.getRotationAxis();
- physx::PxVec3 Axis = physx::PxVec3(RotationAxis.x(), RotationAxis.y(), RotationAxis.z());
- Axis = Axis.getNormalized();
- float RotationDegree = dlg.getRotationDegree();
- float DEGREE_TO_RAD = acos(-1.0) / 180.0;
- RotationDegree = RotationDegree * DEGREE_TO_RAD;
- t.q = physx::PxQuat(RotationDegree, Axis);
- }
-
- SimpleScene::Inst()->GetSampleManager().addModelAsset(dir, file, dlg.getSkinned(), t, !dlg.isAppend());
+ //BlastPlugin::OpenBpxa("", "");
+ BlastPlugin::Inst().menu_openProject();
+ // show project path in toolbar
+ updateValues();
}
void BlastToolbar::on_btnSaveProject_clicked()
{
qDebug("%s", __FUNCTION__);
+ on_btnExportAssets_clicked();
+ BlastPlugin::Inst().menu_saveProject();
}
void BlastToolbar::on_btnExportAssets_clicked()
{
qDebug("%s", __FUNCTION__);
+ FileReferencesPanel* pPanel = BlastPlugin::Inst().GetFileReferencesPanel();
+ if (pPanel)
+ {
+ BlastAssetInstancesNode* assetInstancesNode = BlastTreeData::ins().getBlastAssetInstancesNode();
+ if (assetInstancesNode != nullptr)
+ {
+ size_t count = assetInstancesNode->children.size();
+ for (size_t i = 0; i < count; ++i)
+ {
+ BlastAssetInstanceNode* assetInstanceNode = dynamic_cast<BlastAssetInstanceNode*>(assetInstancesNode->children[i]);
+ if (assetInstanceNode)
+ {
+ assetInstanceNode->setSelected(true);
+ pPanel->on_btnSave_clicked();
+ }
+ }
+ }
+ }
}
void BlastToolbar::on_btnExportFilepath_clicked()
{
qDebug("%s", __FUNCTION__);
+ AppMainWindow& window = AppMainWindow::Inst();
+ QString lastDir = leExportFilepath->text();
+ if (lastDir.length() < 1)
+ {
+ lastDir = GlobalSettings::Inst().m_projectFileDir.c_str();
+ }
+ QString pathName = QFileDialog::getExistingDirectory(&window, "Exporting Path", lastDir);
+ if (!pathName.isEmpty())
+ {
+ GlobalSettings::Inst().m_projectFileDir = pathName.toUtf8().data();
+ leExportFilepath->setText(pathName);
+ }
}
void BlastToolbar::on_ssbiDepthPreview_valueChanged(int v)
{
qDebug("%s", __FUNCTION__);
+ BlastSceneTree* pBlastSceneTree = BlastSceneTree::ins();
+ pBlastSceneTree->hideAllChunks();
+ if (m_fullCoverage)
+ {
+ pBlastSceneTree->setChunkVisibleFullCoverage(v);
+ }
+ else
+ {
+ std::vector<uint32_t> depths(1, v);
+ pBlastSceneTree->setChunkVisible(depths, true);
+ }
+ // refresh display in scene tree
+ //pBlastSceneTree->updateValues(false);
+ SampleManager::ins()->m_bNeedRefreshTree = true;
}
void BlastToolbar::on_cbExactCoverage_stateChanged(int state)
{
qDebug("%s", __FUNCTION__);
+ m_fullCoverage = (state != 0);
+ //lbExactCoverage->setText(QApplication::translate("AppMainToolbar", (m_fullCoverage? "Full Coverage" : "Exact Coverage"), 0));
+ int depth = ssbiDepthPreview->value();
+ on_ssbiDepthPreview_valueChanged(depth);
}
void BlastToolbar::on_btnSelectTool_clicked()
{
- qDebug("%s", __FUNCTION__);
+ SampleManager* pSampleManager = SampleManager::ins();
+ SelectionToolController& selectionToolController = pSampleManager->getSelectionToolController();
+ ExplodeToolController& expolodeController = pSampleManager->getExplodeToolController();
+ expolodeController.DisableController();
+ GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController();
+ gizmoToolController.showAxisRenderables(false);
+
+ if (gizmoToolController.IsEnabled())
+ {
+ gizmoToolController.DisableController();
+ selectionToolController.setTargetActor(gizmoToolController.getTargetActor());
+ }
+ selectionToolController.EnableController();
+
}
void BlastToolbar::on_pointselect_action()
{
qDebug("%s", __FUNCTION__);
-
- SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager();
- sampleManager.setBlastToolType(BTT_Select);
}
void BlastToolbar::on_rectselect_action()
{
qDebug("%s", __FUNCTION__);
-
- SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager();
- sampleManager.setBlastToolType(BTT_Select);
}
void BlastToolbar::on_drawselect_action()
@@ -442,6 +600,83 @@ void BlastToolbar::on_drawselect_action()
qDebug("%s", __FUNCTION__);
}
+bool BlastToolbar::on_Translate_clicked()
+{
+ SampleManager* pSampleManager = SampleManager::ins();
+ SelectionToolController& selectionToolController = pSampleManager->getSelectionToolController();
+ ExplodeToolController& expolodeController = pSampleManager->getExplodeToolController();
+ expolodeController.DisableController();
+ GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController();
+ gizmoToolController.showAxisRenderables(false);
+
+ if (selectionToolController.IsEnabled())
+ {
+ selectionToolController.DisableController();
+ gizmoToolController.setTargetActor(selectionToolController.getTargetActor());
+ }
+ gizmoToolController.EnableController();
+ gizmoToolController.setGizmoToolMode(GTM_Translate);
+
+ return true;
+}
+
+bool BlastToolbar::on_Rotation_clicked()
+{
+ SampleManager* pSampleManager = SampleManager::ins();
+ SelectionToolController& selectionToolController = pSampleManager->getSelectionToolController();
+ ExplodeToolController& expolodeController = pSampleManager->getExplodeToolController();
+ expolodeController.DisableController();
+ GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController();
+ gizmoToolController.showAxisRenderables(false);
+
+ if (selectionToolController.IsEnabled())
+ {
+ selectionToolController.DisableController();
+ gizmoToolController.setTargetActor(selectionToolController.getTargetActor());
+ }
+ gizmoToolController.EnableController();
+ gizmoToolController.setGizmoToolMode(GTM_Rotation);
+
+ return true;
+}
+
+bool BlastToolbar::on_Scale_clicked()
+{
+ SampleManager* pSampleManager = SampleManager::ins();
+ SelectionToolController& selectionToolController = pSampleManager->getSelectionToolController();
+ ExplodeToolController& expolodeController = pSampleManager->getExplodeToolController();
+ expolodeController.DisableController();
+ GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController();
+ gizmoToolController.showAxisRenderables(false);
+
+ if (selectionToolController.IsEnabled())
+ {
+ selectionToolController.DisableController();
+ gizmoToolController.setTargetActor(selectionToolController.getTargetActor());
+ }
+ gizmoToolController.EnableController();
+ gizmoToolController.setGizmoToolMode(GTM_Scale);
+
+ return true;
+}
+
+void BlastToolbar::on_btnGizmoWithLocal_clicked()
+{
+ AppMainWindow& app = AppMainWindow::Inst();
+ app.m_bGizmoWithLocal = !app.m_bGizmoWithLocal;
+ if (app.m_bGizmoWithLocal)
+ {
+ btnGizmoWithLocal->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnGizmoWithLocal.png"));
+ setStyledToolTip(btnGizmoWithLocal, "Gizmo in Local Mode");
+ }
+ else
+ {
+ btnGizmoWithLocal->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnGizmoWithGlobal.png"));
+ setStyledToolTip(btnGizmoWithLocal, "Gizmo in Global Mode");
+ }
+ app.updateUI();
+}
+
void BlastToolbar::on_btnPaintbrush_clicked()
{
qDebug("%s", __FUNCTION__);
@@ -454,7 +689,146 @@ void BlastToolbar::on_btnFractureTool_clicked()
void BlastToolbar::on_btnExplodedViewTool_clicked()
{
- qDebug("%s", __FUNCTION__);
+#if (1)
+ SampleManager* pSampleManager = SampleManager::ins();
+ ExplodeToolController& explodeToolController = pSampleManager->getExplodeToolController();
+ GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController();
+ gizmoToolController.showAxisRenderables(false);
+
+ pSampleManager->getSelectionToolController().DisableController();
+
+ if (gizmoToolController.IsEnabled())
+ {
+ gizmoToolController.DisableController();
+ }
+ explodeToolController.EnableController();
+#endif
+
+#if (0)
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager->IsSimulating())
+ {
+ return;
+ }
+
+ BlastAsset* pBlastAsset = nullptr;
+ int nFamilyIndex = -1;
+ pSampleManager->getCurrentSelectedInstance(&pBlastAsset, nFamilyIndex);
+ if (pBlastAsset == nullptr)
+ {
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ if (AssetDescMap.size() == 1)
+ {
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itAssetDescMap = AssetDescMap.begin();
+ pSampleManager->setCurrentSelectedInstance(itAssetDescMap->first, -1);
+ pBlastAsset = pSampleManager->getCurBlastAsset();
+ viewer_msg("no asset selected, use the only one in current scene.");
+ }
+ }
+ if (pBlastAsset == nullptr)
+ {
+ viewer_msg("please select one asset before explode.");
+ return;
+ }
+
+ std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = pSampleManager->getAssetFamiliesMap();
+ std::map<BlastAsset*, std::vector<BlastFamily*>>::iterator itAFM = AssetFamiliesMap.find(pBlastAsset);
+ if (itAFM == AssetFamiliesMap.end())
+ {
+ return;
+ }
+
+ std::vector<BlastFamily*> families = itAFM->second;
+ int familySize = families.size();
+ if (familySize == 0)
+ {
+ viewer_msg("no instance for current asset.");
+ return;
+ }
+
+ if (nFamilyIndex == -1 || nFamilyIndex >= familySize)
+ {
+ nFamilyIndex = 0;
+ viewer_msg("no instance selected, use the first one of current asset.");
+ }
+
+ BlastFamily* pFamily = families[nFamilyIndex];
+
+ PxScene& scene = pSampleManager->getPhysXController().getEditPhysXScene();
+ const PxU32 actorsCountTotal = scene.getNbActors(PxActorTypeFlag::eRIGID_DYNAMIC);
+ if (actorsCountTotal == 0)
+ {
+ return;
+ }
+
+ std::vector<PxActor*> actorsTotal(actorsCountTotal);
+ PxU32 nbActors = scene.getActors(PxActorTypeFlag::eRIGID_DYNAMIC, &actorsTotal[0], actorsCountTotal, 0);
+ PX_ASSERT(actorsCountTotal == nbActors);
+
+ std::vector<PxActor*> actors;
+ PxActor* pRootActor = nullptr;
+ for (int act = 0; act < actorsCountTotal; act++)
+ {
+ if (pFamily->find(*actorsTotal[act]))
+ {
+ if (pRootActor == nullptr)
+ {
+ uint32_t chunkIndex = pFamily->getChunkIndexByPxActor(*actorsTotal[act]);
+ std::vector<uint32_t> chunkIndexes;
+ chunkIndexes.push_back(chunkIndex);
+ std::vector<BlastChunkNode*> chunkNodes = BlastTreeData::ins().getChunkNodeByBlastChunk(pBlastAsset, chunkIndexes);
+ if (chunkNodes.size() > 0 && BlastTreeData::isRoot(chunkNodes[0]))
+ {
+ pRootActor = actorsTotal[act];
+ }
+ else
+ {
+ actors.push_back(actorsTotal[act]);
+ }
+ }
+ else
+ {
+ actors.push_back(actorsTotal[act]);
+ }
+ }
+ }
+
+ if (pRootActor == nullptr)
+ {
+ return;
+ }
+
+ ++nExplodedViewState;
+
+ BlastController& blastController = pSampleManager->getBlastController();
+
+ PxVec3 origin = pRootActor->getWorldBounds().getCenter();
+
+ int actorsCount = actors.size();
+ for (int ac = 0; ac < actorsCount; ac++)
+ {
+ PxActor* actor = actors[ac];
+ PxRigidDynamic* dynamic = actor->is<PxRigidDynamic>();
+ PX_ASSERT(dynamic != nullptr);
+ PxTransform transformOld = dynamic->getGlobalPose();
+ PxTransform transformNew = transformOld;
+
+ PxBounds3 bound = actor->getWorldBounds();
+ PxVec3 target = bound.getCenter();
+ PxVec3 tChange = (target - origin) * 0.5;
+ if (nExplodedViewState > 5)
+ {
+ tChange = (origin - target) / 3;
+ }
+ PxVec3 newTarget = target + tChange;
+ transformNew.p = transformOld.p + tChange;
+ dynamic->setGlobalPose(transformNew);
+ blastController.updateActorRenderableTransform(*actor, transformNew, false);
+ }
+ if (nExplodedViewState > 9)
+ nExplodedViewState = 0;
+
+#endif
}
void BlastToolbar::on_btnJointsTool_clicked()
@@ -469,10 +843,23 @@ void BlastToolbar::on_btnFuseSelectedChunks_clicked()
void BlastToolbar::on_btnReset_clicked()
{
- qDebug("%s", __FUNCTION__);
+ nExplodedViewState = 0;
SampleManager* pSampleManager = SampleManager::ins();
+ bool bStopSimulation = pSampleManager->IsSimulating();
pSampleManager->resetScene();
+ // only show depth 0 if stop from simulation. Otherwise, just show as previous.
+ if (bStopSimulation)
+ {
+ BlastSceneTree* pBlastSceneTree = BlastSceneTree::ins();
+ pBlastSceneTree->hideAllChunks();
+ std::vector<uint32_t> depths(1, 0);
+ pBlastSceneTree->setChunkVisible(depths, true);
+ // refresh display in scene tree
+ //pBlastSceneTree->updateValues(false);
+ SampleManager::ins()->m_bNeedRefreshTree = true;
+ }
+ updateValues();
}
void BlastToolbar::on_btnSimulatePlay_clicked()
@@ -480,7 +867,26 @@ void BlastToolbar::on_btnSimulatePlay_clicked()
qDebug("%s", __FUNCTION__);
SampleManager* pSampleManager = SampleManager::ins();
- pSampleManager->setBlastToolType(BTT_Damage);
+ if (!pSampleManager->IsSimulating())
+ {
+ // force to recreate BlastFamilyModelSimple from project data
+ pSampleManager->resetScene();
+ pSampleManager->EnableSimulating(true);
+ // set right damage mode
+ DamageToolController& damageToolController = pSampleManager->getDamageToolController();
+ bool bChecked = damageToolController.IsEnabled() && damageToolController.IsEnabled() && damageToolController.isDamageMode();
+ if (damageToolController.isDamageMode() && !bChecked)
+ {
+ on_btnDamage_clicked();
+ }
+ }
+ else
+ {
+ // pause it or continue
+ PhysXController& physx = pSampleManager->getPhysXController();
+ bool bState = physx.isPaused();
+ physx.setPaused(!bState);
+ }
}
void BlastToolbar::on_btnFrameStepForward_clicked()
@@ -488,35 +894,141 @@ void BlastToolbar::on_btnFrameStepForward_clicked()
qDebug("%s", __FUNCTION__);
SampleManager* pSampleManager = SampleManager::ins();
- pSampleManager->setBlastToolType(BTT_Damage);
- PhysXController& physXController = pSampleManager->getPhysXController();
- physXController.m_bForce = true;
+ if (!pSampleManager->IsSimulating())
+ {
+ // force to recreate BlastFamilyModelSimple from project data
+ pSampleManager->resetScene();
+ // set right damage mode
+ DamageToolController& damageToolController = pSampleManager->getDamageToolController();
+ bool bChecked = damageToolController.IsEnabled() && damageToolController.IsEnabled() && damageToolController.isDamageMode();
+ if (damageToolController.isDamageMode() && !bChecked)
+ {
+ on_btnDamage_clicked();
+ }
+ }
+ pSampleManager->EnableSimulating(true);
+ pSampleManager->EnableStepforward(true);
}
-void BlastToolbar::on_btnBomb_clicked()
+void BlastToolbar::on_btnDamage_clicked()
{
qDebug("%s", __FUNCTION__);
- // debug codes: test RepX exporting. to-do, remove me later, e.g. when implementing bomb.
SampleManager* pSampleManager = SampleManager::ins();
- PhysXController& physXController = pSampleManager->getPhysXController();
- PxPhysics& physics = physXController.getPhysics();
- PxScene& scene = physXController.getPhysXScene();
- physXController.ExportCollisionRepX("d:\\t1.RepX", &physics, &scene, false);
- // debug codes: test RepX exporting. to-do, remove me later
+ DamageToolController& damageToolController = pSampleManager->getDamageToolController();
+ if (damageToolController.IsEnabled())
+ {
+ damageToolController.DisableController();
+ damageToolController.setDamageMode(false);
+ btnDamage->setChecked(false);
+ }
+ else
+ {
+ damageToolController.EnableController();
+ damageToolController.setDamageMode(true);
+ btnDamage->setChecked(true);
+ }
+// pSampleManager->getDamageToolController().setDamageMode(!pSampleManager->getDamageToolController().isDamageMode());
}
void BlastToolbar::on_btnProjectile_clicked()
{
qDebug("%s", __FUNCTION__);
- SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager();
- SceneController& sceneController = sampleManager.getSceneController();
- sceneController.addProjectile();
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager->IsSimulating())
+ {
+ SceneController& sceneController = pSampleManager->getSceneController();
+ sceneController.addProjectile();
+ }
+ else
+ {
+ viewer_msg("Please use it when simulation runs.");
+ }
}
void BlastToolbar::on_btnDropObject_clicked()
{
qDebug("%s", __FUNCTION__);
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager->IsSimulating())
+ {
+ on_btnReset_clicked();
+ // if not use timer, it could go to strange paused state.
+ gDropTimer.start(10);
+ return;
+ }
+ gDropTimer.stop();
+ BlastAssetInstancesNode* assetInstancesNode = BlastTreeData::ins().getBlastAssetInstancesNode();
+ if (assetInstancesNode != nullptr)
+ {
+ physx::PxVec3 size = pSampleManager->getAssetExtent();
+ float fChange = size.magnitude();
+ size_t count = assetInstancesNode->children.size();
+ // find the min height first
+ float minHeight = NV_MAX_F32;
+ for (size_t i = 0; i < count; ++i)
+ {
+ BlastAssetInstanceNode* assetInstanceNode = (BlastAssetInstanceNode*)assetInstancesNode->children[i];
+ BPPAssetInstance* bppInstance = (BPPAssetInstance*)assetInstanceNode->getData();
+ if (bppInstance)
+ {
+ BlastFamily* family = SampleManager::ins()->getFamilyByInstance(bppInstance);
+ if (family)
+ {
+ physx::PxTransform t = family->getSettings().transform;
+ if(t.p.y < minHeight)
+ minHeight = t.p.y;
+ }
+ }
+ }
+ // make fChange
+ while ((minHeight + fChange) < 0.0f)
+ {
+ fChange += fChange;
+ }
+ // change position
+ for (size_t i = 0; i < count; ++i)
+ {
+ BlastAssetInstanceNode* assetInstanceNode = (BlastAssetInstanceNode*)assetInstancesNode->children[i];
+ BPPAssetInstance* bppInstance = (BPPAssetInstance*)assetInstanceNode->getData();
+ if (bppInstance)
+ {
+ BlastFamily* family = SampleManager::ins()->getFamilyByInstance(bppInstance);
+ if (family)
+ {
+ physx::PxTransform t = family->getSettings().transform;
+ t.p.y += fChange;
+ family->initTransform(t);
+ }
+ }
+ }
+ // have to reset scene to make the new positions used.
+ on_btnReset_clicked();
+ pSampleManager->EnableSimulating(true);
+ // restore original position
+ for (size_t i = 0; i < count; ++i)
+ {
+ BlastAssetInstanceNode* assetInstanceNode = (BlastAssetInstanceNode*)assetInstancesNode->children[i];
+ BPPAssetInstance* bppInstance = (BPPAssetInstance*)assetInstanceNode->getData();
+ if (bppInstance)
+ {
+ BlastFamily* family = SampleManager::ins()->getFamilyByInstance(bppInstance);
+ if (family)
+ {
+ physx::PxTransform t = family->getSettings().transform;
+ t.p.y -= fChange;
+ family->initTransform(t);
+ }
+ }
+ }
+ // set right damage mode
+ DamageToolController& damageToolController = pSampleManager->getDamageToolController();
+ bool bChecked = damageToolController.IsEnabled() && damageToolController.IsEnabled() && damageToolController.isDamageMode();
+ if (damageToolController.isDamageMode() && !bChecked)
+ {
+ on_btnDamage_clicked();
+ }
+ }
}
void BlastToolbar::on_btnPreferences_clicked()
@@ -524,5 +1036,20 @@ void BlastToolbar::on_btnPreferences_clicked()
qDebug("%s", __FUNCTION__);
SampleManager* pSampleManager = SampleManager::ins();
- pSampleManager->saveAsset();
+ BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset();
+ pSampleManager->saveAsset(pBlastAsset);
+}
+
+void BlastToolbar::updateCheckIconsStates()
+{
+ SampleManager* pSampleManager = SampleManager::ins();
+ SelectionToolController& selectionToolController = pSampleManager->getSelectionToolController();
+ btnSelectTool->setChecked(selectionToolController.IsEnabled());
+
+ GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController();
+ bool bGizmo = gizmoToolController.IsEnabled();
+ GizmoToolMode mode = gizmoToolController.getGizmoToolMode();
+ btnTranslate->setChecked(mode == GTM_Translate && bGizmo);
+ btnRotate->setChecked(mode == GTM_Rotation && bGizmo);
+ btnScale->setChecked(mode == GTM_Scale && bGizmo);
} \ No newline at end of file
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.h b/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.h
index f44dcfb..24129e8 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.h
@@ -36,6 +36,11 @@ public slots:
void on_rectselect_action();
void on_drawselect_action();
+ bool on_Translate_clicked();
+ bool on_Rotation_clicked();
+ bool on_Scale_clicked();
+ void on_btnGizmoWithLocal_clicked();
+
void on_btnPaintbrush_clicked();
void on_btnFractureTool_clicked();
void on_btnExplodedViewTool_clicked();
@@ -46,12 +51,14 @@ public slots:
void on_btnSimulatePlay_clicked();
void on_btnFrameStepForward_clicked();
- void on_btnBomb_clicked();
+ void on_btnDamage_clicked();
void on_btnProjectile_clicked();
void on_btnDropObject_clicked();
void on_btnPreferences_clicked();
+ void updateCheckIconsStates();
+
private:
QHBoxLayout *hLayout;
QFrame *fSeparate;
@@ -74,9 +81,14 @@ private:
QLabel *lbExactCoverage;
QCheckBox* cbExactCoverage;
- QPushButton *btnSelectTool;
+ QPushButton *btnSelectTool;
+ QPushButton *btnTranslate;
+ QPushButton *btnRotate;
+ QPushButton *btnScale;
+ QPushButton *btnGizmoWithLocal;
+
QPushButton *btnPaintbrush;
- QPushButton *btnFractureTool;
+ QPushButton *btnFractureTool;
QPushButton *btnExplodedViewTool;
QPushButton *btnJointsTool;
QPushButton *btnFuseSelectedChunks;
@@ -85,10 +97,12 @@ private:
QPushButton *btnSimulatePlay;
QPushButton *btnFrameStepForward;
- QPushButton *btnBomb;
+ QPushButton *btnDamage;
QPushButton *btnProjectile;
QPushButton *btnDropObject;
QPushButton *btnPreferences;
+
+ bool m_fullCoverage;
};
#endif // BlastToolbar_h__
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.cpp
index e52dfb2..5d82ce5 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.cpp
@@ -2,12 +2,42 @@
#include "ui_DefaultDamagePanel.h"
#include "ProjectParams.h"
#include "BlastSceneTree.h"
+#include <float.h>
+
+#include "DamageToolController.h"
+
+DefaultDamagePanel* gDefaultDamagePanel = nullptr;
+DefaultDamagePanel* DefaultDamagePanel::ins()
+{
+ return gDefaultDamagePanel;
+}
+
+QComboBox* DefaultDamagePanel::getDamageProfile()
+{
+ return ui->comboBoxDamageProfile;
+}
+
+void DefaultDamagePanel::setUpdateData(bool bUpdateData)
+{
+ _updateData = bUpdateData;
+}
DefaultDamagePanel::DefaultDamagePanel(QWidget *parent) :
QWidget(parent),
- ui(new Ui::DefaultDamagePanel)
+ ui(new Ui::DefaultDamagePanel),
+ _updateData(true)
{
+ gDefaultDamagePanel = this;
+
ui->setupUi(this);
+
+ _updateData = false;
+ ui->spinBoxDamageAmount->setRange(0.0f, DBL_MAX);
+ ui->spinBoxExplosiveImpulse->setRange(0.0f, DBL_MAX);
+ ui->spinBoxDamageRadius->setRange(0.0f, DBL_MAX);
+ ui->spinBoxStressDamageForce->setRange(0.0f, DBL_MAX);
+ ui->checkBoxDamageContinuously->setChecked(false);
+ _updateData = true;
}
DefaultDamagePanel::~DefaultDamagePanel()
@@ -17,23 +47,29 @@ DefaultDamagePanel::~DefaultDamagePanel()
void DefaultDamagePanel::updateValues()
{
- if (_selectedAssets.size() > 0)
- {
- BPPDefaultDamage& damage = _selectedAssets[0]->defaultDamage;
-
- ui->spinBoxMinRadius->setValue(damage.minRadius);
- ui->spinBoxMaxRadius->setValue(damage.maxRadius);
- ui->comboBoxFallOff->setCurrentIndex(damage.FallOff);
- ui->spinBoxMaxChunkSpeed->setValue(damage.maxChunkSpeed);
+ _updateData = false;
+ BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage;
+ if (damage.damageStructs.arraySizes[0] > 0)
+ {
+ uint32_t damageProfile = damage.damageProfile;
+ BPPDamageStruct& damageStruct = damage.damageStructs.buf[damageProfile];
+ ui->spinBoxDamageAmount->setValue(damage.damageAmount);
+ ui->spinBoxExplosiveImpulse->setValue(damage.explosiveImpulse);
+ ui->spinBoxStressDamageForce->setValue(damage.stressDamageForce);
+ ui->comboBoxDamageProfile->setCurrentIndex(damageProfile);
+ ui->spinBoxDamageRadius->setValue(damageStruct.damageRadius);
+ ui->checkBoxDamageContinuously->setChecked(damageStruct.continuously);
}
else
{
- ui->spinBoxMinRadius->setValue(0.0f);
- ui->spinBoxMaxRadius->setValue(0.0f);
- ui->checkBoxMaxRadius->setChecked(false);
- ui->comboBoxFallOff->setCurrentIndex(-1);
- ui->spinBoxMaxChunkSpeed->setValue(0.0f);
+ ui->spinBoxDamageAmount->setValue(0);
+ ui->spinBoxExplosiveImpulse->setValue(0);
+ ui->spinBoxDamageRadius->setValue(0);
+ ui->spinBoxStressDamageForce->setValue(0);
+ ui->checkBoxDamageContinuously->setChecked(false);
+ ui->comboBoxDamageProfile->setCurrentIndex(0);
}
+ _updateData = true;
}
void DefaultDamagePanel::dataSelected(std::vector<BlastNode*> selections)
@@ -52,53 +88,74 @@ void DefaultDamagePanel::dataSelected(std::vector<BlastNode*> selections)
updateValues();
}
-void DefaultDamagePanel::on_spinBoxMinRadius_valueChanged(double arg1)
+void DefaultDamagePanel::on_spinBoxDamageAmount_valueChanged(double arg1)
{
- for (size_t i = 0; i < _selectedAssets.size(); ++i)
- {
- BPPDefaultDamage& damage = _selectedAssets[i]->defaultDamage;
- damage.minRadius = arg1;
- }
+ if (!_updateData)
+ return;
+
+ BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage;
+ damage.damageAmount = arg1;
+
+ DamageToolController::ins()->setDamageAmount(arg1);
}
-void DefaultDamagePanel::on_spinBoxMaxRadius_valueChanged(double arg1)
+void DefaultDamagePanel::on_spinBoxExplosiveImpulse_valueChanged(double arg1)
{
- for (size_t i = 0; i < _selectedAssets.size(); ++i)
- {
- BPPDefaultDamage& damage = _selectedAssets[i]->defaultDamage;
+ if (!_updateData)
+ return;
- damage.maxRadius = arg1;
+ BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage;
+ damage.explosiveImpulse = arg1;
- if (arg1 < damage.minRadius)
- {
- damage.maxRadius = damage.minRadius;
- }
- }
+ DamageToolController::ins()->setExplosiveImpulse(arg1);
}
-void DefaultDamagePanel::on_checkBoxMaxRadius_stateChanged(int arg1)
+void DefaultDamagePanel::on_spinBoxDamageRadius_valueChanged(double arg1)
{
- for (size_t i = 0; i < _selectedAssets.size(); ++i)
- {
- BPPDefaultDamage& damage = _selectedAssets[i]->defaultDamage;
- damage.maxRadiusEnable = (arg1 != 0 ? true: false);
- }
+ if (!_updateData)
+ return;
+
+ BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage;
+ uint32_t damageProfile = damage.damageProfile;
+ BPPDamageStruct& damageStruct = damage.damageStructs.buf[damageProfile];
+ damageStruct.damageRadius = arg1;
+
+ DamageToolController::ins()->setRadius(arg1);
}
-void DefaultDamagePanel::on_comboBoxFallOff_currentIndexChanged(int index)
+void DefaultDamagePanel::on_spinBoxStressDamageForce_valueChanged(double arg1)
{
- for (size_t i = 0; i < _selectedAssets.size(); ++i)
- {
- BPPDefaultDamage& damage = _selectedAssets[i]->defaultDamage;
- damage.FallOff = index;
- }
+ if (!_updateData)
+ return;
+
+ BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage;
+ damage.stressDamageForce = arg1;
+
+ DamageToolController::ins()->setStressForceFactor(arg1);
}
-void DefaultDamagePanel::on_spinBoxMaxChunkSpeed_valueChanged(double arg1)
+void DefaultDamagePanel::on_comboBoxDamageProfile_currentIndexChanged(int index)
{
- for (size_t i = 0; i < _selectedAssets.size(); ++i)
- {
- BPPDefaultDamage& damage = _selectedAssets[i]->defaultDamage;
- damage.maxChunkSpeed = arg1;
- }
+ if (!_updateData)
+ return;
+
+ BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage;
+ damage.damageProfile = index;
+
+ DamageToolController::ins()->setDamagerIndex(index);
+
+ updateValues();
+}
+
+void DefaultDamagePanel::on_checkBoxDamageContinuously_stateChanged(int arg1)
+{
+ if (!_updateData)
+ return;
+
+ BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage;
+ uint32_t damageProfile = damage.damageProfile;
+ BPPDamageStruct& damageStruct = damage.damageStructs.buf[damageProfile];
+ damageStruct.continuously = arg1;
+
+ DamageToolController::ins()->setDamageWhilePressed(arg1);
}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.h b/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.h
index bbd4d3e..044311e 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.h
@@ -2,6 +2,7 @@
#define DEFAULTDAMAGEPANEL_H
#include <QtWidgets/QWidget>
+#include <QtWidgets/QComboBox>
#include "BlastSceneTree.h"
namespace Ui {
@@ -17,22 +18,29 @@ public:
~DefaultDamagePanel();
void updateValues();
+ static DefaultDamagePanel* ins();
+ QComboBox* getDamageProfile();
+ void setUpdateData(bool bUpdateData);
+
virtual void dataSelected(std::vector<BlastNode*> selections);
private slots:
- void on_spinBoxMinRadius_valueChanged(double arg1);
+ void on_spinBoxDamageAmount_valueChanged(double arg1);
+
+ void on_spinBoxExplosiveImpulse_valueChanged(double arg1);
- void on_spinBoxMaxRadius_valueChanged(double arg1);
+ void on_spinBoxDamageRadius_valueChanged(double arg1);
- void on_checkBoxMaxRadius_stateChanged(int arg1);
+ void on_spinBoxStressDamageForce_valueChanged(double arg1);
- void on_comboBoxFallOff_currentIndexChanged(int index);
+ void on_comboBoxDamageProfile_currentIndexChanged(int index);
- void on_spinBoxMaxChunkSpeed_valueChanged(double arg1);
+ void on_checkBoxDamageContinuously_stateChanged(int arg1);
private:
- Ui::DefaultDamagePanel *ui;
- std::vector<BPPAsset*> _selectedAssets;
+ Ui::DefaultDamagePanel *ui;
+ bool _updateData;
+ std::vector<BPPAsset*> _selectedAssets;
};
#endif // DEFAULTDAMAGEPANEL_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.cpp
index 62b294c..235dd23 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.cpp
@@ -6,20 +6,38 @@
#include <QtCore/QFile>
#include <QtCore/QDebug>
#include "GlobalSettings.h"
+#include "SampleManager.h"
+#include "ViewerOutput.h"
+
+FileReferencesPanel* gFileReferencesPanel = nullptr;
+FileReferencesPanel* FileReferencesPanel::ins()
+{
+ return gFileReferencesPanel;
+}
FileReferencesPanel::FileReferencesPanel(QWidget *parent)
: QWidget(parent)
, ui(new Ui::FileReferencesPanel)
- , _saveFBX(true)
- , _saveBlast(true)
- , _saveCollision(true)
{
ui->setupUi(this);
ui->lineEditFBXSourceAsset->setReadOnly(true);
- ui->checkBoxFBX->setChecked(_saveFBX);
- ui->checkBoxBlast->setChecked(_saveBlast);
- ui->checkBoxCollision->setChecked(_saveCollision);
+ ui->lineEditFBX->setText("New.fbx");
+ ui->lineEditObj->setText("New.obj");
+ ui->lineEditCollision->setText("New.repx");
+ ui->lineEditLLAsset->setText("Newll.blast");
+ ui->lineEditTKAsset->setText("Newtk.blast");
+ ui->lineEditBPXA->setText("New.blast");
+ bValid = false;
+ ui->checkBoxFBX->setChecked(false);
+ ui->checkBoxObj->setChecked(false);
+ ui->checkBoxCollision->setChecked(false);
+ ui->checkBoxLLAsset->setChecked(false);
+ ui->checkBoxTKAsset->setChecked(false);
+ ui->checkBoxBPXA->setChecked(false);
+ bValid = true;
+
+ gFileReferencesPanel = this;
updateValues();
}
@@ -39,40 +57,113 @@ void FileReferencesPanel::updateValues()
else
ui->lineEditFBXSourceAsset->setText("");
- GlobalSettings& globalSettings = GlobalSettings::Inst();
- QString projectFileName = globalSettings.m_projectFileName.c_str();
+ ui->lineEditFBX->setText("");
+ ui->lineEditObj->setText("");
+ ui->lineEditCollision->setText("");
+ ui->lineEditLLAsset->setText("");
+ ui->lineEditTKAsset->setText("");
+ ui->lineEditBPXA->setText("");
+ bValid = false;
+ ui->checkBoxFBX->setChecked(false);
+ ui->checkBoxObj->setChecked(false);
+ ui->checkBoxCollision->setChecked(false);
+ ui->checkBoxLLAsset->setChecked(false);
+ ui->checkBoxTKAsset->setChecked(false);
+ ui->checkBoxBPXA->setChecked(false);
+ bValid = true;
- if (projectFileName.isEmpty())
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager == nullptr)
{
- ui->lineEditFBX->setText("New.fbx");
- ui->lineEditBlast->setText("New.Blast");
- ui->lineEditCollision->setText("New.repx");
+ return;
}
+
+ BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset();
+ if (pBlastAsset == nullptr)
+ {
+ return;
+ }
+
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itADM = AssetDescMap.find(pBlastAsset);
+ if (itADM == AssetDescMap.end())
+ {
+ return;
+ }
+
+ AssetList::ModelAsset modelAsset = itADM->second;
+ if (modelAsset.name.empty())
+ {
+ return;
+ }
+
+ BPPAssetArray& assetArray = projectParams.blast.blastAssets;
+ BPPAsset asset;
+ int aaas = 0;
+ for (; aaas < assetArray.arraySizes[0]; aaas++)
+ {
+ asset = assetArray.buf[aaas];
+ std::string assetname = asset.name;
+ if (assetname == modelAsset.name)
+ break;
+ }
+ if (aaas == assetArray.arraySizes[0])
+ {
+ return;
+ }
+
+ QFileInfo fileInfo(modelAsset.name.c_str());
+
+ if (asset.fbx.buf != nullptr)
+ ui->lineEditFBX->setText(asset.fbx.buf);
+ else
+ {
+ ui->lineEditFBX->setText(fileInfo.baseName() + "_New.fbx");
+ }
+
+ if (asset.obj.buf != nullptr)
+ ui->lineEditObj->setText(asset.obj.buf);
else
{
- QFileInfo fileInfo(projectFileName);
-
- if (fileReferences.fbx.buf != nullptr)
- ui->lineEditFBX->setText(fileReferences.fbx.buf);
- else
- {
- ui->lineEditFBX->setText(fileInfo.baseName() + " New.fbx");
- }
-
- if (fileReferences.blast.buf != nullptr)
- ui->lineEditBlast->setText(fileReferences.blast.buf);
- else
- {
- ui->lineEditBlast->setText(fileInfo.baseName() + " New.Blast");
- }
-
- if (fileReferences.collision.buf != nullptr)
- ui->lineEditCollision->setText(fileReferences.collision.buf);
- else
- {
- ui->lineEditCollision->setText(fileInfo.baseName() + " New.repX");
- }
+ ui->lineEditObj->setText(fileInfo.baseName() + "_New.obj");
}
+
+ if (asset.collision.buf != nullptr)
+ ui->lineEditCollision->setText(asset.collision.buf);
+ else
+ {
+ ui->lineEditCollision->setText(fileInfo.baseName() + "_New.repx");
+ }
+
+ if (asset.llasset.buf != nullptr)
+ ui->lineEditLLAsset->setText(asset.llasset.buf);
+ else
+ {
+ ui->lineEditLLAsset->setText(fileInfo.baseName() + "_Newll.blast");
+ }
+
+ if (asset.tkasset.buf != nullptr)
+ ui->lineEditTKAsset->setText(asset.tkasset.buf);
+ else
+ {
+ ui->lineEditTKAsset->setText(fileInfo.baseName() + "_Newtk.blast");
+ }
+
+ if (asset.bpxa.buf != nullptr)
+ ui->lineEditBPXA->setText(asset.bpxa.buf);
+ else
+ {
+ ui->lineEditBPXA->setText(fileInfo.baseName() + "_New.blast");
+ }
+
+ bValid = false;
+ ui->checkBoxFBX->setChecked(asset.exportFBX);
+ ui->checkBoxObj->setChecked(asset.exportOBJ);
+ ui->checkBoxCollision->setChecked(asset.exportCollision);
+ ui->checkBoxLLAsset->setChecked(asset.exportLLAsset);
+ ui->checkBoxTKAsset->setChecked(asset.exportTKAsset);
+ ui->checkBoxBPXA->setChecked(asset.exportBPXA);
+ bValid = true;
}
void FileReferencesPanel::on_btnOpenFile_clicked()
@@ -108,17 +199,310 @@ void FileReferencesPanel::on_btnRemove_clicked()
void FileReferencesPanel::on_checkBoxFBX_stateChanged(int arg1)
{
- _saveFBX = (arg1 == 0 ? false : true);
+ if (!bValid)
+ {
+ return;
+ }
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager == nullptr)
+ {
+ return;
+ }
+
+ BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset();
+ if (pBlastAsset == nullptr)
+ {
+ return;
+ }
+
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itADM = AssetDescMap.find(pBlastAsset);
+ if (itADM == AssetDescMap.end())
+ {
+ return;
+ }
+
+ AssetList::ModelAsset modelAsset = itADM->second;
+ if (modelAsset.name.empty())
+ {
+ return;
+ }
+
+ BPParams& projectParams = BlastProject::ins().getParams();
+ BPPAssetArray& assetArray = projectParams.blast.blastAssets;
+ int aaas = 0;
+ for (; aaas < assetArray.arraySizes[0]; aaas++)
+ {
+ std::string assetname = assetArray.buf[aaas].name;
+ if (assetname == modelAsset.name)
+ break;
+ }
+ if (aaas == assetArray.arraySizes[0])
+ {
+ return;
+ }
+
+ BPPAsset& asset = assetArray.buf[aaas];
+ asset.exportFBX = ui->checkBoxFBX->isChecked();
}
-void FileReferencesPanel::on_checkBoxBlast_stateChanged(int arg1)
+void FileReferencesPanel::on_checkBoxObj_stateChanged(int arg1)
{
- _saveBlast = (arg1 == 0 ? false : true);
+ if (!bValid)
+ {
+ return;
+ }
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager == nullptr)
+ {
+ return;
+ }
+
+ BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset();
+ if (pBlastAsset == nullptr)
+ {
+ return;
+ }
+
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itADM = AssetDescMap.find(pBlastAsset);
+ if (itADM == AssetDescMap.end())
+ {
+ return;
+ }
+
+ AssetList::ModelAsset modelAsset = itADM->second;
+ if (modelAsset.name.empty())
+ {
+ return;
+ }
+
+ BPParams& projectParams = BlastProject::ins().getParams();
+ BPPAssetArray& assetArray = projectParams.blast.blastAssets;
+ int aaas = 0;
+ for (; aaas < assetArray.arraySizes[0]; aaas++)
+ {
+ std::string assetname = assetArray.buf[aaas].name;
+ if (assetname == modelAsset.name)
+ break;
+ }
+ if (aaas == assetArray.arraySizes[0])
+ {
+ return;
+ }
+
+ BPPAsset& asset = assetArray.buf[aaas];
+ asset.exportOBJ = ui->checkBoxObj->isChecked();
}
void FileReferencesPanel::on_checkBoxCollision_stateChanged(int arg1)
{
- _saveCollision = (arg1 == 0 ? false : true);
+ if (!bValid)
+ {
+ return;
+ }
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager == nullptr)
+ {
+ return;
+ }
+
+ BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset();
+ if (pBlastAsset == nullptr)
+ {
+ return;
+ }
+
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itADM = AssetDescMap.find(pBlastAsset);
+ if (itADM == AssetDescMap.end())
+ {
+ return;
+ }
+
+ AssetList::ModelAsset modelAsset = itADM->second;
+ if (modelAsset.name.empty())
+ {
+ return;
+ }
+
+ BPParams& projectParams = BlastProject::ins().getParams();
+ BPPAssetArray& assetArray = projectParams.blast.blastAssets;
+ int aaas = 0;
+ for (; aaas < assetArray.arraySizes[0]; aaas++)
+ {
+ std::string assetname = assetArray.buf[aaas].name;
+ if (assetname == modelAsset.name)
+ break;
+ }
+ if (aaas == assetArray.arraySizes[0])
+ {
+ return;
+ }
+
+ BPPAsset& asset = assetArray.buf[aaas];
+ asset.exportCollision = ui->checkBoxCollision->isChecked();
+}
+
+void FileReferencesPanel::on_checkBoxLLAsset_stateChanged(int arg1)
+{
+ if (!bValid)
+ {
+ return;
+ }
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager == nullptr)
+ {
+ return;
+ }
+
+ BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset();
+ if (pBlastAsset == nullptr)
+ {
+ return;
+ }
+
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itADM = AssetDescMap.find(pBlastAsset);
+ if (itADM == AssetDescMap.end())
+ {
+ return;
+ }
+
+ AssetList::ModelAsset modelAsset = itADM->second;
+ if (modelAsset.name.empty())
+ {
+ return;
+ }
+
+ BPParams& projectParams = BlastProject::ins().getParams();
+ BPPAssetArray& assetArray = projectParams.blast.blastAssets;
+ int aaas = 0;
+ for (; aaas < assetArray.arraySizes[0]; aaas++)
+ {
+ std::string assetname = assetArray.buf[aaas].name;
+ if (assetname == modelAsset.name)
+ break;
+ }
+ if (aaas == assetArray.arraySizes[0])
+ {
+ return;
+ }
+
+ BPPAsset& asset = assetArray.buf[aaas];
+ asset.exportLLAsset = ui->checkBoxLLAsset->isChecked();
+}
+
+void FileReferencesPanel::on_checkBoxTKAsset_stateChanged(int arg1)
+{
+ if (!bValid)
+ {
+ return;
+ }
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager == nullptr)
+ {
+ return;
+ }
+
+ BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset();
+ if (pBlastAsset == nullptr)
+ {
+ return;
+ }
+
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itADM = AssetDescMap.find(pBlastAsset);
+ if (itADM == AssetDescMap.end())
+ {
+ return;
+ }
+
+ AssetList::ModelAsset modelAsset = itADM->second;
+ if (modelAsset.name.empty())
+ {
+ return;
+ }
+
+ BPParams& projectParams = BlastProject::ins().getParams();
+ BPPAssetArray& assetArray = projectParams.blast.blastAssets;
+ int aaas = 0;
+ for (; aaas < assetArray.arraySizes[0]; aaas++)
+ {
+ std::string assetname = assetArray.buf[aaas].name;
+ if (assetname == modelAsset.name)
+ break;
+ }
+ if (aaas == assetArray.arraySizes[0])
+ {
+ return;
+ }
+
+ BPPAsset& asset = assetArray.buf[aaas];
+ asset.exportTKAsset = ui->checkBoxTKAsset->isChecked();
+}
+
+void FileReferencesPanel::on_checkBoxBPXA_stateChanged(int arg1)
+{
+ if (!bValid)
+ {
+ return;
+ }
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager == nullptr)
+ {
+ return;
+ }
+
+ BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset();
+ if (pBlastAsset == nullptr)
+ {
+ return;
+ }
+
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itADM = AssetDescMap.find(pBlastAsset);
+ if (itADM == AssetDescMap.end())
+ {
+ return;
+ }
+
+ AssetList::ModelAsset modelAsset = itADM->second;
+ if (modelAsset.name.empty())
+ {
+ return;
+ }
+
+ BPParams& projectParams = BlastProject::ins().getParams();
+ BPPAssetArray& assetArray = projectParams.blast.blastAssets;
+ int aaas = 0;
+ for (; aaas < assetArray.arraySizes[0]; aaas++)
+ {
+ std::string assetname = assetArray.buf[aaas].name;
+ if (assetname == modelAsset.name)
+ break;
+ }
+ if (aaas == assetArray.arraySizes[0])
+ {
+ return;
+ }
+
+ BPPAsset& asset = assetArray.buf[aaas];
+ asset.exportBPXA = ui->checkBoxBPXA->isChecked();
+
+ if (asset.exportBPXA)
+ {
+ bValid = false;
+ ui->checkBoxObj->setChecked(true);
+ asset.exportOBJ = true;
+ bValid = true;
+ }
}
void FileReferencesPanel::on_btnSave_clicked()
@@ -128,21 +512,63 @@ void FileReferencesPanel::on_btnSave_clicked()
copy(fileReferences.fbxSourceAsset, ui->lineEditFBXSourceAsset->text().toUtf8().data());
- if (_saveFBX)
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager == nullptr)
+ {
+ return;
+ }
+
+ BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset();
+ if (pBlastAsset == nullptr)
+ {
+ return;
+ }
+
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>::iterator itADM = AssetDescMap.find(pBlastAsset);
+ if (itADM == AssetDescMap.end())
{
- copy(fileReferences.fbx, ui->lineEditFBX->text().toUtf8().data());
- // to do: save fbx file
+ return;
}
- if (_saveBlast)
+ AssetList::ModelAsset modelAsset = itADM->second;
+ if (modelAsset.name.empty())
{
- copy(fileReferences.blast, ui->lineEditBlast->text().toUtf8().data());
- // to do: save blast file
+ return;
}
- if (_saveCollision)
+ BPPAssetArray& assetArray = projectParams.blast.blastAssets;
+ int aaas = 0;
+ for (; aaas < assetArray.arraySizes[0]; aaas++)
+ {
+ std::string assetname = assetArray.buf[aaas].name;
+ if (assetname == modelAsset.name)
+ break;
+ }
+ if (aaas == assetArray.arraySizes[0])
{
- copy(fileReferences.collision, ui->lineEditCollision->text().toUtf8().data());
- // to do: save collision file
+ return;
}
+
+ BPPAsset& asset = assetArray.buf[aaas];
+
+ copy(asset.fbx, ui->lineEditFBX->text().toUtf8().data());
+ asset.exportFBX = ui->checkBoxFBX->isChecked();
+
+ copy(asset.obj, ui->lineEditObj->text().toUtf8().data());
+ asset.exportOBJ = ui->checkBoxObj->isChecked();
+
+ copy(asset.collision, ui->lineEditCollision->text().toUtf8().data());
+ asset.exportCollision = ui->checkBoxCollision->isChecked();
+
+ copy(asset.llasset, ui->lineEditLLAsset->text().toUtf8().data());
+ asset.exportLLAsset = ui->checkBoxLLAsset->isChecked();
+
+ copy(asset.tkasset, ui->lineEditTKAsset->text().toUtf8().data());
+ asset.exportTKAsset = ui->checkBoxTKAsset->isChecked();
+
+ copy(asset.bpxa, ui->lineEditBPXA->text().toUtf8().data());
+ asset.exportBPXA = ui->checkBoxBPXA->isChecked();
+
+ SampleManager::ins()->exportAsset();
}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.h
index e393f33..71905df 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.h
@@ -16,7 +16,9 @@ public:
~FileReferencesPanel();
void updateValues();
-private slots:
+ static FileReferencesPanel* ins();
+
+public slots:
void on_btnOpenFile_clicked();
void on_btnReload_clicked();
@@ -25,17 +27,21 @@ private slots:
void on_checkBoxFBX_stateChanged(int arg1);
- void on_checkBoxBlast_stateChanged(int arg1);
+ void on_checkBoxObj_stateChanged(int arg1);
void on_checkBoxCollision_stateChanged(int arg1);
+
+ void on_checkBoxLLAsset_stateChanged(int arg1);
+
+ void on_checkBoxTKAsset_stateChanged(int arg1);
+
+ void on_checkBoxBPXA_stateChanged(int arg1);
void on_btnSave_clicked();
private:
Ui::FileReferencesPanel *ui;
- bool _saveFBX;
- bool _saveBlast;
- bool _saveCollision;
+ bool bValid;
};
#endif // FILEREFERENCESPANEL_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.cpp
index a537140..daf4397 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.cpp
@@ -1,10 +1,12 @@
#include "FiltersDockWidget.h"
#include "ui_FiltersDockWidget.h"
-#include "ProjectParams.h"
#include <QtWidgets/QInputDialog>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QMessageBox>
#include "SampleManager.h"
+#include "BlastSceneTree.h"
+#include "BlastFamily.h"
+#include "ViewerOutput.h"
const QString LISTITEM_NORMAL_STYLESHEET = ":enabled { background: rgb(68,68,68); }";
@@ -12,7 +14,245 @@ const QString LISTITEM_SELECTED_STYLESHEET = ":enabled { background: rgba(118,18
const QString LISTITEM_BUTTON_STYLESHEET = ":enabled { border: 0px; }";
-class FilterItemWidget;
+class FilterOperation
+{
+public:
+ virtual void execute(BlastNode *node) = 0;
+};
+
+class FilterVisitor : public BlastVisitorBase
+{
+public:
+ FilterVisitor(FilterPreset& filterPreset, FilterOperation& filterOperation)
+ : resultCount(0)
+ , _filterPreset(filterPreset)
+ , _filterOperation(filterOperation)
+
+ {
+
+ }
+
+ virtual void visit(BlastNode *node);
+
+ int resultCount;
+private:
+ bool _canSatisfyFilter(BlastNode *node);
+
+ FilterPreset& _filterPreset;
+ FilterOperation& _filterOperation;
+};
+
+void FilterVisitor::visit(BlastNode *node)
+{
+ if (_canSatisfyFilter(node))
+ {
+ _filterOperation.execute(node);
+ ++resultCount;
+ }
+}
+
+bool FilterVisitor::_canSatisfyFilter(BlastNode *node)
+{
+ EFilterRestriction restrictions = eFilterRestriction_Invalid;
+
+ for (std::vector<EFilterRestriction>::iterator itr = _filterPreset.filters.begin(); itr != _filterPreset.filters.end(); ++itr)
+ {
+ restrictions = (EFilterRestriction)(restrictions | (*itr));
+ }
+
+ bool matchDepth = false, matchItemType = false;
+
+ // jude whether current node can be filtered by depth restrictions
+ if (restrictions & eFilterRestriction_DepthAll)
+ {
+ matchDepth = true;
+ }
+ else
+ {
+ int nodeDepth = BlastTreeData::getDepth(node);
+ int allDepthRestrictions = eFilterRestriction_Depth0 | eFilterRestriction_Depth1 | eFilterRestriction_Depth2 | eFilterRestriction_Depth3 | eFilterRestriction_Depth4 | eFilterRestriction_Depth5;
+
+ if ((restrictions & eFilterRestriction_AllDescendants) && (restrictions & eFilterRestriction_AllParents))
+ {
+ if (restrictions & allDepthRestrictions)
+ {
+ matchDepth = true;
+ }
+ }
+ else if ((restrictions & eFilterRestriction_AllDescendants) && !(restrictions & eFilterRestriction_AllParents))
+ {
+ int expectMinDepthRestirction = 5;
+ if ((restrictions & eFilterRestriction_Depth0))
+ {
+ expectMinDepthRestirction = 0;
+ }
+ else if ((restrictions & eFilterRestriction_Depth1))
+ {
+ expectMinDepthRestirction = 1;
+ }
+ else if ((restrictions & eFilterRestriction_Depth2))
+ {
+ expectMinDepthRestirction = 2;
+ }
+ else if ((restrictions & eFilterRestriction_Depth3))
+ {
+ expectMinDepthRestirction = 3;
+ }
+ else if ((restrictions & eFilterRestriction_Depth4))
+ {
+ expectMinDepthRestirction = 4;
+ }
+ else if ((restrictions & eFilterRestriction_Depth5))
+ {
+ expectMinDepthRestirction = 5;
+ }
+
+ if (expectMinDepthRestirction <= nodeDepth)
+ {
+ matchDepth = true;
+ }
+ }
+ else if (!(restrictions & eFilterRestriction_AllDescendants) && (restrictions & eFilterRestriction_AllParents))
+ {
+ int expectMaxDepthRestirction = 0;
+ if ((restrictions & eFilterRestriction_Depth5))
+ {
+ expectMaxDepthRestirction = 5;
+ }
+ else if ((restrictions & eFilterRestriction_Depth4))
+ {
+ expectMaxDepthRestirction = 4;
+ }
+ else if ((restrictions & eFilterRestriction_Depth3))
+ {
+ expectMaxDepthRestirction = 3;
+ }
+ else if ((restrictions & eFilterRestriction_Depth2))
+ {
+ expectMaxDepthRestirction = 2;
+ }
+ else if ((restrictions & eFilterRestriction_Depth1))
+ {
+ expectMaxDepthRestirction = 1;
+ }
+ else if ((restrictions & eFilterRestriction_Depth0))
+ {
+ expectMaxDepthRestirction = 0;
+ }
+
+ if (nodeDepth <= expectMaxDepthRestirction)
+ {
+ matchDepth = true;
+ }
+ }
+ else if (!(restrictions & eFilterRestriction_AllDescendants) && !(restrictions & eFilterRestriction_AllParents))
+ {
+ EFilterRestriction expectDepthRestriction = (EFilterRestriction)(eFilterRestriction_Depth0 << nodeDepth);
+
+ if (restrictions & expectDepthRestriction)
+ {
+ matchDepth = true;
+ }
+ }
+ }
+
+ // jude whether current node can be filtered by item type restrictions
+ if ((restrictions & eFilterRestriction_ItemTypeAll))
+ {
+ matchItemType = true;
+ }
+ else
+ {
+ EBlastNodeType nodeType = node->getType();
+ if (eChunk == nodeType)
+ {
+ BlastChunkNode* chunkNode = (BlastChunkNode*)node;
+ if (restrictions & eFilterRestriction_Chunk)
+ {
+ matchItemType = true;
+ }
+ else if (restrictions & eFilterRestriction_SupportChunk)
+ {
+ if (chunkNode->isSupport())
+ {
+ matchItemType = true;
+ }
+ }
+ else if (restrictions & eFilterRestriction_StaticSupportChunk)
+ {
+ if (chunkNode->isSupport() && chunkNode->isStatic())
+ {
+ matchItemType = true;
+ }
+ }
+ }
+ else if (eBond == nodeType)
+ {
+ BlastBondNode* bondNode = (BlastBondNode*)node;
+ if (restrictions & eFilterRestriction_Bond)
+ {
+ matchItemType = true;
+ }
+ else if (restrictions & eFilterRestriction_WorldBond)
+ {
+ if (bondNode->isWolrd())
+ {
+ matchItemType = true;
+ }
+ }
+ }
+ }
+
+ if ((restrictions & eFilterRestriction_EqualTo) && (restrictions & eFilterRestriction_NotEquaTo))
+ {
+ return true;
+ }
+ else if (!(restrictions & eFilterRestriction_EqualTo) && !(restrictions & eFilterRestriction_NotEquaTo)
+ || (restrictions & eFilterRestriction_EqualTo))
+ {
+ if (matchDepth && matchItemType)
+ return true;
+ }
+ else if ((restrictions & eFilterRestriction_NotEquaTo))
+ {
+ if (!(matchDepth && matchItemType))
+ return true;
+ }
+
+ return false;
+}
+
+class FilterSelectOperation : public FilterOperation
+{
+public:
+ virtual void execute(BlastNode *node)
+ {
+ if (nullptr != node)
+ {
+ BlastSceneTree::ins()->selectTreeItem(node);
+ }
+ }
+};
+
+class FilterVisibilityOperation : public FilterOperation
+{
+public:
+ FilterVisibilityOperation(bool visible)
+ : _visible(visible)
+ {
+ }
+
+ virtual void execute(BlastNode *node)
+ {
+ if (nullptr != node)
+ {
+ node->setVisible(_visible);
+ }
+ }
+
+private:
+ bool _visible;
+};
struct FilterItemInfo
{
@@ -27,11 +267,11 @@ public:
QString text;
};
-FilterItemWidget::FilterItemWidget(FiltersDockWidget* parent, QListWidgetItem* item, const QString& filterPreset, int depth)
+FilterItemWidget::FilterItemWidget(FiltersDockWidget* parent, QListWidgetItem* item, const QString& filterPreset, EFilterRestriction restriction)
: QWidget(parent)
, _relatedListWidgetItem(item)
, _filterPreset(filterPreset)
- , _depth(depth)
+ , _restriction(restriction)
{
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
@@ -76,21 +316,32 @@ void FilterItemWidget::onRemoveButtonClicked()
FiltersDockWidget::FiltersDockWidget(QWidget *parent) :
QDockWidget(parent),
ui(new Ui::FiltersDockWidget),
+ _updateData(true),
_filterUIItems(),
_filterItemWidgets(),
_lastSelectRow(-1)
{
ui->setupUi(this);
- _depthButtons.push_back(ui->btnDepth0);
- _depthButtons.push_back(ui->btnDepth1);
- _depthButtons.push_back(ui->btnDepth2);
- _depthButtons.push_back(ui->btnDepth3);
- _depthButtons.push_back(ui->btnDepth4);
- _depthButtons.push_back(ui->btnDepth5);
+ _restrictionActionMap[eFilterRestriction_AllDescendants] = ui->actionAllDescendants;
+ _restrictionActionMap[eFilterRestriction_AllParents] = ui->actionAllParents;
+ _restrictionActionMap[eFilterRestriction_DepthAll] = ui->actionDepthAll;
+ _restrictionActionMap[eFilterRestriction_Depth0] = ui->actionDepth0;
+ _restrictionActionMap[eFilterRestriction_Depth1] = ui->actionDepth1;
+ _restrictionActionMap[eFilterRestriction_Depth2] = ui->actionDepth2;
+ _restrictionActionMap[eFilterRestriction_Depth3] = ui->actionDepth3;
+ _restrictionActionMap[eFilterRestriction_Depth4] = ui->actionDepth4;
+ _restrictionActionMap[eFilterRestriction_Depth5] = ui->actionDepth5;
+ _restrictionActionMap[eFilterRestriction_ItemTypeAll] = ui->actionItemTypeAll;
+ _restrictionActionMap[eFilterRestriction_Chunk] = ui->actionChunk;
+ _restrictionActionMap[eFilterRestriction_SupportChunk] = ui->actionSupportChunk;
+ _restrictionActionMap[eFilterRestriction_StaticSupportChunk] = ui->actionStaticSupportChunk;
+ _restrictionActionMap[eFilterRestriction_Bond] = ui->actionBond;
+ _restrictionActionMap[eFilterRestriction_WorldBond] = ui->actionWorldBond;
+ _restrictionActionMap[eFilterRestriction_EqualTo] = ui->actionEqualTo;
+ _restrictionActionMap[eFilterRestriction_NotEquaTo] = ui->actionNotEquaTo;
_updateFilterItemList();
- _updateFilterDepthBtns();
}
FiltersDockWidget::~FiltersDockWidget()
@@ -100,18 +351,32 @@ FiltersDockWidget::~FiltersDockWidget()
void FiltersDockWidget::updateValues()
{
- BPParams& projectParams = BlastProject::ins().getParams();
- BPPFilterPresetArray& filterPresetArray = projectParams.filter.filters;
-
+ _updateData = false;
ui->comboBoxFilterPreset->clear();
+ std::vector<FilterPreset>& filterPresets = BlastProject::ins().getFilterPresets();
QStringList filterNames;
- int count = filterPresetArray.arraySizes[0];
+ filterNames.append("Default");
+ int count = (int)filterPresets.size();
for (int i = 0; i < count; ++i)
{
- filterNames.append(filterPresetArray.buf[i].name.buf);
+ filterNames.append(filterPresets[i].name.c_str());
}
ui->comboBoxFilterPreset->addItems(filterNames);
+ BPParams& projectParams = BlastProject::ins().getParams();
+ if (nullptr == projectParams.filter.activeFilter.buf
+ || 0 == strlen(projectParams.filter.activeFilter.buf)
+ || !(BlastProject::ins().isFilterPresetNameExist(projectParams.filter.activeFilter.buf)))
+ {
+ ui->comboBoxFilterPreset->setCurrentIndex(0);
+ }
+ else
+ {
+ ui->comboBoxFilterPreset->setCurrentText(projectParams.filter.activeFilter.buf);
+ }
+
+ _updateFilterItemList();
+
if (count > 0)
{
ui->btnModifyFilterPreset->setEnabled(true);
@@ -122,15 +387,18 @@ void FiltersDockWidget::updateValues()
ui->btnModifyFilterPreset->setEnabled(false);
ui->btnRemoveFilterPreset->setEnabled(false);
}
+ _updateData = true;
}
void FiltersDockWidget::on_comboBoxFilterPreset_currentIndexChanged(int index)
{
+ if (!_updateData)
+ return;
+
BPParams& projectParams = BlastProject::ins().getParams();
- projectParams.filter.activeFilter = index;
+ copy(projectParams.filter.activeFilter, ui->comboBoxFilterPreset->currentText().toUtf8().data());
_updateFilterItemList();
- _updateFilterDepthBtns();
}
void FiltersDockWidget::on_btnAddFilterPrest_clicked()
@@ -161,6 +429,12 @@ void FiltersDockWidget::on_btnAddFilterPrest_clicked()
void FiltersDockWidget::on_btnModifyFilterPreset_clicked()
{
+ if (ui->comboBoxFilterPreset->currentIndex() < 1)
+ {
+ QMessageBox::warning(this, "Blast Tool", "You should select an filter preset!");
+ return;
+ }
+
QByteArray tmp = ui->comboBoxFilterPreset->currentText().toUtf8();
const char* oldName = tmp.data();
@@ -191,87 +465,274 @@ void FiltersDockWidget::on_btnModifyFilterPreset_clicked()
void FiltersDockWidget::on_btnRemoveFilterPreset_clicked()
{
+ if (ui->comboBoxFilterPreset->currentIndex() < 1)
+ {
+ QMessageBox::warning(this, "Blast Tool", "You should select an filter preset!");
+ return;
+ }
+
QByteArray tmp = ui->comboBoxFilterPreset->currentText().toUtf8();
const char* name = tmp.data();
BlastProject::ins().removeFilterPreset(name);
updateValues();
}
-void FiltersDockWidget::on_btnDepth0_clicked(bool val)
+void FiltersDockWidget::on_btnSaveFilterPreset_clicked()
{
- _addRemoveDepthFilter(0, val);
+ BlastProject::ins().saveFilterPreset();
}
-void FiltersDockWidget::on_btnDepth1_clicked(bool val)
+void FiltersDockWidget::on_actionAllDescendants_triggered(bool checked)
{
- _addRemoveDepthFilter(1, val);
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_AllDescendants, checked);
}
-void FiltersDockWidget::on_btnDepth2_clicked(bool val)
+void FiltersDockWidget::on_actionAllParents_triggered(bool checked)
{
- _addRemoveDepthFilter(2, val);
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_AllParents, checked);
}
-void FiltersDockWidget::on_btnDepth3_clicked(bool val)
+void FiltersDockWidget::on_actionDepthAll_triggered(bool checked)
{
- _addRemoveDepthFilter(3, val);
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_DepthAll, checked);
}
-void FiltersDockWidget::on_btnDepth4_clicked(bool val)
+void FiltersDockWidget::on_actionDepth0_triggered(bool checked)
{
- _addRemoveDepthFilter(4, val);
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_Depth0, checked);
}
-void FiltersDockWidget::on_btnDepth5_clicked(bool val)
+void FiltersDockWidget::on_actionDepth1_triggered(bool checked)
{
- _addRemoveDepthFilter(5, val);
+ _addRemoveRestriction(eFilterRestriction_Depth1, checked);
}
-void FiltersDockWidget::on_btnAddDepthFilter_clicked()
+void FiltersDockWidget::on_actionDepth2_triggered(bool checked)
{
+ if (!_updateData)
+ return;
+ _addRemoveRestriction(eFilterRestriction_Depth2, checked);
}
-void FiltersDockWidget::on_btnAddFilter_clicked()
+void FiltersDockWidget::on_actionDepth3_triggered(bool checked)
{
+ if (!_updateData)
+ return;
+ _addRemoveRestriction(eFilterRestriction_Depth3, checked);
+}
+
+void FiltersDockWidget::on_actionDepth4_triggered(bool checked)
+{
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_Depth4, checked);
+}
+
+void FiltersDockWidget::on_actionDepth5_triggered(bool checked)
+{
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_Depth5, checked);
+}
+
+void FiltersDockWidget::on_actionItemTypeAll_triggered(bool checked)
+{
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_ItemTypeAll, checked);
+}
+
+void FiltersDockWidget::on_actionChunk_triggered(bool checked)
+{
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_Chunk, checked);
+}
+
+void FiltersDockWidget::on_actionSupportChunk_triggered(bool checked)
+{
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_SupportChunk, checked);
+}
+
+void FiltersDockWidget::on_actionStaticSupportChunk_triggered(bool checked)
+{
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_StaticSupportChunk, checked);
+}
+
+void FiltersDockWidget::on_actionBond_triggered(bool checked)
+{
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_Bond, checked);
+}
+
+void FiltersDockWidget::on_actionWorldBond_triggered(bool checked)
+{
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_WorldBond, checked);
+}
+
+void FiltersDockWidget::on_actionEqualTo_triggered(bool checked)
+{
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_EqualTo, checked);
+}
+
+void FiltersDockWidget::on_actionNotEquaTo_triggered(bool checked)
+{
+ if (!_updateData)
+ return;
+
+ _addRemoveRestriction(eFilterRestriction_NotEquaTo, checked);
}
void FiltersDockWidget::on_btnSelect_clicked()
{
- std::vector<uint32_t> depths;
- int row = ui->listWidget->currentRow();
- if (-1 != row)
+ FilterPreset filterPreset("Default");
+ FilterPreset* filterPresetPtr = BlastProject::ins().getFilterPreset(ui->comboBoxFilterPreset->currentText().toUtf8().data());
+ if (nullptr == filterPresetPtr)
+ {
+ BPPFilter& bppFilter = BlastProject::ins().getParams().filter;
+ for (int i = 0; i < bppFilter.filterRestrictions.arraySizes[0]; ++i)
+ {
+ filterPreset.filters.push_back(convertStringToFilterRestriction(bppFilter.filterRestrictions.buf[i]));
+ }
+ }
+ else
{
- depths.push_back(_filterItemWidgets[row]->_depth);
+ filterPreset = *filterPresetPtr;
}
- SampleManager::ins()->setChunkSelected(depths, true);
+
+ // clear old selection
+ BlastSceneTree::ins()->updateValues(false);
+
+ FilterSelectOperation operation;
+ FilterVisitor visitor(filterPreset, operation);
+ BlastTreeData::ins().traverse(visitor);
+
+ if (0 == visitor.resultCount)
+ {
+ viewer_msg("No items statify current filters");
+ }
+ //BlastSceneTree::ins()->updateValues(false);
+
+ //std::vector<uint32_t> depths;
+ //for (FilterItemWidget* itemWidget : _filterItemWidgets)
+ //{
+ // depths.push_back(itemWidget->_restriction);
+ //}
+ ////SampleManager::ins()->setChunkSelected(depths, true);
+ //BlastSceneTree::ins()->setChunkSelected(depths, true);
}
void FiltersDockWidget::on_btnVisible_clicked()
{
- std::vector<uint32_t> depths;
- int row = ui->listWidget->currentRow();
- if (-1 != row)
+ FilterPreset filterPreset("Default");
+ FilterPreset* filterPresetPtr = BlastProject::ins().getFilterPreset(ui->comboBoxFilterPreset->currentText().toUtf8().data());
+ if (nullptr == filterPresetPtr)
+ {
+ BPPFilter& bppFilter = BlastProject::ins().getParams().filter;
+ for (int i = 0; i < bppFilter.filterRestrictions.arraySizes[0]; ++i)
+ {
+ filterPreset.filters.push_back(convertStringToFilterRestriction(bppFilter.filterRestrictions.buf[i]));
+ }
+ }
+ else
+ {
+ filterPreset = *filterPresetPtr;
+ }
+
+ FilterVisibilityOperation operation(true);
+ FilterVisitor visitor(filterPreset, operation);
+ BlastTreeData::ins().traverse(visitor);
+ BlastSceneTree::ins()->updateValues(false);
+ if (0 == visitor.resultCount)
{
- depths.push_back(_filterItemWidgets[row]->_depth);
+ viewer_msg("No items statify current filters");
}
- SampleManager::ins()->setChunkVisible(depths, true);
+ //std::vector<uint32_t> depths;
+ //for (FilterItemWidget* itemWidget : _filterItemWidgets)
+ //{
+ // depths.push_back(itemWidget->_restriction);
+ //}
+ ////SampleManager::ins()->setChunkVisible(depths, true);
+ //BlastSceneTree::ins()->setChunkVisible(depths, true);
+ //// refresh display in scene tree
+ //BlastSceneTree* pBlastSceneTree = BlastSceneTree::ins();
+ //pBlastSceneTree->updateValues(false);
}
void FiltersDockWidget::on_btnInVisible_clicked()
{
- std::vector<uint32_t> depths;
- int row = ui->listWidget->currentRow();
- if (-1 != row)
+ FilterPreset filterPreset("Default");
+ FilterPreset* filterPresetPtr = BlastProject::ins().getFilterPreset(ui->comboBoxFilterPreset->currentText().toUtf8().data());
+ if (nullptr == filterPresetPtr)
+ {
+ BPPFilter& bppFilter = BlastProject::ins().getParams().filter;
+ for (int i = 0; i < bppFilter.filterRestrictions.arraySizes[0]; ++i)
+ {
+ filterPreset.filters.push_back(convertStringToFilterRestriction(bppFilter.filterRestrictions.buf[i]));
+ }
+ }
+ else
{
- depths.push_back(_filterItemWidgets[row]->_depth);
+ filterPreset = *filterPresetPtr;
}
- SampleManager::ins()->setChunkVisible(depths, false);
+
+ FilterVisibilityOperation operation(false);
+ FilterVisitor visitor(filterPreset, operation);
+ BlastTreeData::ins().traverse(visitor);
+ BlastSceneTree::ins()->updateValues(false);
+ if (0 == visitor.resultCount)
+ {
+ viewer_msg("No items statify current filters");
+ }
+ //std::vector<uint32_t> depths;
+ //for (FilterItemWidget* itemWidget : _filterItemWidgets)
+ //{
+ // depths.push_back(itemWidget->_restriction);
+ //}
+ ////SampleManager::ins()->setChunkVisible(depths, false);
+ //BlastSceneTree::ins()->setChunkVisible(depths, false);
+ //// refresh display in scene tree
+ //BlastSceneTree* pBlastSceneTree = BlastSceneTree::ins();
+ //pBlastSceneTree->updateValues(false);
}
void FiltersDockWidget::on_listWidget_currentRowChanged(int index)
{
+ if (!_updateData)
+ return;
+
if (-1 != _lastSelectRow && _lastSelectRow < _filterItemWidgets.size())
static_cast<FilterItemWidget*>(_filterItemWidgets[_lastSelectRow])->deSelect();
@@ -292,10 +753,14 @@ void FiltersDockWidget::onListWidgetRemoveBtnClicked(QListWidgetItem* item)
_filterItemWidgets.erase(std::find(_filterItemWidgets.begin(), _filterItemWidgets.end(), toRemoveItem->second->itemWidget));
- if (ui->comboBoxFilterPreset->currentIndex() != -1)
+ if (0 < ui->comboBoxFilterPreset->currentIndex())
{
QByteArray filterPreset = itemWidget->_filterPreset.toUtf8();
- BlastProject::ins().removeFilterDepth(filterPreset.data(), itemWidget->_depth);
+ BlastProject::ins().removeFilterRestriction(filterPreset.data(), itemWidget->_restriction);
+ }
+ else if (0 == ui->comboBoxFilterPreset->currentIndex())
+ {
+ removeItem(BlastProject::ins().getParams().filter.filterRestrictions, convertFilterRestrictionToString(itemWidget->_restriction));
}
ui->listWidget->takeItem(ui->listWidget->row(item));
@@ -304,13 +769,14 @@ void FiltersDockWidget::onListWidgetRemoveBtnClicked(QListWidgetItem* item)
delete itemWidget;
_filterUIItems.erase(toRemoveItem);
- //_updateFilterItemList();
- _updateFilterDepthBtns();
+ _updateFilterItemList();
+
}
}
void FiltersDockWidget::_updateFilterItemList()
{
+ _updateData = false;
/// remove former ui info
map<QListWidgetItem*, FilterItemInfo*>::iterator theEnd = _filterUIItems.end();
for (map<QListWidgetItem*, FilterItemInfo*>::iterator itr = _filterUIItems.begin(); itr != theEnd; ++itr)
@@ -324,66 +790,88 @@ void FiltersDockWidget::_updateFilterItemList()
ui->listWidget->clear();
_filterItemWidgets.clear();
- int filterPresetIndex = ui->comboBoxFilterPreset->currentIndex();
- if (filterPresetIndex < 0)
- return;
-
- BPParams& projectParams = BlastProject::ins().getParams();
- BPPFilterPresetArray& filterPresetArray = projectParams.filter.filters;
- BPPFilterPreset& filterPresset = filterPresetArray.buf[filterPresetIndex];
+ FilterPreset* filterPreset = BlastProject::ins().getFilterPreset(ui->comboBoxFilterPreset->currentText().toUtf8().data());
- int filterCount = filterPresset.depthFilters.arraySizes[0];
-
- for (int i = 0; i < filterCount; ++i)
+ if (nullptr != filterPreset)
{
- QListWidgetItem* item = new QListWidgetItem(NULL);
- int depth = filterPresset.depthFilters.buf[i];
- FilterItemWidget* itemWidget = new FilterItemWidget(this, item, filterPresset.name.buf, depth);
-
- QString depthFilterLabel = QString(QObject::tr("Depth-%1")).arg(depth);
- _filterUIItems.insert(std::make_pair(item, new FilterItemInfo(itemWidget, depthFilterLabel)));
- itemWidget->setText(depthFilterLabel);
- _filterItemWidgets.push_back(itemWidget);
+ for (EFilterRestriction restriction : filterPreset->filters)
+ {
+ _addFilterListItem(filterPreset->name.c_str(), restriction);
+ }
+ }
+ else
+ {
+ BPParams& projectParams = BlastProject::ins().getParams();
+ BPPStringArray& filterRestrictions = projectParams.filter.filterRestrictions;
- ui->listWidget->addItem(item);
- ui->listWidget->setItemWidget(item, itemWidget);
+ for (int i = 0; i < filterRestrictions.arraySizes[0]; ++i)
+ {
+ _addFilterListItem("Default", convertStringToFilterRestriction(filterRestrictions.buf[i].buf));
+ }
}
+
+ _updateFilterUIs();
+
+ _updateData = true;
}
-void FiltersDockWidget::_updateFilterDepthBtns()
+void FiltersDockWidget::_addFilterListItem(const char* filterPresetName, EFilterRestriction restriction)
{
- for (int i = 0; i <= 5; ++i)
- _depthButtons[i]->setChecked(false);
+ QListWidgetItem* item = new QListWidgetItem(NULL);
+ FilterItemWidget* itemWidget = new FilterItemWidget(this, item, filterPresetName, restriction);
- int filterPresetIndex = ui->comboBoxFilterPreset->currentIndex();
- if (filterPresetIndex < 0)
- return;
+ QString depthFilterLabel = convertFilterRestrictionToString(restriction);
+ _filterUIItems.insert(std::make_pair(item, new FilterItemInfo(itemWidget, depthFilterLabel)));
+ itemWidget->setText(depthFilterLabel);
+ _filterItemWidgets.push_back(itemWidget);
- BPParams& projectParams = BlastProject::ins().getParams();
- BPPFilterPresetArray& filterPresetArray = projectParams.filter.filters;
- BPPFilterPreset& filterPresset = filterPresetArray.buf[filterPresetIndex];
+ ui->listWidget->addItem(item);
+ ui->listWidget->setItemWidget(item, itemWidget);
+}
- int filterCount = filterPresset.depthFilters.arraySizes[0];
+void FiltersDockWidget::_updateFilterUIs()
+{
+ for (map<EFilterRestriction, QAction*>::iterator itr = _restrictionActionMap.begin(); itr != _restrictionActionMap.end(); ++itr)
+ itr->second->setChecked(false);
+
+ FilterPreset* filterPreset = BlastProject::ins().getFilterPreset(ui->comboBoxFilterPreset->currentText().toUtf8().data());
- for (int i = 0; i < filterCount; ++i)
+ if (nullptr != filterPreset)
{
- int depth = filterPresset.depthFilters.buf[i];
+ for (EFilterRestriction restriction : filterPreset->filters)
+ {
+ _restrictionActionMap[restriction]->setChecked(true);
+ }
+ }
+ else
+ {
+ BPPStringArray& filterRestrictions = BlastProject::ins().getParams().filter.filterRestrictions;
- _depthButtons[depth]->setChecked(true);
+ for (int i = 0; i < filterRestrictions.arraySizes[0]; ++i)
+ {
+ _restrictionActionMap[convertStringToFilterRestriction(filterRestrictions.buf[i].buf)]->setChecked(true);
+ }
}
}
-void FiltersDockWidget::_addRemoveDepthFilter(int depth, bool add)
+void FiltersDockWidget::_addRemoveRestriction(EFilterRestriction restriction, bool add)
{
- if (ui->comboBoxFilterPreset->currentIndex() != -1)
+ if (0 < ui->comboBoxFilterPreset->currentIndex())
{
QByteArray filterPreset = ui->comboBoxFilterPreset->currentText().toUtf8();
if (add)
- BlastProject::ins().addFilterDepth(filterPreset.data(), depth);
+ BlastProject::ins().addFilterRestriction(filterPreset.data(), restriction);
else
- BlastProject::ins().removeFilterDepth(filterPreset.data(), depth);
-
- _updateFilterItemList();
+ BlastProject::ins().removeFilterRestriction(filterPreset.data(), restriction);
+ }
+ else if (0 == ui->comboBoxFilterPreset->currentIndex())
+ {
+ BPPFilter& filter = BlastProject::ins().getParams().filter;
+ if (add)
+ addItem(filter.filterRestrictions, convertFilterRestrictionToString(restriction));
+ else
+ removeItem(filter.filterRestrictions, convertFilterRestrictionToString(restriction));
}
+ _updateFilterItemList();
}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.h b/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.h
index cf25073..43606dc 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.h
@@ -4,6 +4,7 @@
#include <QtWidgets/QDockWidget>
#include <vector>
#include <map>
+#include "ProjectParams.h"
using namespace std;
namespace Ui {
@@ -13,6 +14,7 @@ class FiltersDockWidget;
class QLabel;
class QPushButton;
class QListWidgetItem;
+class QAction;
struct FilterItemInfo;
class FilterItemWidget;
class FiltersDockWidget;
@@ -21,7 +23,7 @@ class FilterItemWidget : public QWidget
{
Q_OBJECT
public:
- FilterItemWidget(FiltersDockWidget* parent, QListWidgetItem* item, const QString& filterPreset, int depth);
+ FilterItemWidget(FiltersDockWidget* parent, QListWidgetItem* item, const QString& filterPreset, EFilterRestriction restriction);
~FilterItemWidget()
{
}
@@ -41,7 +43,7 @@ public:
QPushButton* _removeBtn;
QListWidgetItem* _relatedListWidgetItem;
QString _filterPreset;
- int _depth;
+ EFilterRestriction _restriction;
};
class FiltersDockWidget : public QDockWidget
@@ -54,51 +56,47 @@ public:
void updateValues();
private slots:
- void on_comboBoxFilterPreset_currentIndexChanged(int index);
-
- void on_btnAddFilterPrest_clicked();
-
- void on_btnModifyFilterPreset_clicked();
-
- void on_btnRemoveFilterPreset_clicked();
-
- void on_btnDepth0_clicked(bool val);
-
- void on_btnDepth1_clicked(bool val);
-
- void on_btnDepth2_clicked(bool val);
-
- void on_btnDepth3_clicked(bool val);
-
- void on_btnDepth4_clicked(bool val);
-
- void on_btnDepth5_clicked(bool val);
-
- void on_btnAddDepthFilter_clicked();
-
- void on_btnAddFilter_clicked();
-
- void on_btnSelect_clicked();
-
- void on_btnVisible_clicked();
-
- void on_btnInVisible_clicked();
-
+ void on_comboBoxFilterPreset_currentIndexChanged(int index);
+ void on_btnAddFilterPrest_clicked();
+ void on_btnModifyFilterPreset_clicked();
+ void on_btnRemoveFilterPreset_clicked();
+ void on_btnSaveFilterPreset_clicked();
+ void on_actionAllDescendants_triggered(bool checked);
+ void on_actionAllParents_triggered(bool checked);
+ void on_actionDepthAll_triggered(bool checked);
+ void on_actionDepth0_triggered(bool checked);
+ void on_actionDepth1_triggered(bool checked);
+ void on_actionDepth2_triggered(bool checked);
+ void on_actionDepth3_triggered(bool checked);
+ void on_actionDepth4_triggered(bool checked);
+ void on_actionDepth5_triggered(bool checked);
+ void on_actionItemTypeAll_triggered(bool checked);
+ void on_actionChunk_triggered(bool checked);
+ void on_actionSupportChunk_triggered(bool checked);
+ void on_actionStaticSupportChunk_triggered(bool checked);
+ void on_actionBond_triggered(bool checked);
+ void on_actionWorldBond_triggered(bool checked);
+ void on_actionEqualTo_triggered(bool checked);
+ void on_actionNotEquaTo_triggered(bool checked);
+ void on_btnSelect_clicked();
+ void on_btnVisible_clicked();
+ void on_btnInVisible_clicked();
void on_listWidget_currentRowChanged(int index);
-
void onListWidgetRemoveBtnClicked(QListWidgetItem* item);
private:
void _updateFilterItemList();
- void _updateFilterDepthBtns();
- void _addRemoveDepthFilter(int depth, bool add);
+ void _addFilterListItem(const char* filterPresetName, EFilterRestriction restriction);
+ void _updateFilterUIs();
+ void _addRemoveRestriction(EFilterRestriction restriction, bool add);
private:
Ui::FiltersDockWidget *ui;
+ bool _updateData;
map<QListWidgetItem*, FilterItemInfo*> _filterUIItems;
vector<FilterItemWidget*> _filterItemWidgets;
int _lastSelectRow;
- vector<QPushButton*> _depthButtons;
+ map<EFilterRestriction, QAction*> _restrictionActionMap;
};
#endif // FILTERSDOCKWIDGET_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureCutoutSettingsPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FractureCutoutSettingsPanel.cpp
deleted file mode 100644
index ea24278..0000000
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureCutoutSettingsPanel.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-#include "FractureCutoutSettingsPanel.h"
-#include "ui_FractureCutoutSettingsPanel.h"
-#include "ProjectParams.h"
-#include <QtWidgets/QInputDialog>
-#include <QtWidgets/QLineEdit>
-#include <QtWidgets/QMessageBox>
-#include <QtCore/QFileInfo>
-#include "AppMainWindow.h"
-
-FractureCutoutSettingsPanel::FractureCutoutSettingsPanel(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::FractureCutoutSettingsPanel)
-{
- ui->setupUi(this);
-}
-
-FractureCutoutSettingsPanel::~FractureCutoutSettingsPanel()
-{
- delete ui;
-}
-
-void FractureCutoutSettingsPanel::updateValues()
-{
- BPPCutoutProjection& cutoutProjection = BlastProject::ins().getParams().fracture.cutoutProjection;
-
- _updateTextureListWidget();
-
- ui->comboBoxCutoutType->setCurrentIndex(cutoutProjection.cutoutType);
- ui->spinBoxPixelThreshold->setValue(cutoutProjection.pixelThreshold);
- ui->checkBoxTiled->setChecked(cutoutProjection.tiled);
- ui->checkBoxInvertU->setChecked(cutoutProjection.invertU);
- ui->checkBoxInvertV->setChecked(cutoutProjection.invertV);
-}
-
-void FractureCutoutSettingsPanel::on_btnAddTexture_clicked()
-{
- QString texName = AppMainWindow::Inst().OpenTextureFile();
-
- if (texName.isEmpty())
- return;
-
- QFileInfo fileInfo(texName);
- QByteArray ba = fileInfo.absoluteFilePath().toLocal8Bit();
- const char* filePath = (const char*)(ba);
-
- if (!BlastProject::ins().isCutoutTextureNameExist(texName.toUtf8().data()))
- {
- BlastProject::ins().addCutoutTexture(filePath);
- _updateTextureListWidget();
- ui->listWidget->setCurrentRow(ui->listWidget->count() - 1);
- }
- else
- {
- QMessageBox::warning(this, "Blast Tool", "The texture you selected is already exist!");
- }
-}
-
-void FractureCutoutSettingsPanel::on_btnReloadTexture_clicked()
-{
-
-}
-
-void FractureCutoutSettingsPanel::on_btnRemoveTexture_clicked()
-{
- if (ui->listWidget->currentRow() != -1)
- {
- QListWidgetItem *item = ui->listWidget->currentItem();
- QString texture = _getTexturePathByName(item->text());
- QByteArray ba = texture.toLocal8Bit();
- BlastProject::ins().removeCutoutTexture(ba.data());
- _updateTextureListWidget();
- }
-}
-
-void FractureCutoutSettingsPanel::on_listWidget_currentRowChanged(int currentRow)
-{
-
-}
-
-void FractureCutoutSettingsPanel::on_btnTextureMap_clicked()
-{
-
-}
-
-void FractureCutoutSettingsPanel::on_comboBoxCutoutType_currentIndexChanged(int index)
-{
- BPPCutoutProjection& cutoutProjection = BlastProject::ins().getParams().fracture.cutoutProjection;
- cutoutProjection.cutoutType = index;
-}
-
-void FractureCutoutSettingsPanel::on_spinBoxPixelThreshold_valueChanged(int arg1)
-{
- BPPCutoutProjection& cutoutProjection = BlastProject::ins().getParams().fracture.cutoutProjection;
- cutoutProjection.pixelThreshold = arg1;
-}
-
-void FractureCutoutSettingsPanel::on_checkBoxTiled_stateChanged(int arg1)
-{
- BPPCutoutProjection& cutoutProjection = BlastProject::ins().getParams().fracture.cutoutProjection;
- cutoutProjection.tiled = (arg1 != 0 ? true : false);
-}
-
-void FractureCutoutSettingsPanel::on_checkBoxInvertU_stateChanged(int arg1)
-{
- BPPCutoutProjection& cutoutProjection = BlastProject::ins().getParams().fracture.cutoutProjection;
- cutoutProjection.invertU = (arg1 != 0 ? true : false);
-}
-
-void FractureCutoutSettingsPanel::on_checkBoxInvertV_stateChanged(int arg1)
-{
- BPPCutoutProjection& cutoutProjection = BlastProject::ins().getParams().fracture.cutoutProjection;
- cutoutProjection.invertV = (arg1 != 0 ? true : false);
-}
-
-void FractureCutoutSettingsPanel::on_btnFitToObject_clicked()
-{
-
-}
-
-void FractureCutoutSettingsPanel::on_btnApplyFracture_clicked()
-{
-
-}
-
-QString FractureCutoutSettingsPanel::_getTexturePathByName(const QString& name)
-{
- BPPCutoutProjection& cutoutProjection = BlastProject::ins().getParams().fracture.cutoutProjection;
- BPPStringArray& textureArray = cutoutProjection.textures;
-
- int count = textureArray.arraySizes[0];
- for (int i = 0; i < count; ++i)
- {
- QFileInfo fileInfo(textureArray.buf[i].buf);
- if (fileInfo.baseName() == name)
- return textureArray.buf[i].buf;
- }
-
- return "";
-}
-
-void FractureCutoutSettingsPanel::_updateTextureListWidget()
-{
- BPPCutoutProjection& cutoutProjection = BlastProject::ins().getParams().fracture.cutoutProjection;
-
- ui->listWidget->clear();
- QStringList items;
- for (int i = 0; i < cutoutProjection.textures.arraySizes[0]; ++i)
- {
- QFileInfo fileInfo(cutoutProjection.textures.buf[i].buf);
- QByteArray ba = fileInfo.baseName().toLocal8Bit();
- const char* texture = (const char*)(ba);
- items.append(texture);
- }
- ui->listWidget->addItems(items);
-}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureCutoutSettingsPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FractureCutoutSettingsPanel.h
deleted file mode 100644
index 7faf2ae..0000000
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureCutoutSettingsPanel.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef FRACTURECUTOUTSETTINGSPANEL_H
-#define FRACTURECUTOUTSETTINGSPANEL_H
-
-#include <QtWidgets/QWidget>
-
-namespace Ui {
-class FractureCutoutSettingsPanel;
-}
-
-class FractureCutoutSettingsPanel : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit FractureCutoutSettingsPanel(QWidget *parent = 0);
- ~FractureCutoutSettingsPanel();
- void updateValues();
-
-private slots:
- void on_btnAddTexture_clicked();
-
- void on_btnReloadTexture_clicked();
-
- void on_btnRemoveTexture_clicked();
-
- void on_listWidget_currentRowChanged(int currentRow);
-
- void on_btnTextureMap_clicked();
-
- void on_comboBoxCutoutType_currentIndexChanged(int index);
-
- void on_spinBoxPixelThreshold_valueChanged(int arg1);
-
- void on_checkBoxTiled_stateChanged(int arg1);
-
- void on_checkBoxInvertU_stateChanged(int arg1);
-
- void on_checkBoxInvertV_stateChanged(int arg1);
-
- void on_btnFitToObject_clicked();
-
- void on_btnApplyFracture_clicked();
-
-private:
- QString _getTexturePathByName(const QString& name);
- void _updateTextureListWidget();
-
-private:
- Ui::FractureCutoutSettingsPanel *ui;
-};
-
-#endif // FRACTURECUTOUTSETTINGSPANEL_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.cpp
index 1f7068d..8a92933 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.cpp
@@ -1,12 +1,42 @@
#include "FractureGeneralPanel.h"
#include "ui_FractureGeneralPanel.h"
#include "ProjectParams.h"
+#include "BlastPlugin.h"
+#include <QtWidgets/QInputDialog>
+#include <QtWidgets/QLineEdit>
+#include <QtWidgets/QMessageBox>
+#include "FractureVoronoiSettingsPanel.h"
+#include "FractureSliceSettingsPanel.h"
+#include "FractureVisualizersPanel.h"
+#include "ExpandablePanel.h"
+#include "SampleManager.h"
+
+FractureGeneralPanel* pFractureGeneralPanel = nullptr;
+FractureGeneralPanel* FractureGeneralPanel::ins()
+{
+ return pFractureGeneralPanel;
+}
FractureGeneralPanel::FractureGeneralPanel(QWidget *parent) :
QWidget(parent),
- ui(new Ui::FractureGeneralPanel)
+ ui(new Ui::FractureGeneralPanel),
+ _updateData(true),
+ _voronoiPanel(nullptr),
+ _slicePanel(nullptr),
+ _visualizersPanel(nullptr),
+ _fractureVoronoiSettingsExpandlePanel(nullptr),
+ _fractureSliceSettingsExpandlePanel(nullptr)
{
ui->setupUi(this);
+ pFractureGeneralPanel = this;
+ m_bValid = true;
+
+ QStringList types;
+ types << "Voronoi" << "Slice";
+ _updateData = false;
+ ui->comboBoxFractureType->addItems(types);
+ ui->comboBoxFractureType->setCurrentIndex(0);
+ _updateData = true;
}
FractureGeneralPanel::~FractureGeneralPanel()
@@ -16,48 +46,258 @@ FractureGeneralPanel::~FractureGeneralPanel()
void FractureGeneralPanel::updateValues()
{
+ _updateData = false;
+ m_bValid = false;
+ ui->comboBoxApplyMaterial->clear();
+ m_bValid = true;
+
+ QStringList materialNames;
+ materialNames.append("None");
+ BPParams& projectParams = BlastProject::ins().getParams();
+ BPPGraphicsMaterialArray& theArray = projectParams.graphicsMaterials;
+ int count = theArray.arraySizes[0];
+ for (int i = 0; i < count; ++i)
+ {
+ BPPGraphicsMaterial& item = theArray.buf[i];
+ materialNames.append(item.name.buf);
+ }
+
+ m_bValid = false;
+ ui->comboBoxApplyMaterial->insertItems(0, materialNames);
+ m_bValid = true;
+
BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general;
- ui->comboBoxFracturePreset->setCurrentIndex(fractureGeneral.fracturePreset);
- ui->comboBoxFractureType->setCurrentIndex(fractureGeneral.fractureType);
- ui->checkBoxAddDepth->setChecked(fractureGeneral.addDepth);
- ui->checkBoxPerChunk->setChecked(fractureGeneral.perChunk);
- ui->checkBoxNewMatID->setChecked(fractureGeneral.newMatID);
+ std::vector<FracturePreset> presets = BlastProject::ins().getFracturePresets();
+ ui->comboBoxFracturePreset->clear();
+ QStringList presetNames;
+ presetNames.append("Default");
+ int countPresets = (int)presets.size();
+ if (countPresets > 0)
+ {
+ for (int i = 0; i < countPresets; ++i)
+ {
+ presetNames.append(presets[i].name.c_str());
+ }
+ }
+ ui->comboBoxFracturePreset->addItems(presetNames);
+
+ if (nullptr == fractureGeneral.fracturePreset.buf
+ || 0 == strlen(fractureGeneral.fracturePreset.buf)
+ || !(BlastProject::ins().isFracturePresetNameExist(fractureGeneral.fracturePreset.buf)))
+ {
+ ui->comboBoxFracturePreset->setCurrentIndex(0);
+ }
+ else
+ {
+ ui->comboBoxFracturePreset->setCurrentText(fractureGeneral.fracturePreset.buf);
+ }
+ _updateFractureUIs();
ui->comboBoxApplyMaterial->setCurrentIndex(fractureGeneral.applyMaterial);
+
+ bool checked = BlastProject::ins().getParams().fracture.general.autoSelectNewChunks;
+ ui->checkBoxAutoSelectNewChunks->setChecked(checked);
+ _updateData = true;
+}
+
+void FractureGeneralPanel::setFracturePanels(FractureVoronoiSettingsPanel* voronoiPanel, FractureSliceSettingsPanel* slicePanel, FractureVisualizersPanel* visulizersPanel)
+{
+ _voronoiPanel = voronoiPanel;
+ _slicePanel = slicePanel;
+ _visualizersPanel = visulizersPanel;
+}
+
+void FractureGeneralPanel::setFractureExpandablePanels(ExpandablePanel* voronoiPanel, ExpandablePanel* slicePanel)
+{
+ _fractureVoronoiSettingsExpandlePanel = voronoiPanel;
+ _fractureSliceSettingsExpandlePanel = slicePanel;
}
void FractureGeneralPanel::on_comboBoxFracturePreset_currentIndexChanged(int index)
{
+ if (!_updateData)
+ return;
+
BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general;
- fractureGeneral.fracturePreset = index;
+ copy(fractureGeneral.fracturePreset, ui->comboBoxFracturePreset->currentText().toStdString().c_str());
+ _updateFractureUIs();
}
-void FractureGeneralPanel::on_comboBoxFractureType_currentIndexChanged(int index)
+
+void FractureGeneralPanel::on_btnAddPreset_clicked()
{
- BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general;
- fractureGeneral.fractureType = index;
+ bool ok = false;
+ QString name = QInputDialog::getText(this,
+ tr("Blast Tool"),
+ tr("Please input name for new fracture preset:"),
+ QLineEdit::Normal,
+ "",
+ &ok);
+ bool nameExist = BlastProject::ins().isFracturePresetNameExist(name.toUtf8().data());
+ if (ok && !name.isEmpty() && !nameExist)
+ {
+ BlastProject::ins().addFracturePreset(name.toUtf8().data(), (FractureType)ui->comboBoxFractureType->currentIndex());
+ updateValues();
+ ui->comboBoxFracturePreset->setCurrentIndex(ui->comboBoxFracturePreset->count() - 1);
+ }
+ else if (ok && nameExist)
+ {
+ QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!");
+ }
+ else if (ok && name.isEmpty())
+ {
+ QMessageBox::warning(this, "Blast Tool", "You need input a name for the new preset!");
+ }
}
-void FractureGeneralPanel::on_checkBoxAddDepth_stateChanged(int arg1)
+void FractureGeneralPanel::on_btnModifyPreset_clicked()
{
- BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general;
- fractureGeneral.addDepth = (arg1 != 0 ? true : false);
+ if (ui->comboBoxFracturePreset->currentIndex() < 1)
+ {
+ QMessageBox::warning(this, "Blast Tool", "You should select an fracture preset!");
+ return;
+ }
+
+ QByteArray tmp = ui->comboBoxFracturePreset->currentText().toUtf8();
+ const char* oldName = tmp.data();
+
+ bool ok = false;
+ QString newName = QInputDialog::getText(this,
+ tr("Blast Tool"),
+ tr("Please input new name for the selected fracture preset:"),
+ QLineEdit::Normal,
+ oldName,
+ &ok);
+ bool nameExist = BlastProject::ins().isUserPresetNameExist(newName.toUtf8().data());
+ if (ok && !newName.isEmpty() && !nameExist)
+ {
+ int curIndex = ui->comboBoxFracturePreset->currentIndex() - 1;
+ if(curIndex >= 0)
+ {
+ std::vector<FracturePreset>& presets = BlastProject::ins().getFracturePresets();
+ presets[curIndex].name = newName.toUtf8().data();
+ updateValues();
+ ui->comboBoxFracturePreset->setCurrentIndex(curIndex + 1);
+ }
+ }
+ else if (ok && nameExist)
+ {
+ QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!");
+ }
+ else if (ok && newName.isEmpty())
+ {
+ QMessageBox::warning(this, "Blast Tool", "You need input a name for the selected preset!");
+ }
}
-void FractureGeneralPanel::on_checkBoxPerChunk_stateChanged(int arg1)
+void FractureGeneralPanel::on_btnSavePreset_clicked()
{
- BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general;
- fractureGeneral.perChunk = (arg1 != 0 ? true : false);
+ BlastProject::ins().saveFracturePreset();
}
-void FractureGeneralPanel::on_checkBoxNewMatID_stateChanged(int arg1)
+void FractureGeneralPanel::on_comboBoxFractureType_currentIndexChanged(int index)
{
+ if (!_updateData)
+ return;
+
BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general;
- fractureGeneral.newMatID = (arg1 != 0 ? true:false);
+ fractureGeneral.fractureType = index;
+
+ FracturePreset* fracturePreset = getCurrentFracturePreset();
+ if (fracturePreset != nullptr)
+ {
+ fracturePreset->setType((FractureType)index);
+ }
+ _showFracturePanel(ui->comboBoxFractureType->currentText());
}
void FractureGeneralPanel::on_comboBoxApplyMaterial_currentIndexChanged(int index)
{
+ if (!m_bValid)
+ return;
+
+ if (!_updateData)
+ return;
+
BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general;
fractureGeneral.applyMaterial = index;
}
+
+void FractureGeneralPanel::on_checkBoxAutoSelectNewChunks_stateChanged(int arg1)
+{
+ BlastProject::ins().getParams().fracture.general.autoSelectNewChunks = arg1;
+}
+
+FracturePreset* FractureGeneralPanel::getCurrentFracturePreset()
+{
+ int currentPreset = ui->comboBoxFracturePreset->currentIndex();
+
+ if (0 < currentPreset)
+ {
+ std::vector<FracturePreset>& presets = BlastProject::ins().getFracturePresets();
+ if (presets.size() > 0)
+ {
+ return &(presets[currentPreset - 1]);
+ }
+ }
+
+ return nullptr;
+}
+
+FracturePreset* FractureGeneralPanel::_getFracturePreset(const char* name)
+{
+ std::vector<FracturePreset>& presets = BlastProject::ins().getFracturePresets();
+
+ for (size_t i = 0; i < presets.size(); ++i)
+ {
+ if (presets[i].name == name)
+ return &(presets[i]);
+ }
+
+ return nullptr;
+}
+
+void FractureGeneralPanel::_updateFractureUIs()
+{
+ _updateData = false;
+
+ FracturePreset* fracturePreset = getCurrentFracturePreset();
+ if (fracturePreset != nullptr)
+ {
+ if (eFractureType_Voronoi == fracturePreset->type)
+ {
+ ui->comboBoxFractureType->setCurrentIndex(0);
+ }
+ else if (eFractureType_Slice == fracturePreset->type)
+ {
+ ui->comboBoxFractureType->setCurrentIndex(1);
+ }
+ }
+ else
+ {
+ BPPFracture& fracture = BlastProject::ins().getParams().fracture;
+ ui->comboBoxFractureType->setCurrentIndex(fracture.general.fractureType);
+ }
+
+ _showFracturePanel(ui->comboBoxFractureType->currentText());
+ _visualizersPanel->updateValues();
+ _updateData = true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+void FractureGeneralPanel::_showFracturePanel(const QString& fractireType)
+{
+ _fractureVoronoiSettingsExpandlePanel->hide();
+ _fractureSliceSettingsExpandlePanel->hide();
+ QString fractireTypeLower = fractireType.toLower();
+ if (fractireTypeLower == "voronoi")
+ {
+ _voronoiPanel->updateValues();
+ _fractureVoronoiSettingsExpandlePanel->show();
+ }
+ else if (fractireTypeLower == "slice")
+ {
+ _slicePanel->updateValues();
+ _fractureSliceSettingsExpandlePanel->show();
+ }
+}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.h
index 4b51f5e..1ab9f24 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.h
@@ -2,35 +2,61 @@
#define FRACTUREGENERALPANEL_H
#include <QtWidgets/QWidget>
+#include "ProjectParams.h"
namespace Ui {
class FractureGeneralPanel;
}
+class FractureVoronoiSettingsPanel;
+class FractureSliceSettingsPanel;
+class FractureVisualizersPanel;
+class ExpandablePanel;
+
class FractureGeneralPanel : public QWidget
{
Q_OBJECT
public:
+ static FractureGeneralPanel* ins();
+
explicit FractureGeneralPanel(QWidget *parent = 0);
~FractureGeneralPanel();
void updateValues();
+ void setFracturePanels(FractureVoronoiSettingsPanel* voronoiPanel, FractureSliceSettingsPanel* slicePanel, FractureVisualizersPanel* visulizersPanel);
+ void setFractureExpandablePanels(ExpandablePanel* voronoiPanel, ExpandablePanel* slicePanel);
+
+ FracturePreset* getCurrentFracturePreset();
private slots:
void on_comboBoxFracturePreset_currentIndexChanged(int index);
- void on_comboBoxFractureType_currentIndexChanged(int index);
+ void on_btnAddPreset_clicked();
- void on_checkBoxAddDepth_stateChanged(int arg1);
+ void on_btnModifyPreset_clicked();
- void on_checkBoxPerChunk_stateChanged(int arg1);
+ void on_btnSavePreset_clicked();
- void on_checkBoxNewMatID_stateChanged(int arg1);
+ void on_comboBoxFractureType_currentIndexChanged(int index);
void on_comboBoxApplyMaterial_currentIndexChanged(int index);
+
+ void on_checkBoxAutoSelectNewChunks_stateChanged(int arg1);
+
+private:
+ FracturePreset* _getFracturePreset(const char* name);
+ void _updateFractureUIs();
+ void _showFracturePanel(const QString& fractireType);
private:
- Ui::FractureGeneralPanel *ui;
+ Ui::FractureGeneralPanel *ui;
+ bool m_bValid;
+ bool _updateData;
+ FractureVoronoiSettingsPanel* _voronoiPanel;
+ FractureSliceSettingsPanel* _slicePanel;
+ FractureVisualizersPanel* _visualizersPanel;
+ ExpandablePanel* _fractureVoronoiSettingsExpandlePanel;
+ ExpandablePanel* _fractureSliceSettingsExpandlePanel;
};
#endif // FRACTUREGENERALPANEL_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureShellCutSettingsPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FractureShellCutSettingsPanel.cpp
deleted file mode 100644
index c08e3ba..0000000
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureShellCutSettingsPanel.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "FractureShellCutSettingsPanel.h"
-#include "ui_FractureShellCutSettingsPanel.h"
-#include "ProjectParams.h"
-
-FractureShellCutSettingsPanel::FractureShellCutSettingsPanel(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::FractureShellCutSettingsPanel)
-{
- ui->setupUi(this);
-}
-
-FractureShellCutSettingsPanel::~FractureShellCutSettingsPanel()
-{
- delete ui;
-}
-
-void FractureShellCutSettingsPanel::updateValues()
-{
- BPPShellCut& shellCut = BlastProject::ins().getParams().fracture.shellCut;
-
- ui->spinBoxThickness->setValue(shellCut.thickness);
- ui->spinBoxThicknessVariation->setValue(shellCut.thicknessVariation);
-}
-
-void FractureShellCutSettingsPanel::on_spinBoxThickness_valueChanged(double arg1)
-{
- BPPShellCut& shellCut = BlastProject::ins().getParams().fracture.shellCut;
- shellCut.thickness = arg1;
-}
-
-void FractureShellCutSettingsPanel::on_spinBoxThicknessVariation_valueChanged(double arg1)
-{
- BPPShellCut& shellCut = BlastProject::ins().getParams().fracture.shellCut;
- shellCut.thicknessVariation = arg1;
-}
-
-void FractureShellCutSettingsPanel::on_btnApplyFracture_clicked()
-{
-
-}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureShellCutSettingsPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FractureShellCutSettingsPanel.h
deleted file mode 100644
index a664adb..0000000
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureShellCutSettingsPanel.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef FRACTURESHELLCUTSETTINGSPANEL_H
-#define FRACTURESHELLCUTSETTINGSPANEL_H
-
-#include <QtWidgets/QWidget>
-
-namespace Ui {
-class FractureShellCutSettingsPanel;
-}
-
-class FractureShellCutSettingsPanel : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit FractureShellCutSettingsPanel(QWidget *parent = 0);
- ~FractureShellCutSettingsPanel();
- void updateValues();
-
-private slots:
-void on_spinBoxThickness_valueChanged(double arg1);
-
- void on_spinBoxThicknessVariation_valueChanged(double arg1);
-
- void on_btnApplyFracture_clicked();
-
-private:
- Ui::FractureShellCutSettingsPanel *ui;
-};
-
-#endif // FRACTURESHELLCUTSETTINGSPANEL_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.cpp
index fa82ee2..103c01c 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.cpp
@@ -1,13 +1,16 @@
#include "FractureSliceSettingsPanel.h"
#include "ui_FractureSliceSettingsPanel.h"
-#include "ProjectParams.h"
#include "SimpleScene.h"
#include "SampleManager.h"
#include <QtWidgets/QMessageBox>
+#include "FractureGeneralPanel.h"
+#include "BlastFamily.h"
FractureSliceSettingsPanel::FractureSliceSettingsPanel(QWidget *parent) :
QWidget(parent),
- ui(new Ui::FractureSliceSettingsPanel)
+ ui(new Ui::FractureSliceSettingsPanel),
+ _updateData(true),
+ _generalPanel(nullptr)
{
ui->setupUi(this);
}
@@ -19,87 +22,177 @@ FractureSliceSettingsPanel::~FractureSliceSettingsPanel()
void FractureSliceSettingsPanel::updateValues()
{
- BPPSlice& slice = BlastProject::ins().getParams().fracture.slice;
-
- ui->spinBoxNumSlices->setValue(slice.numSlices);
- ui->spinBoxOffsetVariation->setValue(slice.offsetVariation);
- ui->spinBoxRotationVariation->setValue(slice.rotationVariation);
- ui->spinBoxNoiseAmplitude->setValue(slice.noiseAmplitude);
- ui->spinBoxNoiseFrequency->setValue(slice.noiseFrequency);
- ui->spinBoxNoiseSeed->setValue(slice.noiseSeed);
+ _updateData = false;
+ BPPSlice* slice = _getBPPSlice();
+
+ ui->spinBoxNumSlicesX->setValue(slice->numSlicesX);
+ ui->spinBoxNumSlicesY->setValue(slice->numSlicesY);
+ ui->spinBoxNumSlicesZ->setValue(slice->numSlicesZ);
+ ui->spinBoxOffsetVariation->setValue(slice->offsetVariation);
+ ui->spinBoxRotationVariation->setValue(slice->rotationVariation);
+ ui->spinBoxNoiseAmplitude->setValue(slice->noiseAmplitude);
+ ui->spinBoxNoiseFrequency->setValue(slice->noiseFrequency);
+ ui->spinBoxNoiseOctaveNumber->setValue(slice->noiseOctaveNumber);
+ ui->spinBoxNoiseSeed->setValue(slice->noiseSeed);
+ ui->spinBoxSurfaceResolution->setValue(slice->surfaceResolution);
+ _updateData = true;
}
-void FractureSliceSettingsPanel::on_spinBoxNumSlices_valueChanged(int arg1)
+void FractureSliceSettingsPanel::on_spinBoxNumSlicesX_valueChanged(int arg1)
{
- BPPSlice& slice = BlastProject::ins().getParams().fracture.slice;
- slice.numSlices = arg1;
+ if (!_updateData)
+ return;
+
+ BPPSlice* slice = _getBPPSlice();
+ slice->numSlicesX = arg1;
+}
+
+void FractureSliceSettingsPanel::on_spinBoxNumSlicesY_valueChanged(int arg1)
+{
+ if (!_updateData)
+ return;
+
+ BPPSlice* slice = _getBPPSlice();
+ slice->numSlicesY = arg1;
+}
+
+void FractureSliceSettingsPanel::on_spinBoxNumSlicesZ_valueChanged(int arg1)
+{
+ if (!_updateData)
+ return;
+
+ BPPSlice* slice = _getBPPSlice();
+ slice->numSlicesZ = arg1;
}
void FractureSliceSettingsPanel::on_spinBoxOffsetVariation_valueChanged(double arg1)
{
- BPPSlice& slice = BlastProject::ins().getParams().fracture.slice;
- slice.offsetVariation = arg1;
+ if (!_updateData)
+ return;
+
+ BPPSlice* slice = _getBPPSlice();
+ slice->offsetVariation = arg1;
}
void FractureSliceSettingsPanel::on_spinBoxRotationVariation_valueChanged(double arg1)
{
- BPPSlice& slice = BlastProject::ins().getParams().fracture.slice;
- slice.rotationVariation = arg1;
+ if (!_updateData)
+ return;
+
+ BPPSlice* slice = _getBPPSlice();
+ slice->rotationVariation = arg1;
}
void FractureSliceSettingsPanel::on_spinBoxNoiseAmplitude_valueChanged(double arg1)
{
- BPPSlice& slice = BlastProject::ins().getParams().fracture.slice;
- slice.noiseAmplitude = arg1;
+ if (!_updateData)
+ return;
+
+ BPPSlice* slice = _getBPPSlice();
+ slice->noiseAmplitude = arg1;
}
void FractureSliceSettingsPanel::on_spinBoxNoiseFrequency_valueChanged(double arg1)
{
- BPPSlice& slice = BlastProject::ins().getParams().fracture.slice;
- slice.noiseFrequency = arg1;
+ if (!_updateData)
+ return;
+
+ BPPSlice* slice = _getBPPSlice();
+ slice->noiseFrequency = arg1;
+}
+
+void FractureSliceSettingsPanel::on_spinBoxNoiseOctaveNumber_valueChanged(int arg1)
+{
+ if (!_updateData)
+ return;
+
+ BPPSlice* slice = _getBPPSlice();
+ slice->noiseOctaveNumber = arg1;
}
void FractureSliceSettingsPanel::on_spinBoxNoiseSeed_valueChanged(int arg1)
{
- BPPSlice& slice = BlastProject::ins().getParams().fracture.slice;
- slice.noiseSeed = arg1;
+ if (!_updateData)
+ return;
+
+ BPPSlice* slice = _getBPPSlice();
+ slice->noiseSeed = arg1;
+}
+
+void FractureSliceSettingsPanel::on_spinBoxSurfaceResolution_valueChanged(int arg1)
+{
+ if (!_updateData)
+ return;
+
+ BPPSlice* slice = _getBPPSlice();
+ slice->surfaceResolution = arg1;
}
void FractureSliceSettingsPanel::on_btnApplyFracture_clicked()
{
- BPPSlice& slice = BlastProject::ins().getParams().fracture.slice;
+ BPPSlice* slice = _getBPPSlice();
SliceFractureExecutor executor;
- executor.applyNoise(slice.noiseAmplitude, slice.noiseAmplitude, 0, 0, 0, slice.noiseSeed);
- executor.applyConfig(slice.numSlices, slice.numSlices, slice.numSlices, slice.offsetVariation, slice.rotationVariation);
+ executor.setBPPSlice(slice);
+
+ SampleManager* pSampleManager = SampleManager::ins();
+ std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = pSampleManager->getAssetFamiliesMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ BPParams& projectParams = BlastProject::ins().getParams();
+ BPPGraphicsMaterialArray& theArray = projectParams.graphicsMaterials;
+ BPPFractureGeneral& fractureGeneral = projectParams.fracture.general;
+ int32_t nMaterialIndex = fractureGeneral.applyMaterial;
+ std::string materialName = "";
+ RenderMaterial* pRenderMaterial = nullptr;
+ if (nMaterialIndex > 0)
+ {
+ BPPGraphicsMaterial& item = theArray.buf[nMaterialIndex - 1];
+ materialName = item.name.buf;
+ pRenderMaterial = pSampleManager->getRenderMaterial(materialName);
+ }
- bool multiplyChunksSelected = false;
std::map<BlastAsset*, std::vector<uint32_t>> selectedChunks = SampleManager::ins()->getSelectedChunks();
std::map<BlastAsset*, std::vector<uint32_t>>::iterator itrAssetSelectedChunks = selectedChunks.begin();
-
- if (selectedChunks.size() > 1)
+ for (; itrAssetSelectedChunks != selectedChunks.end(); itrAssetSelectedChunks++)
{
- multiplyChunksSelected = true;
+ if (itrAssetSelectedChunks->second.size() == 0)
+ {
+ continue;
+ }
+
+ if (pRenderMaterial != nullptr)
+ {
+ BlastAsset* pBlastAsset = itrAssetSelectedChunks->first;
+ std::vector<BlastFamily*> families = AssetFamiliesMap[pBlastAsset];
+ int familySize = families.size();
+ for (int fs = 0; fs < familySize; fs++)
+ {
+ BlastFamily* pBlastFamily = families[fs];
+ pBlastFamily->setMaterial(pRenderMaterial, false);
+
+ AssetList::ModelAsset modelAsset = AssetDescMap[pBlastAsset];
+ int assetID = BlastProject::ins().getAssetIDByName(modelAsset.name.c_str());
+ BPPAssetInstance* instance = BlastProject::ins().getAssetInstance(assetID, fs);
+ copy(instance->inMaterial, materialName.c_str());
+ }
+ }
+
+ executor.setSourceAsset(itrAssetSelectedChunks->first);
+ executor.setTargetChunks(itrAssetSelectedChunks->second);
+ executor.execute();
}
- else if (selectedChunks.size() == 1 && itrAssetSelectedChunks->second.size() > 1)
+}
+
+BPPSlice* FractureSliceSettingsPanel::_getBPPSlice()
+{
+ BPPSlice* slice = nullptr;
+ FracturePreset* preset = _generalPanel->getCurrentFracturePreset();
+ if (nullptr != preset)
{
- multiplyChunksSelected = true;
+ slice = &(preset->fracture.slice);
}
- else if((selectedChunks.size() == 1 && itrAssetSelectedChunks->second.size() == 0) || (selectedChunks.size() == 0))
+ else
{
- return;
+ slice = &(BlastProject::ins().getParams().fracture.slice);
}
-
- if (multiplyChunksSelected)
- {
- QMessageBox::warning(NULL, "Blast Tool", "Now, this tool can only fracture one chunk!");
- return;
- }
-
- executor.setSourceAsset(itrAssetSelectedChunks->first);
- executor.setTargetChunk(itrAssetSelectedChunks->second.at(0));
- executor.execute();
-
- //VoronoiFractureExecutor executor;
- //executor.setTargetChunk(0);
- //executor.execute();
+ return slice;
}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.h
index b85b58f..5b68575 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.h
@@ -2,10 +2,12 @@
#define FRACTURESLICESETTINGSPANEL_H
#include <QtWidgets/QWidget>
+#include "ProjectParams.h"
namespace Ui {
class FractureSliceSettingsPanel;
}
+class FractureGeneralPanel;
class FractureSliceSettingsPanel : public QWidget
{
@@ -15,9 +17,12 @@ public:
explicit FractureSliceSettingsPanel(QWidget *parent = 0);
~FractureSliceSettingsPanel();
void updateValues();
+ void setFractureGeneralPanel(FractureGeneralPanel* generalPanel) { _generalPanel = generalPanel; }
private slots:
- void on_spinBoxNumSlices_valueChanged(int arg1);
+ void on_spinBoxNumSlicesX_valueChanged(int arg1);
+ void on_spinBoxNumSlicesY_valueChanged(int arg1);
+ void on_spinBoxNumSlicesZ_valueChanged(int arg1);
void on_spinBoxOffsetVariation_valueChanged(double arg1);
@@ -27,12 +32,21 @@ private slots:
void on_spinBoxNoiseFrequency_valueChanged(double arg1);
+ void on_spinBoxNoiseOctaveNumber_valueChanged(int arg1);
+
void on_spinBoxNoiseSeed_valueChanged(int arg1);
+ void on_spinBoxSurfaceResolution_valueChanged(int arg1);
+
void on_btnApplyFracture_clicked();
private:
- Ui::FractureSliceSettingsPanel *ui;
+ BPPSlice* _getBPPSlice();
+
+private:
+ Ui::FractureSliceSettingsPanel *ui;
+ bool _updateData;
+ FractureGeneralPanel* _generalPanel;
};
#endif // FRACTURESLICESETTINGSPANEL_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.cpp
index 0f77e27..52d5431 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.cpp
@@ -1,9 +1,12 @@
#include "FractureVisualizersPanel.h"
#include "ui_FractureVisualizersPanel.h"
#include "ProjectParams.h"
+#include "FractureGeneralPanel.h"
+#include "SampleManager.h"
FractureVisualizersPanel::FractureVisualizersPanel(QWidget *parent) :
- QWidget(parent),
+ QWidget(parent),
+ _updateData(true),
ui(new Ui::FractureVisualizersPanel)
{
ui->setupUi(this);
@@ -16,21 +19,57 @@ FractureVisualizersPanel::~FractureVisualizersPanel()
void FractureVisualizersPanel::updateValues()
{
- BPPFractureVisualization& fractureVisualization = BlastProject::ins().getParams().fracture.visualization;
+ _updateData = false;
+/*
+ BPPFractureVisualization* fractureVisualization = _getBPPVisualization();
- ui->checkBoxFracturePreview->setChecked(fractureVisualization.fracturePreview);
- ui->checkBoxDisplayFractureWidget->setChecked(fractureVisualization.displayFractureWidget);
+ ui->checkBoxFracturePreview->setChecked(fractureVisualization->fracturePreview);
+ ui->checkBoxDisplayFractureWidget->setChecked(fractureVisualization->displayFractureWidget);
+*/
+ bool checked = BlastProject::ins().getParams().fracture.general.selectionDepthTest;
+ ui->checkBoxSelectionDepthTest->setChecked(checked);
+ _updateData = true;
}
-
+/*
void FractureVisualizersPanel::on_checkBoxFracturePreview_stateChanged(int arg1)
{
- BPPFractureVisualization& fractureVisualization = BlastProject::ins().getParams().fracture.visualization;
- fractureVisualization.fracturePreview = (arg1 != 0 ? true : false);
+ if (!_updateData)
+ return;
+
+ BPPFractureVisualization* fractureVisualization = _getBPPVisualization();
+ fractureVisualization->fracturePreview = (arg1 != 0 ? true : false);
}
void FractureVisualizersPanel::on_checkBoxDisplayFractureWidget_stateChanged(int arg1)
{
- BPPFractureVisualization& fractureVisualization = BlastProject::ins().getParams().fracture.visualization;
- fractureVisualization.displayFractureWidget = (arg1 != 0 ? true : false);
+ if (!_updateData)
+ return;
+
+ BPPFractureVisualization* fractureVisualization = _getBPPVisualization();
+ fractureVisualization->displayFractureWidget = (arg1 != 0 ? true : false);
+}
+*/
+void FractureVisualizersPanel::on_checkBoxSelectionDepthTest_stateChanged(int arg1)
+{
+ BlastProject::ins().getParams().fracture.general.selectionDepthTest = arg1;
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (nullptr != pSampleManager)
+ {
+ SampleManager::ins()->ApplySelectionDepthTest();
+ }
}
+BPPFractureVisualization* FractureVisualizersPanel::_getBPPVisualization()
+{
+ BPPFractureVisualization* visualization = nullptr;
+ FracturePreset* preset = _generalPanel->getCurrentFracturePreset();
+ if (nullptr != preset)
+ {
+ visualization = &(preset->visualization);
+ }
+ else
+ {
+ visualization = &(BlastProject::ins().getParams().fracture.visualization);
+ }
+ return visualization;
+}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.h
index d542d7f..9d944d1 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.h
@@ -2,10 +2,12 @@
#define FRACTUREVISUALIZERSPANEL_H
#include <QtWidgets/QWidget>
+#include "ProjectParams.h"
namespace Ui {
class FractureVisualizersPanel;
}
+class FractureGeneralPanel;
class FractureVisualizersPanel : public QWidget
{
@@ -15,14 +17,22 @@ public:
explicit FractureVisualizersPanel(QWidget *parent = 0);
~FractureVisualizersPanel();
void updateValues();
+ void setFractureGeneralPanel(FractureGeneralPanel* generalPanel) { _generalPanel = generalPanel; }
private slots:
+/*
void on_checkBoxFracturePreview_stateChanged(int arg1);
void on_checkBoxDisplayFractureWidget_stateChanged(int arg1);
+*/
+ void on_checkBoxSelectionDepthTest_stateChanged(int arg1);
private:
- Ui::FractureVisualizersPanel *ui;
+ BPPFractureVisualization* _getBPPVisualization();
+private:
+ Ui::FractureVisualizersPanel *ui;
+ bool _updateData;
+ FractureGeneralPanel* _generalPanel;
};
#endif // FRACTUREVISUALIZERSPANEL_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.cpp
index 2142f80..7f18b8d 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.cpp
@@ -6,14 +6,16 @@
#include <QtWidgets/QMessageBox>
#include <QtCore/QFileInfo>
#include "AppMainWindow.h"
-#include "ProjectParams.h"
#include "SimpleScene.h"
#include "SampleManager.h"
+#include "FractureGeneralPanel.h"
+#include "BlastFamily.h"
FractureVoronoiSettingsPanel::FractureVoronoiSettingsPanel(QWidget *parent) :
QWidget(parent),
ui(new Ui::FractureVoronoiSettingsPanel),
- _updateData(true)
+ _updateData(true),
+ _generalPanel(nullptr)
{
ui->setupUi(this);
@@ -28,24 +30,16 @@ FractureVoronoiSettingsPanel::~FractureVoronoiSettingsPanel()
void FractureVoronoiSettingsPanel::updateValues()
{
_updateData = false;
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
-
- ui->spinBoxNumberOfSites->setValue(voronoi.numSites);
- ui->comboBoxSiteGeneration->setCurrentIndex(voronoi.siteGeneration);
- ui->spinBoxGridSize->setValue(voronoi.gridSize);
- ui->spinBoxGridScale->setValue(voronoi.gridScale);
- ui->spinBoxAmplitude->setValue(voronoi.amplitude);
- ui->spinBoxFrequency->setValue(voronoi.frequency);
+ BPPVoronoi* voronoi = _getBPPVoronoi();
- _updatePaintMaskComboBox();
+ ui->comboBoxSiteGeneration->setCurrentIndex(voronoi->siteGeneration);
+ _showCurrentSiteGenerationUI();
+ ui->spinBoxNumberOfSites->setValue(voronoi->numSites);
- _updateMeshCutterComboBox();
- ui->checkBoxFractureInsideCutter->setChecked(voronoi.fractureInsideCutter);
- ui->checkBoxFractureOutsideCutter->setChecked(voronoi.fractureOutsideCutter);
+ ui->spinBoxNumberOfClusters->setValue(voronoi->numberOfClusters);
+ ui->spinBoxSitesPerCluster->setValue(voronoi->sitesPerCluster);
+ ui->spinBoxClusterRadius->setValue(voronoi->clusterRadius);
- ui->spinBoxTextureSites->setValue(voronoi.numTextureSites);
-
- _updateTextureListWidget();
_updateData = true;
}
@@ -64,291 +58,133 @@ void FractureVoronoiSettingsPanel::on_checkBoxCutterMesh_stateChanged(int arg1)
}
-void FractureVoronoiSettingsPanel::on_spinBoxNumberOfSites_valueChanged(int arg1)
-{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.numSites = arg1;
-}
-
void FractureVoronoiSettingsPanel::on_comboBoxSiteGeneration_currentIndexChanged(int index)
{
if (!_updateData)
return;
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.siteGeneration = index;
-}
-
-void FractureVoronoiSettingsPanel::on_spinBoxGridSize_valueChanged(int arg1)
-{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.gridSize = arg1;
-}
-
-void FractureVoronoiSettingsPanel::on_spinBoxGridScale_valueChanged(double arg1)
-{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.gridScale = arg1;
-}
-
-void FractureVoronoiSettingsPanel::on_spinBoxAmplitude_valueChanged(double arg1)
-{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.amplitude = arg1;
+ BPPVoronoi* voronoi = _getBPPVoronoi();
+ voronoi->siteGeneration = index;
+ _showCurrentSiteGenerationUI();
}
-void FractureVoronoiSettingsPanel::on_spinBoxFrequency_valueChanged(int arg1)
-{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.frequency = arg1;
-}
-
-void FractureVoronoiSettingsPanel::on_comboBoxPaintMasks_currentIndexChanged(int index)
+void FractureVoronoiSettingsPanel::on_spinBoxNumberOfSites_valueChanged(int arg1)
{
if (!_updateData)
return;
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.activePaintMask = index;
-}
-
-void FractureVoronoiSettingsPanel::on_btnAddPaintMasks_clicked()
-{
- bool ok = false;
- QString name = QInputDialog::getText(this,
- tr("Blast Tool"),
- tr("Please input name for new paint mask:"),
- QLineEdit::Normal,
- "",
- &ok);
- bool nameExist = BlastProject::ins().isPaintMaskNameExist(name.toUtf8().data());
- if (ok && !name.isEmpty() && !nameExist)
- {
- BlastProject::ins().addPaintMasks(name.toUtf8().data());
- _updatePaintMaskComboBox();
- ui->comboBoxPaintMasks->setCurrentIndex(ui->comboBoxPaintMasks->count() - 1);
- }
- else if (ok && nameExist)
- {
- QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!");
- }
- else if (ok && name.isEmpty())
- {
- QMessageBox::warning(this, "Blast Tool", "You need input a name for the new paint mask!");
- }
-}
-
-void FractureVoronoiSettingsPanel::on_btnRemovePaintMasks_clicked()
-{
- if (ui->comboBoxPaintMasks->currentIndex() > -1)
- {
- BlastProject::ins().removePaintMasks(ui->comboBoxPaintMasks->currentText().toUtf8().data());
- _updatePaintMaskComboBox();
- }
+ BPPVoronoi* voronoi = _getBPPVoronoi();
+ voronoi->numSites = arg1;
}
-void FractureVoronoiSettingsPanel::on_comboBoxMeshCutter_currentIndexChanged(int index)
+void FractureVoronoiSettingsPanel::on_spinBoxNumberOfClusters_valueChanged(int arg1)
{
if (!_updateData)
return;
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.activeMeshCutter = index;
-}
-
-void FractureVoronoiSettingsPanel::on_btnAddMeshCutter_clicked()
-{
- bool ok = false;
- QString name = QInputDialog::getText(this,
- tr("Blast Tool"),
- tr("Please input name for new mesh cutter:"),
- QLineEdit::Normal,
- "",
- &ok);
- bool nameExist = BlastProject::ins().isMeshCutterNameExist(name.toUtf8().data());
- if (ok && !name.isEmpty() && !nameExist)
- {
- BlastProject::ins().addMeshCutter(name.toUtf8().data());
- _updateMeshCutterComboBox();
- ui->comboBoxMeshCutter->setCurrentIndex(ui->comboBoxMeshCutter->count() - 1);
- }
- else if (ok && nameExist)
- {
- QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!");
- }
- else if (ok && name.isEmpty())
- {
- QMessageBox::warning(this, "Blast Tool", "You need input a name for the new cutter mesh!");
- }
-}
-
-void FractureVoronoiSettingsPanel::on_btnRemoveMeshCutter_clicked()
-{
- if (ui->comboBoxMeshCutter->currentIndex() > -1)
- {
- BlastProject::ins().removeMeshCutter(ui->comboBoxMeshCutter->currentText().toUtf8().data());
- _updateMeshCutterComboBox();
- }
-}
-
-void FractureVoronoiSettingsPanel::on_checkBoxFractureInsideCutter_stateChanged(int arg1)
-{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.fractureInsideCutter = (arg1 != 0 ? true : false);
+ BPPVoronoi* voronoi = _getBPPVoronoi();
+ voronoi->numberOfClusters = arg1;
}
-void FractureVoronoiSettingsPanel::on_checkBoxFractureOutsideCutter_stateChanged(int arg1)
+void FractureVoronoiSettingsPanel::on_spinBoxSitesPerCluster_valueChanged(int arg1)
{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.fractureOutsideCutter = (arg1 != 0 ? true : false);
-}
-
-void FractureVoronoiSettingsPanel::on_btnAddTexture_clicked()
-{
- QString texName = AppMainWindow::Inst().OpenTextureFile();
-
- if (texName.isEmpty())
+ if (!_updateData)
return;
- QFileInfo fileInfo(texName);
- QByteArray ba = fileInfo.absoluteFilePath().toLocal8Bit();
- const char* filePath = (const char*)(ba);
-
- if (!BlastProject::ins().isVoronoiTextureNameExist(texName.toUtf8().data()))
- {
- BlastProject::ins().addVoronoiTexture(filePath);
- _updateTextureListWidget();
- ui->listWidgetTexture->setCurrentRow(ui->listWidgetTexture->count() - 1);
- }
- else
- {
- QMessageBox::warning(this, "Blast Tool", "The texture you selected is already exist!");
- }
-}
-
-void FractureVoronoiSettingsPanel::on_btnReloadTexture_clicked()
-{
-
-}
-
-void FractureVoronoiSettingsPanel::on_btnRemoveTexture_clicked()
-{
- if (ui->listWidgetTexture->currentRow() != -1)
- {
- QListWidgetItem *item = ui->listWidgetTexture->currentItem();
- QString texture = _getTexturePathByName(item->text());
- QByteArray ba = texture.toLocal8Bit();
- BlastProject::ins().removeVoronoiTexture(ba.data());
- _updateTextureListWidget();
- }
-}
-
-void FractureVoronoiSettingsPanel::on_spinBoxTextureSites_valueChanged(int arg1)
-{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- voronoi.numTextureSites = arg1;
-}
-
-void FractureVoronoiSettingsPanel::on_listWidgetTexture_itemSelectionChanged()
-{
-
+ BPPVoronoi* voronoi = _getBPPVoronoi();
+ voronoi->sitesPerCluster = arg1;
}
-void FractureVoronoiSettingsPanel::on_btnTextureMap_clicked()
+void FractureVoronoiSettingsPanel::on_spinBoxClusterRadius_valueChanged(double arg1)
{
+ if (!_updateData)
+ return;
+ BPPVoronoi* voronoi = _getBPPVoronoi();
+ voronoi->clusterRadius = arg1;
}
void FractureVoronoiSettingsPanel::on_btnApplyFracture_clicked()
{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
+ BPPVoronoi* voronoi = _getBPPVoronoi();
VoronoiFractureExecutor executor;
- executor.setCellsCount(voronoi.numSites);
+ executor.setBPPVoronoi(voronoi);
- bool multiplyChunksSelected = false;
- std::map<BlastAsset*, std::vector<uint32_t>> selectedChunks = SampleManager::ins()->getSelectedChunks();
- std::map<BlastAsset*, std::vector<uint32_t>>::iterator itrAssetSelectedChunks = selectedChunks.begin();
-
- if (selectedChunks.size() > 1)
- {
- multiplyChunksSelected = true;
- }
- else if (selectedChunks.size() == 1 && itrAssetSelectedChunks->second.size() > 1)
+ SampleManager* pSampleManager = SampleManager::ins();
+ std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = pSampleManager->getAssetFamiliesMap();
+ std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap();
+ BPParams& projectParams = BlastProject::ins().getParams();
+ BPPGraphicsMaterialArray& theArray = projectParams.graphicsMaterials;
+ BPPFractureGeneral& fractureGeneral = projectParams.fracture.general;
+ int32_t nMaterialIndex = fractureGeneral.applyMaterial;
+ std::string materialName = "";
+ RenderMaterial* pRenderMaterial = nullptr;
+ if (nMaterialIndex > 0)
{
- multiplyChunksSelected = true;
- }
- else if ((selectedChunks.size() == 1 && itrAssetSelectedChunks->second.size() == 0) || (selectedChunks.size() == 0))
- {
- return;
+ BPPGraphicsMaterial& item = theArray.buf[nMaterialIndex - 1];
+ materialName = item.name.buf;
+ pRenderMaterial = pSampleManager->getRenderMaterial(materialName);
}
- if (multiplyChunksSelected)
+ std::map<BlastAsset*, std::vector<uint32_t>> selectedChunks = SampleManager::ins()->getSelectedChunks();
+ std::map<BlastAsset*, std::vector<uint32_t>>::iterator itrAssetSelectedChunks = selectedChunks.begin();
+ for (; itrAssetSelectedChunks != selectedChunks.end(); itrAssetSelectedChunks++)
{
- QMessageBox::warning(NULL, "Blast Tool", "Now, this tool can only fracture one chunk!");
- return;
- }
+ if (itrAssetSelectedChunks->second.size() == 0)
+ {
+ continue;
+ }
- executor.setSourceAsset(itrAssetSelectedChunks->first);
- executor.setTargetChunk(itrAssetSelectedChunks->second.at(0));
- executor.execute();
-}
+ if (pRenderMaterial != nullptr)
+ {
+ BlastAsset* pBlastAsset = itrAssetSelectedChunks->first;
+ std::vector<BlastFamily*> families = AssetFamiliesMap[pBlastAsset];
+ int familySize = families.size();
+ for (int fs = 0; fs < familySize; fs++)
+ {
+ BlastFamily* pBlastFamily = families[fs];
+ pBlastFamily->setMaterial(pRenderMaterial, false);
-QString FractureVoronoiSettingsPanel::_getTexturePathByName(const QString& name)
-{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
- BPPStringArray& textureArray = voronoi.textureSites;
+ AssetList::ModelAsset modelAsset = AssetDescMap[pBlastAsset];
+ int assetID = BlastProject::ins().getAssetIDByName(modelAsset.name.c_str());
+ BPPAssetInstance* instance = BlastProject::ins().getAssetInstance(assetID, fs);
+ copy(instance->inMaterial, materialName.c_str());
+ }
+ }
- int count = textureArray.arraySizes[0];
- for (int i = 0; i < count; ++i)
- {
- QFileInfo fileInfo(textureArray.buf[i].buf);
- if (fileInfo.baseName() == name)
- return textureArray.buf[i].buf;
+ executor.setSourceAsset(itrAssetSelectedChunks->first);
+ executor.setTargetChunks(itrAssetSelectedChunks->second);
+ executor.execute();
}
-
- return "";
}
-void FractureVoronoiSettingsPanel::_updatePaintMaskComboBox()
+BPPVoronoi* FractureVoronoiSettingsPanel::_getBPPVoronoi()
{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
-
- ui->comboBoxPaintMasks->clear();
- QStringList items;
- for (int i = 0; i < voronoi.paintMasks.arraySizes[0]; ++i)
+ BPPVoronoi* voronoi = nullptr;
+ FracturePreset* preset = _generalPanel->getCurrentFracturePreset();
+ if (nullptr != preset)
{
- items.append(voronoi.paintMasks.buf[i].buf);
+ voronoi = &(preset->fracture.voronoi);
}
- ui->comboBoxPaintMasks->addItems(items);
- ui->comboBoxPaintMasks->setCurrentIndex(voronoi.activePaintMask);
-}
-
-void FractureVoronoiSettingsPanel::_updateMeshCutterComboBox()
-{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
-
- ui->comboBoxMeshCutter->clear();
- QStringList items;
- for (int i = 0; i < voronoi.meshCutters.arraySizes[0]; ++i)
+ else
{
- items.append(voronoi.meshCutters.buf[i].buf);
+ voronoi = &(BlastProject::ins().getParams().fracture.voronoi);
}
- ui->comboBoxMeshCutter->addItems(items);
- ui->comboBoxMeshCutter->setCurrentIndex(voronoi.activeMeshCutter);
+ return voronoi;
}
-void FractureVoronoiSettingsPanel::_updateTextureListWidget()
+void FractureVoronoiSettingsPanel::_showCurrentSiteGenerationUI()
{
- BPPVoronoi& voronoi = BlastProject::ins().getParams().fracture.voronoi;
-
- ui->listWidgetTexture->clear();
- QStringList items;
- for (int i = 0; i < voronoi.textureSites.arraySizes[0]; ++i)
+ ui->widgetUniform->hide();
+ ui->widgetClusters->hide();
+ BPPVoronoi* voronoi = _getBPPVoronoi();
+ switch(voronoi->siteGeneration)
{
- QFileInfo fileInfo(voronoi.textureSites.buf[i].buf);
- QByteArray ba = fileInfo.baseName().toLocal8Bit();
- const char* texture = (const char*)(ba);
- items.append(texture);
+ case 0:
+ ui->widgetUniform->show();
+ break;
+ case 1:
+ ui->widgetClusters->show();
+ break;
}
- ui->listWidgetTexture->addItems(items);
}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.h
index 6a0668d..0f9b252 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.h
@@ -2,10 +2,12 @@
#define FRACTUREVORONOISETTINGSPANEL_H
#include <QtWidgets/QWidget>
+#include "ProjectParams.h"
namespace Ui {
class FractureVoronoiSettingsPanel;
}
+class FractureGeneralPanel;
class FractureVoronoiSettingsPanel : public QWidget
{
@@ -15,6 +17,7 @@ public:
explicit FractureVoronoiSettingsPanel(QWidget *parent = 0);
~FractureVoronoiSettingsPanel();
void updateValues();
+ void setFractureGeneralPanel(FractureGeneralPanel* generalPanel) { _generalPanel = generalPanel; }
private slots:
void on_checkBoxGridPreview_stateChanged(int arg1);
@@ -23,57 +26,26 @@ private slots:
void on_checkBoxCutterMesh_stateChanged(int arg1);
- void on_spinBoxNumberOfSites_valueChanged(int arg1);
-
- void on_comboBoxSiteGeneration_currentIndexChanged(int index);
-
- void on_spinBoxGridSize_valueChanged(int arg1);
-
- void on_spinBoxGridScale_valueChanged(double arg1);
-
- void on_spinBoxAmplitude_valueChanged(double arg1);
-
- void on_spinBoxFrequency_valueChanged(int arg1);
-
- void on_comboBoxPaintMasks_currentIndexChanged(int index);
-
- void on_btnAddPaintMasks_clicked();
-
- void on_btnRemovePaintMasks_clicked();
+ void on_comboBoxSiteGeneration_currentIndexChanged(int index);
- void on_comboBoxMeshCutter_currentIndexChanged(int index);
-
- void on_btnAddMeshCutter_clicked();
-
- void on_btnRemoveMeshCutter_clicked();
-
- void on_checkBoxFractureInsideCutter_stateChanged(int arg1);
-
- void on_checkBoxFractureOutsideCutter_stateChanged(int arg1);
-
- void on_btnAddTexture_clicked();
-
- void on_btnReloadTexture_clicked();
-
- void on_btnRemoveTexture_clicked();
+ void on_spinBoxNumberOfSites_valueChanged(int arg1);
- void on_spinBoxTextureSites_valueChanged(int arg1);
+ void on_spinBoxNumberOfClusters_valueChanged(int arg1);
- void on_listWidgetTexture_itemSelectionChanged();
+ void on_spinBoxSitesPerCluster_valueChanged(int arg1);
- void on_btnTextureMap_clicked();
+ void on_spinBoxClusterRadius_valueChanged(double arg1);
void on_btnApplyFracture_clicked();
private:
- QString _getTexturePathByName(const QString& name);
- void _updatePaintMaskComboBox();
- void _updateMeshCutterComboBox();
- void _updateTextureListWidget();
+ BPPVoronoi* _getBPPVoronoi();
+ void _showCurrentSiteGenerationUI();
private:
Ui::FractureVoronoiSettingsPanel *ui;
bool _updateData;
+ FractureGeneralPanel* _generalPanel;
};
#endif // FRACTUREVORONOISETTINGSPANEL_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.cpp
index 88915f1..aa6af69 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.cpp
@@ -3,10 +3,12 @@
#include <QtWidgets/QInputDialog>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QMessageBox>
+#include "SampleManager.h"
GeneralPanel::GeneralPanel(QWidget *parent) :
QWidget(parent),
- ui(new Ui::GeneralPanel)
+ ui(new Ui::GeneralPanel),
+ _updateData(true)
{
ui->setupUi(this);
}
@@ -18,48 +20,71 @@ GeneralPanel::~GeneralPanel()
void GeneralPanel::updateValues()
{
- std::vector<StressSolverUserPreset> presets = BlastProject::ins().getUserPresets();
+ _updateData = false;
ui->comboBoxUserPreset->clear();
+ QStringList userPresets;
+ userPresets.append("Default");
+ std::vector<StressSolverUserPreset> presets = BlastProject::ins().getUserPresets();
int countUserPresets = (int)presets.size();
if (countUserPresets > 0)
{
- QStringList userPresets;
for (int i = 0; i < countUserPresets; ++i)
{
userPresets.append(presets[i].name.c_str());
}
- ui->comboBoxUserPreset->addItems(userPresets);
}
+ ui->comboBoxUserPreset->addItems(userPresets);
- std::vector<BPPAsset*> selectedAssets = BlastProject::ins().getSelectedBlastAssets();
- if (selectedAssets.size() > 0)
+ if (_selectedAssets.size() > 0)
{
- ui->comboBoxUserPreset->setCurrentText(selectedAssets[0]->activePreset.buf);
+ if (nullptr == _selectedAssets[0]->activeUserPreset.buf
+ || 0 == strlen(_selectedAssets[0]->activeUserPreset.buf)
+ || !BlastProject::ins().isUserPresetNameExist(_selectedAssets[0]->activeUserPreset.buf))
+ {
+ ui->comboBoxUserPreset->setCurrentIndex(0);
+ }
+ else
+ {
+ ui->comboBoxUserPreset->setCurrentText(_selectedAssets[0]->activeUserPreset.buf);
+ }
_updateStressSolverUIs();
}
else
{
- ui->comboBoxUserPreset->setCurrentIndex(-1);
+ ui->comboBoxUserPreset->setCurrentIndex(0);
+ }
+ _updateData = true;
+}
+
+void GeneralPanel::dataSelected(std::vector<BlastNode*> selections)
+{
+ _selectedAssets.clear();
+ for (BlastNode* node : selections)
+ {
+ if (eAsset == node->getType())
+ {
+ BPPAsset* asset = static_cast<BPPAsset*>(node->getData());
+ _selectedAssets.push_back(asset);
+ }
}
+
+ updateValues();
}
void GeneralPanel::on_comboBoxUserPreset_currentIndexChanged(int index)
{
- std::vector<BPPAsset*> assets = BlastProject::ins().getSelectedBlastAssets();
- for (size_t i = 0; i < assets.size(); ++i)
+ if (!_updateData)
+ return;
+
+ for (size_t i = 0; i < _selectedAssets.size(); ++i)
{
QByteArray tem = ui->comboBoxUserPreset->currentText().toUtf8();
- copy(assets[i]->activePreset, tem.data());
-
- BPPStressSolver* preset = _getUserPreset(tem.data());
- if (preset)
- {
- copy(assets[i]->stressSolver, *preset);
- }
+ copy(_selectedAssets[i]->activeUserPreset, tem.data());
}
_updateStressSolverUIs();
+ _updateStressSolverToBlast();
}
void GeneralPanel::on_btnAddUserPreset_clicked()
@@ -90,7 +115,7 @@ void GeneralPanel::on_btnAddUserPreset_clicked()
void GeneralPanel::on_btnModifyUserPreset_clicked()
{
- if (ui->comboBoxUserPreset->currentIndex() == -1)
+ if (ui->comboBoxUserPreset->currentIndex() < 1)
{
QMessageBox::warning(this, "Blast Tool", "You should select an user preset!");
return;
@@ -109,12 +134,14 @@ void GeneralPanel::on_btnModifyUserPreset_clicked()
bool nameExist = BlastProject::ins().isUserPresetNameExist(newName.toUtf8().data());
if (ok && !newName.isEmpty() && !nameExist)
{
- int curIndex = ui->comboBoxUserPreset->currentIndex();
-
- std::vector<StressSolverUserPreset>& presets = BlastProject::ins().getUserPresets();
- presets[curIndex].name = newName.toUtf8().data();
- updateValues();
- ui->comboBoxUserPreset->setCurrentIndex(curIndex);
+ int curIndex = ui->comboBoxUserPreset->currentIndex() - 1;
+ if (curIndex >= 0)
+ {
+ std::vector<StressSolverUserPreset>& presets = BlastProject::ins().getUserPresets();
+ presets[curIndex].name = newName.toUtf8().data();
+ updateValues();
+ ui->comboBoxUserPreset->setCurrentIndex(curIndex + 1);
+ }
}
else if (ok && nameExist)
{
@@ -122,130 +149,133 @@ void GeneralPanel::on_btnModifyUserPreset_clicked()
}
else if (ok && newName.isEmpty())
{
- QMessageBox::warning(this, "Blast Tool", "You need input a name for the selected graphics material!");
+ QMessageBox::warning(this, "Blast Tool", "You need input a name for the selected preset!");
}
}
void GeneralPanel::on_btnSaveUserPreset_clicked()
{
- int currentUserPreset = ui->comboBoxUserPreset->currentIndex();
- if (-1 != currentUserPreset)
- {
- std::vector<StressSolverUserPreset>& presets = BlastProject::ins().getUserPresets();
- BPPStressSolver& stressSolver = presets[currentUserPreset].stressSolver;
- stressSolver.solverMode = ui->comboBoxSolverMode->currentIndex();
- stressSolver.linearFactor = ui->spinBoxLinearFactor->value();
- stressSolver.angularFactor = ui->spinBoxAngularFactor->value();
- stressSolver.meanError = ui->spinBoxMeanError->value();
- stressSolver.varianceError = ui->spinBoxVarianceError->value();
- stressSolver.bondsPerFrame = ui->spinBoxBondsPerFrame->value();
- stressSolver.bondsIterations = ui->spinBoxBondsIterations->value();
- }
-
BlastProject::ins().saveUserPreset();
}
-void GeneralPanel::on_comboBoxSolverMode_currentIndexChanged(int index)
+void GeneralPanel::on_spinBoxMaterialHardness_valueChanged(double arg1)
{
- BPPStressSolver* stressSolver = _getCurrentStressSolver();
+ if (!_updateData)
+ return;
+
+ BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver();
if (stressSolver)
{
- stressSolver->solverMode = index;
+ stressSolver->hardness = arg1;
+ }
+ else
+ {
+ for (BPPAsset* asset : _selectedAssets)
+ {
+ asset->stressSolver.hardness = arg1;
+ }
}
+
+ _updateStressSolverToBlast();
}
void GeneralPanel::on_spinBoxLinearFactor_valueChanged(double arg1)
{
- BPPStressSolver* stressSolver = _getCurrentStressSolver();
+ if (!_updateData)
+ return;
+
+ BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver();
if (stressSolver)
{
stressSolver->linearFactor = arg1;
}
-
+ else
+ {
+ for (BPPAsset* asset : _selectedAssets)
+ {
+ asset->stressSolver.linearFactor = arg1;
+ }
+ }
+
+ _updateStressSolverToBlast();
}
void GeneralPanel::on_spinBoxAngularFactor_valueChanged(double arg1)
{
- BPPStressSolver* stressSolver = _getCurrentStressSolver();
+ if (!_updateData)
+ return;
+
+ BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver();
if (stressSolver)
{
stressSolver->angularFactor = arg1;
}
-}
-
-void GeneralPanel::on_spinBoxMeanError_valueChanged(double arg1)
-{
- BPPStressSolver* stressSolver = _getCurrentStressSolver();
-
- if (stressSolver)
+ else
{
- stressSolver->meanError = arg1;
+ for (BPPAsset* asset : _selectedAssets)
+ {
+ asset->stressSolver.angularFactor = arg1;
+ }
}
-}
-void GeneralPanel::on_spinBoxVarianceError_valueChanged(double arg1)
-{
- BPPStressSolver* stressSolver = _getCurrentStressSolver();
-
- if (stressSolver)
- {
- stressSolver->varianceError = arg1;
- }
+ _updateStressSolverToBlast();
}
-void GeneralPanel::on_spinBoxBondsPerFrame_valueChanged(int arg1)
+void GeneralPanel::on_spinBoxBondIterations_valueChanged(int arg1)
{
- BPPStressSolver* stressSolver = _getCurrentStressSolver();
+ if (!_updateData)
+ return;
+
+ BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver();
if (stressSolver)
{
- stressSolver->bondsPerFrame = arg1;
+ stressSolver->bondIterationsPerFrame = arg1;
}
-}
-
-void GeneralPanel::on_spinBoxBondsIterations_valueChanged(int arg1)
-{
- BPPStressSolver* stressSolver = _getCurrentStressSolver();
-
- if (stressSolver)
+ else
{
- stressSolver->bondsIterations = arg1;
+ for (BPPAsset* asset : _selectedAssets)
+ {
+ asset->stressSolver.bondIterationsPerFrame = arg1;
+ }
}
+
+ _updateStressSolverToBlast();
}
-BPPStressSolver* GeneralPanel::_getCurrentStressSolver()
+void GeneralPanel::on_spinBoxGraphReductionLevel_valueChanged(int arg1)
{
- int currentUserPreset = ui->comboBoxUserPreset->currentIndex();
+ if (!_updateData)
+ return;
- if (-1 != currentUserPreset)
+ BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver();
+
+ if (stressSolver)
{
- std::vector<StressSolverUserPreset>& presets = BlastProject::ins().getUserPresets();
- return &(presets[currentUserPreset].stressSolver);
+ stressSolver->graphReductionLevel = arg1;
}
else
{
- std::vector<BPPAsset*> assets = BlastProject::ins().getSelectedBlastAssets();
-
- if (assets.size() > 0)
+ for (BPPAsset* asset : _selectedAssets)
{
- return &(assets[0]->stressSolver);
+ asset->stressSolver.graphReductionLevel = arg1;
}
}
- return nullptr;
+ _updateStressSolverToBlast();
}
-BPPStressSolver* GeneralPanel::_getUserPreset(const char* name)
+BPPStressSolver* GeneralPanel::_getCurrentUserPresetStressSolver()
{
- std::vector<StressSolverUserPreset>& presets = BlastProject::ins().getUserPresets();
+ int currentUserPreset = ui->comboBoxUserPreset->currentIndex();
- for (size_t i = 0; i < presets.size(); ++i)
+ if (0 < currentUserPreset)
{
- if (presets[i].name == name)
- return &(presets[i].stressSolver);
+ std::vector<StressSolverUserPreset>& presets = BlastProject::ins().getUserPresets();
+ return &(presets[currentUserPreset - 1].stressSolver);
}
return nullptr;
@@ -253,29 +283,33 @@ BPPStressSolver* GeneralPanel::_getUserPreset(const char* name)
void GeneralPanel::_updateStressSolverUIs()
{
- BPPStressSolver* stressSolver = _getCurrentStressSolver();
- if (stressSolver != nullptr)
+ BPPStressSolver noStressSolver;
+ init(noStressSolver);
+ BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver();
+ if (stressSolver == nullptr)
{
- ui->comboBoxSolverMode->setCurrentIndex(stressSolver->solverMode);
- ui->spinBoxLinearFactor->setValue(stressSolver->linearFactor);
- ui->spinBoxAngularFactor->setValue(stressSolver->angularFactor);
- ui->spinBoxMeanError->setValue(stressSolver->meanError);
- ui->spinBoxVarianceError->setValue(stressSolver->varianceError);
- ui->spinBoxBondsPerFrame->setValue(stressSolver->bondsPerFrame);
- ui->spinBoxBondsIterations->setValue(stressSolver->bondsIterations);
+ if (0 < _selectedAssets.size())
+ {
+ copy(noStressSolver, _selectedAssets[0]->stressSolver);
+ }
+ stressSolver = &noStressSolver;
}
- else
+
+ _updateData = false;
+ ui->spinBoxMaterialHardness->setValue(stressSolver->hardness);
+ ui->spinBoxLinearFactor->setValue(stressSolver->linearFactor);
+ ui->spinBoxAngularFactor->setValue(stressSolver->angularFactor);
+ ui->spinBoxBondIterations->setValue(stressSolver->bondIterationsPerFrame);
+ ui->spinBoxGraphReductionLevel->setValue(stressSolver->graphReductionLevel);
+ _updateData = true;
+}
+
+void GeneralPanel::_updateStressSolverToBlast()
+{
+ BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver();
+
+ for (BPPAsset* asset : _selectedAssets)
{
- BPPStressSolver noStressSolver;
- init(noStressSolver);
-
- ui->comboBoxSolverMode->setCurrentIndex(noStressSolver.solverMode);
- ui->spinBoxLinearFactor->setValue(noStressSolver.linearFactor);
- ui->spinBoxAngularFactor->setValue(noStressSolver.angularFactor);
- ui->spinBoxMeanError->setValue(noStressSolver.meanError);
- ui->spinBoxVarianceError->setValue(noStressSolver.varianceError);
- ui->spinBoxBondsPerFrame->setValue(noStressSolver.bondsPerFrame);
- ui->spinBoxBondsIterations->setValue(noStressSolver.bondsIterations);
+ SampleManager::ins()->updateAssetFamilyStressSolver(asset, nullptr != stressSolver? *stressSolver : asset->stressSolver);
}
-
}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.h
index a7a52e3..9651185 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.h
@@ -3,12 +3,13 @@
#include <QtWidgets/QWidget>
#include "ProjectParams.h"
+#include "BlastSceneTree.h"
namespace Ui {
class GeneralPanel;
}
-class GeneralPanel : public QWidget
+class GeneralPanel : public QWidget, public ISceneObserver
{
Q_OBJECT
@@ -17,6 +18,8 @@ public:
~GeneralPanel();
void updateValues();
+ virtual void dataSelected(std::vector<BlastNode*> selections);
+
private slots:
void on_comboBoxUserPreset_currentIndexChanged(int index);
@@ -26,27 +29,25 @@ private slots:
void on_btnSaveUserPreset_clicked();
- void on_comboBoxSolverMode_currentIndexChanged(int index);
+ void on_spinBoxMaterialHardness_valueChanged(double arg1);
void on_spinBoxLinearFactor_valueChanged(double arg1);
void on_spinBoxAngularFactor_valueChanged(double arg1);
- void on_spinBoxMeanError_valueChanged(double arg1);
-
- void on_spinBoxVarianceError_valueChanged(double arg1);
-
- void on_spinBoxBondsPerFrame_valueChanged(int arg1);
+ void on_spinBoxBondIterations_valueChanged(int arg1);
- void on_spinBoxBondsIterations_valueChanged(int arg1);
+ void on_spinBoxGraphReductionLevel_valueChanged(int arg1);
private:
- BPPStressSolver* _getCurrentStressSolver();
- BPPStressSolver* _getUserPreset(const char* name);
+ BPPStressSolver* _getCurrentUserPresetStressSolver();
void _updateStressSolverUIs();
+ void _updateStressSolverToBlast();
private:
- Ui::GeneralPanel *ui;
+ Ui::GeneralPanel *ui;
+ bool _updateData;
+ std::vector<BPPAsset*> _selectedAssets;
};
#endif // GENERALPANEL_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.cpp
index 6095f67..0ecfaf0 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.cpp
@@ -1,9 +1,9 @@
#include "MaterialAssignmentsPanel.h"
#include "ui_MaterialAssignmentsPanel.h"
#include "ProjectParams.h"
-#include "RenderMaterial.h"
#include "SampleManager.h"
#include "MaterialLibraryPanel.h"
+#include <assert.h>
MaterialAssignmentsPanel* pMaterialAssignmentsPanel = nullptr;
MaterialAssignmentsPanel* MaterialAssignmentsPanel::ins()
@@ -37,7 +37,11 @@ void MaterialAssignmentsPanel::getMaterialNameAndPaths(std::vector<std::string>&
{
BPPGraphicsMaterial& item = theArray.buf[i];
std::string name = item.name.buf;
- std::string path = item.diffuseTextureFilePath.buf;
+ std::string path = "";
+ if (item.diffuseTextureFilePath.buf != nullptr)
+ {
+ path = item.diffuseTextureFilePath.buf;
+ }
if (name1 == name)
{
path1 = path;
@@ -52,10 +56,23 @@ void MaterialAssignmentsPanel::getMaterialNameAndPaths(std::vector<std::string>&
}
}
- materialNames.push_back(name1);
- materialNames.push_back(name2);
- materialPaths.push_back(path1);
- materialPaths.push_back(path2);
+ materialNames[0] = name1;
+ materialPaths[0] = path1;
+
+ BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general;
+ int32_t nMaterialIndex = fractureGeneral.applyMaterial;
+ assert(theArray.buf != nullptr);
+ if (nMaterialIndex > 0 && theArray.buf)
+ {
+ BPPGraphicsMaterial& item = theArray.buf[nMaterialIndex - 1];
+ name2 = item.name.buf;
+ if (item.diffuseTextureFilePath.buf)
+ {
+ path2 = item.diffuseTextureFilePath.buf;
+ }
+ }
+ materialNames[1] = name2;
+ materialPaths[1] = path2;
}
MaterialAssignmentsPanel::~MaterialAssignmentsPanel()
@@ -68,8 +85,27 @@ void MaterialAssignmentsPanel::updateValues()
m_bValid = false;
ui->comboBoxMaterialID1->clear();
ui->comboBoxMaterialID2->clear();
+ ui->comboBoxMaterialID1->setEnabled(false);
+ ui->comboBoxMaterialID2->setEnabled(false);
m_bValid = true;
+ SampleManager* pSampleManager = SampleManager::ins();
+ if (pSampleManager == nullptr)
+ {
+ return;
+ }
+
+ BlastAsset* pBlastAsset = nullptr;
+ int index = -1;
+ pSampleManager->getCurrentSelectedInstance(&pBlastAsset, index);
+ if (pBlastAsset == nullptr || index == -1)
+ {
+ return;
+ }
+
+ ui->comboBoxMaterialID1->setEnabled(true);
+ ui->comboBoxMaterialID2->setEnabled(true);
+
QStringList materialNames;
materialNames.append("None");
BPParams& projectParams = BlastProject::ins().getParams();
@@ -85,35 +121,12 @@ void MaterialAssignmentsPanel::updateValues()
ui->comboBoxMaterialID1->insertItems(0, materialNames);
ui->comboBoxMaterialID2->insertItems(0, materialNames);
m_bValid = true;
-
- SampleManager* pSampleManager = SampleManager::ins();
- if (pSampleManager == nullptr)
- {
- return;
- }
-
- BlastAsset* pBlastAsset = nullptr;
- int index = -1;
- pSampleManager->getCurrentSelectedInstance(&pBlastAsset, index);
- if (pBlastAsset == nullptr || index == -1)
- {
- return;
- }
- RenderMaterial* pRenderMaterial[] = { nullptr, nullptr };
- std::string strMaterialNames[] = { "None", "None" };
+ std::string strMaterialNames[] = { "", "" };
bool ex[] = { true, false };
for (int i = 0; i < 2; i++)
{
- pSampleManager->getMaterialForCurrentFamily(&pRenderMaterial[i], ex[i]);
- if (pRenderMaterial[i] != nullptr)
- {
- std::string m = pRenderMaterial[i]->getMaterialName();
- if (m != "")
- {
- strMaterialNames[i] = m;
- }
- }
+ pSampleManager->getMaterialForCurrentFamily(strMaterialNames[i], ex[i]);
}
m_bValid = false;
@@ -129,33 +142,31 @@ void MaterialAssignmentsPanel::updateValues()
BPPBlast& blast = projectParams.blast;
BPPGraphicsMaterialArray& graphicsMaterialsArray = projectParams.graphicsMaterials;
- BPPMaterialAssignments& assignment = blast.graphicsMeshes.buf[_selectedGraphicsMesh].materialAssignments;
-
- ui->comboBoxMaterialID1->clear();
- ui->comboBoxMaterialID2->clear();
- ui->comboBoxMaterialID3->clear();
- ui->comboBoxMaterialID4->clear();
-
- QStringList materialNames;
- materialNames.append("None");
- int count = graphicsMaterialsArray.arraySizes[0];
- for (int i = 0; i < count; ++i)
- {
- materialNames.append(graphicsMaterialsArray.buf[i].name.buf);
- }
-
- ui->comboBoxMaterialID1->insertItems(0, materialNames);
- ui->comboBoxMaterialID2->insertItems(0, materialNames);
- ui->comboBoxMaterialID3->insertItems(0, materialNames);
- ui->comboBoxMaterialID4->insertItems(0, materialNames);
-
- ui->comboBoxMaterialID1->setCurrentIndex(assignment.materialIndexes[0] + 1);
- ui->comboBoxMaterialID2->setCurrentIndex(assignment.materialIndexes[1] + 1);
- ui->comboBoxMaterialID3->setCurrentIndex(assignment.materialIndexes[2] + 1);
- ui->comboBoxMaterialID4->setCurrentIndex(assignment.materialIndexes[3] + 1);
+ //BPPMaterialAssignmentsArray& assignment = blast.graphicsMeshes.buf[_selectedGraphicsMesh].materialAssignments;
+
+ //ui->comboBoxMaterialID1->clear();
+ //ui->comboBoxMaterialID2->clear();
+ //ui->comboBoxMaterialID3->clear();
+ //ui->comboBoxMaterialID4->clear();
+
+ //QStringList materialNames;
+ //materialNames.append("None");
+ //int count = graphicsMaterialsArray.arraySizes[0];
+ //for (int i = 0; i < count; ++i)
+ //{
+ // materialNames.append(graphicsMaterialsArray.buf[i].name.buf);
+ //}
+
+ //ui->comboBoxMaterialID1->insertItems(0, materialNames);
+ //ui->comboBoxMaterialID2->insertItems(0, materialNames);
+ //ui->comboBoxMaterialID3->insertItems(0, materialNames);
+ //ui->comboBoxMaterialID4->insertItems(0, materialNames);
+
+ //ui->comboBoxMaterialID1->setCurrentIndex(assignment.materialIndexes[0] + 1);
+ //ui->comboBoxMaterialID2->setCurrentIndex(assignment.materialIndexes[1] + 1);
+ //ui->comboBoxMaterialID3->setCurrentIndex(assignment.materialIndexes[2] + 1);
+ //ui->comboBoxMaterialID4->setCurrentIndex(assignment.materialIndexes[3] + 1);
}
-
-
}
void MaterialAssignmentsPanel::on_comboBoxMaterialID1_currentIndexChanged(int index)
@@ -173,24 +184,8 @@ void MaterialAssignmentsPanel::on_comboBoxMaterialID1_currentIndexChanged(int in
{
return;
}
- std::map<std::string, RenderMaterial*>& renderMaterials = pSampleManager->getRenderMaterials();
- std::map<std::string, RenderMaterial*>::iterator it = renderMaterials.find(name);
- if (it != renderMaterials.end())
- {
- pRenderMaterial = it->second;
- }
- else
- {
- MaterialLibraryPanel* pMaterialLibraryPanel = MaterialLibraryPanel::ins();
- std::map<std::string, RenderMaterial*>& renderMaterials2 = pMaterialLibraryPanel->getRenderMaterials();
- it = renderMaterials2.find(name);
- if (it != renderMaterials2.end())
- {
- pRenderMaterial = it->second;
- }
- }
- pSampleManager->setMaterialForCurrentFamily(pRenderMaterial, true);
+ pSampleManager->setMaterialForCurrentFamily(name, true);
return;
assignMaterialToMaterialID(0, index - 1);
@@ -211,24 +206,8 @@ void MaterialAssignmentsPanel::on_comboBoxMaterialID2_currentIndexChanged(int in
{
return;
}
- std::map<std::string, RenderMaterial*>& renderMaterials = pSampleManager->getRenderMaterials();
- std::map<std::string, RenderMaterial*>::iterator it = renderMaterials.find(name);
- if (it != renderMaterials.end())
- {
- pRenderMaterial = it->second;
- }
- else
- {
- MaterialLibraryPanel* pMaterialLibraryPanel = MaterialLibraryPanel::ins();
- std::map<std::string, RenderMaterial*>& renderMaterials2 = pMaterialLibraryPanel->getRenderMaterials();
- it = renderMaterials2.find(name);
- if (it != renderMaterials2.end())
- {
- pRenderMaterial = it->second;
- }
- }
- pSampleManager->setMaterialForCurrentFamily(pRenderMaterial, false);
+ pSampleManager->setMaterialForCurrentFamily(name, false);
return;
assignMaterialToMaterialID(1, index - 1);
@@ -256,10 +235,10 @@ void MaterialAssignmentsPanel::assignMaterialToMaterialID(int materialID, int ma
if (materialIndex >= graphicsMaterialArray.arraySizes[0])
return;
- BPPGraphicsMeshArray& graphicsMeshArray = blast.graphicsMeshes;
+ //BPPGraphicsMeshArray& graphicsMeshArray = blast.graphicsMeshes;
- if (_selectedGraphicsMesh > -1 && _selectedGraphicsMesh < graphicsMeshArray.arraySizes[0])
- {
- graphicsMeshArray.buf[_selectedGraphicsMesh].materialAssignments.materialIndexes[materialID] = materialIndex;
- }
+ //if (_selectedGraphicsMesh > -1 && _selectedGraphicsMesh < graphicsMeshArray.arraySizes[0])
+ //{
+ // graphicsMeshArray.buf[_selectedGraphicsMesh].materialAssignments.materialIndexes[materialID] = materialIndex;
+ //}
}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.cpp
index b9ad5e8..f062ad4 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.cpp
@@ -6,12 +6,10 @@
#include <QtWidgets/QMessageBox>
#include "QtUtil.h"
#include "AppMainWindow.h"
-#include "SimpleScene.h"
-#include "RenderMaterial.h"
-#include "ResourceManager.h"
#include "SampleManager.h"
#include "MaterialAssignmentsPanel.h"
-#include "Renderable.h"
+#include "FractureGeneralPanel.h"
+#include "ResourceManager.h"
enum ETextureType
{
eDiffuseTexture,
@@ -45,7 +43,6 @@ void OnTextureButtonClicked(BPPGraphicsMaterial& material, ETextureType t, QPush
else
pButton->setIcon(QIcon(":/AppMainWindow/images/TextureIsUsed_icon.png"));
- SimpleScene::Inst()->SetFurModified(true);
}
void OnTextureReload(BPPGraphicsMaterial& material, ETextureType t, QPushButton* pButton)
@@ -72,7 +69,6 @@ void OnTextureReload(BPPGraphicsMaterial& material, ETextureType t, QPushButton*
else
pButton->setIcon(QIcon(":/AppMainWindow/images/TextureIsUsed_icon.png"));
- SimpleScene::Inst()->SetFurModified(true);
}
void OnTextureClear(BPPGraphicsMaterial& material, ETextureType t, QPushButton* pButton)
@@ -95,7 +91,6 @@ void OnTextureClear(BPPGraphicsMaterial& material, ETextureType t, QPushButton*
pButton->setIcon(QIcon(":/AppMainWindow/images/TextureEnabled_icon.png"));
- SimpleScene::Inst()->SetFurModified(true);
}
MaterialLibraryPanel* pMaterialLibraryPanel = nullptr;
@@ -104,65 +99,6 @@ MaterialLibraryPanel* MaterialLibraryPanel::ins()
return pMaterialLibraryPanel;
}
-void MaterialLibraryPanel::addMaterial(std::string materialName, std::string diffuseTexture)
-{
- if (!BlastProject::ins().isGraphicsMaterialNameExist(materialName.c_str()))
- {
- BlastProject::ins().addGraphicsMaterial(materialName.c_str(), diffuseTexture.c_str());
- updateValues();
- ui->listWidget->setCurrentRow(ui->listWidget->count() - 1);
- }
-}
-
-void MaterialLibraryPanel::removeMaterial(std::string name)
-{
- BlastProject::ins().removeGraphicsMaterial(name.c_str());
- updateValues();
- ui->listWidget->setCurrentRow(ui->listWidget->count() - 1);
-}
-
-void MaterialLibraryPanel::deleteMaterials()
-{
- std::vector<std::string>::iterator itStr;
- std::vector<Renderable*>::iterator itRenderable;
-
- for (itStr = m_NeedDeleteRenderMaterials.begin(); itStr != m_NeedDeleteRenderMaterials.end(); itStr++)
- {
- std::string materialName = *itStr;
- RenderMaterial* pRenderMaterial = m_RenderMaterialMap[materialName];
- std::vector<Renderable*>& renderables = pRenderMaterial->getRelatedRenderables();
- for (itRenderable = renderables.begin(); itRenderable != renderables.end(); itRenderable++)
- {
- Renderable* pRenderable = *itRenderable;
- pRenderable->setMaterial(*RenderMaterial::getDefaultRenderMaterial());
- }
-
- std::map<std::string, RenderMaterial*>::iterator it = m_RenderMaterialMap.find(materialName);
- if (it != m_RenderMaterialMap.end())
- {
- m_RenderMaterialMap.erase(it);
- delete it->second;
- MaterialLibraryPanel::ins()->removeMaterial(materialName);
- }
- }
-
- m_NeedDeleteRenderMaterials.clear();
-}
-
-void MaterialLibraryPanel::deleteMaterialMap()
-{
- std::map<std::string, RenderMaterial*>::iterator itRMM;
- for (itRMM = m_RenderMaterialMap.begin(); itRMM != m_RenderMaterialMap.end(); itRMM++)
- {
- RenderMaterial* pRenderMaterial = itRMM->second;
- std::string materialName = pRenderMaterial->getMaterialName();
- MaterialLibraryPanel::ins()->removeMaterial(materialName);
- delete pRenderMaterial;
- }
- m_RenderMaterialMap.clear();
- m_NeedDeleteRenderMaterials.clear();
-}
-
MaterialLibraryPanel::MaterialLibraryPanel(QWidget *parent) :
QWidget(parent),
ui(new Ui::MaterialLibraryPanel)
@@ -203,6 +139,7 @@ void MaterialLibraryPanel::updateValues()
}
MaterialAssignmentsPanel::ins()->updateValues();
+ FractureGeneralPanel::ins()->updateValues();
}
void MaterialLibraryPanel::on_btnAddMat_clicked()
@@ -217,10 +154,13 @@ void MaterialLibraryPanel::on_btnAddMat_clicked()
bool nameExist = BlastProject::ins().isGraphicsMaterialNameExist(name.toUtf8().data());
if (ok && !name.isEmpty() && !nameExist)
{
- ResourceManager* pResourceManager = ResourceManager::ins();
std::string strName = name.toUtf8().data();
- RenderMaterial* pRenderMaterial = new RenderMaterial(strName.c_str(), *pResourceManager, "model_simple_textured_ex");
- m_RenderMaterialMap[strName] = pRenderMaterial;
+ if (!BlastProject::ins().isGraphicsMaterialNameExist(strName.c_str()))
+ {
+ BlastProject::ins().addGraphicsMaterial(strName.c_str());
+ updateValues();
+ ui->listWidget->setCurrentRow(ui->listWidget->count() - 1);
+ }
}
else if (ok && nameExist)
{
@@ -256,15 +196,6 @@ void MaterialLibraryPanel::on_btnModifyMat_clicked()
std::string strOldName = oldName;
std::string strNewName = newName.toUtf8().data();
- std::map<std::string, RenderMaterial*>::iterator it = m_RenderMaterialMap.find(strOldName);
- if (it != m_RenderMaterialMap.end())
- {
- RenderMaterial* pRenderMaterial = it->second;
- m_RenderMaterialMap.erase(it);
- pRenderMaterial->setMaterialName(strNewName);
- m_RenderMaterialMap[strNewName] = pRenderMaterial;
- }
-
SampleManager::ins()->renameRenderMaterial(strOldName, strNewName);
BlastProject::ins().renameGraphicsMaterial(oldName, newName.toUtf8().data());
@@ -291,15 +222,12 @@ void MaterialLibraryPanel::on_btnRemoveMat_clicked()
QByteArray tem = items.at(0)->text().toUtf8();
std::string strName = tem.data();
- std::map<std::string, RenderMaterial*>::iterator it = m_RenderMaterialMap.find(strName);
- if (it != m_RenderMaterialMap.end())
- {
- m_NeedDeleteRenderMaterials.push_back(it->second->getMaterialName());
- }
- else
- {
- SampleManager::ins()->deleteRenderMaterial(strName);
- }
+
+ SampleManager::ins()->removeRenderMaterial(strName);
+
+ BlastProject::ins().removeGraphicsMaterial(strName.c_str());
+ updateValues();
+ ui->listWidget->setCurrentRow(ui->listWidget->count() - 1);
}
void MaterialLibraryPanel::on_listWidget_currentRowChanged(int currentRow)
@@ -315,6 +243,13 @@ void MaterialLibraryPanel::on_btnDiffuseColor_clicked()
atcore_float4* color = (atcore_float4*)&(material->diffuseColor);
pickColor(*color);
setButtonColor(ui->btnDiffuseColor, color->x, color->y, color->z);
+
+ QString qName = material->name.buf;
+ std::string strName = qName.toUtf8().data();
+
+ BlastProject::ins().reloadDiffuseColor(strName.c_str(), color->x, color->y, color->z);
+
+ SampleManager::ins()->reloadRenderMaterial(strName, color->x, color->y, color->z);
}
}
@@ -324,6 +259,15 @@ void MaterialLibraryPanel::on_btnDiffuseColorTex_clicked()
if (material)
{
OnTextureButtonClicked(*material, eDiffuseTexture, ui->btnDiffuseColorTex);
+
+ QString qName = material->name.buf;
+ std::string strName = qName.toUtf8().data();
+ QString qTexture = material->diffuseTextureFilePath.buf;
+ std::string strTexture = qTexture.toUtf8().data();
+
+ BlastProject::ins().reloadDiffuseTexture(strName.c_str(), strTexture.c_str());
+
+ SampleManager::ins()->reloadRenderMaterial(strName, strTexture);
}
}
@@ -338,13 +282,10 @@ void MaterialLibraryPanel::on_btnDiffuseColorTexReload_clicked()
std::string strName = qName.toUtf8().data();
QString qTexture = material->diffuseTextureFilePath.buf;
std::string strTexture = qTexture.toUtf8().data();
-
- std::map<std::string, RenderMaterial*>& renderMaterials = SampleManager::ins()->getRenderMaterials();
- std::map<std::string, RenderMaterial*>::iterator it = renderMaterials.find(strName);
- if (it != renderMaterials.end())
- {
- it->second->setTextureFileName(strTexture);
- }
+
+ SampleManager::ins()->reloadRenderMaterial(strName, "");
+ ResourceManager::ins()->releaseTexture(strTexture.c_str());
+ SampleManager::ins()->reloadRenderMaterial(strName, strTexture);
}
}
@@ -357,15 +298,10 @@ void MaterialLibraryPanel::on_btnDiffuseColorTexClear_clicked()
QString qName = material->name.buf;
std::string strName = qName.toUtf8().data();
- QString qTexture = material->diffuseTextureFilePath.buf;
- std::string strTexture = qTexture.toUtf8().data();
- std::map<std::string, RenderMaterial*>& renderMaterials = SampleManager::ins()->getRenderMaterials();
- std::map<std::string, RenderMaterial*>::iterator it = renderMaterials.find(strName);
- if (it != renderMaterials.end())
- {
- it->second->setTextureFileName(strTexture);
- }
+ BlastProject::ins().reloadDiffuseTexture(strName.c_str(), "");
+
+ SampleManager::ins()->reloadRenderMaterial(strName, "");
}
}
@@ -377,6 +313,13 @@ void MaterialLibraryPanel::on_btnSpecularColor_clicked()
atcore_float4* color = (atcore_float4*)&(material->specularColor);
pickColor(*color);
setButtonColor(ui->btnSpecularColor, color->x, color->y, color->z);
+
+ QString qName = material->name.buf;
+ std::string strName = qName.toUtf8().data();
+
+ BlastProject::ins().reloadSpecularColor(strName.c_str(), color->x, color->y, color->z);
+
+ SampleManager::ins()->reloadRenderMaterial(strName, color->x, color->y, color->z, false);
}
}
@@ -386,6 +329,15 @@ void MaterialLibraryPanel::on_btnSpecularColorTex_clicked()
if (material)
{
OnTextureButtonClicked(*material, eSpecularTexture, ui->btnSpecularColorTex);
+
+ QString qName = material->name.buf;
+ std::string strName = qName.toUtf8().data();
+ QString qTexture = material->specularTextureFilePath.buf;
+ std::string strTexture = qTexture.toUtf8().data();
+
+ BlastProject::ins().reloadSpecularTexture(strName.c_str(), strTexture.c_str());
+
+ SampleManager::ins()->reloadRenderMaterial(strName, strTexture, RenderMaterial::TT_Specular);
}
}
@@ -395,6 +347,15 @@ void MaterialLibraryPanel::on_btnSpecularColorTexReload_clicked()
if (material)
{
OnTextureReload(*material, eSpecularTexture, ui->btnSpecularColorTex);
+
+ QString qName = material->name.buf;
+ std::string strName = qName.toUtf8().data();
+ QString qTexture = material->specularTextureFilePath.buf;
+ std::string strTexture = qTexture.toUtf8().data();
+
+ SampleManager::ins()->reloadRenderMaterial(strName, "", RenderMaterial::TT_Specular);
+ ResourceManager::ins()->releaseTexture(strTexture.c_str());
+ SampleManager::ins()->reloadRenderMaterial(strName, strTexture, RenderMaterial::TT_Specular);
}
}
@@ -404,6 +365,13 @@ void MaterialLibraryPanel::on_btnSpecularColorTexClear_clicked()
if (material)
{
OnTextureClear(*material, eSpecularTexture, ui->btnSpecularColorTex);
+
+ QString qName = material->name.buf;
+ std::string strName = qName.toUtf8().data();
+
+ BlastProject::ins().reloadSpecularTexture(strName.c_str(), "");
+
+ SampleManager::ins()->reloadRenderMaterial(strName, "", RenderMaterial::TT_Specular);
}
}
@@ -412,7 +380,13 @@ void MaterialLibraryPanel::on_spinSpecularShin_valueChanged(double arg1)
BPPGraphicsMaterial* material = _getSelectedMaterial();
if (material)
{
- material->specularShininess = (float)arg1;
+ float specularShininess = (float)arg1;
+
+ material->specularShininess = specularShininess;
+
+ QString qName = material->name.buf;
+ std::string strName = qName.toUtf8().data();
+ SampleManager::ins()->reloadRenderMaterial(strName, specularShininess);
}
}
@@ -422,6 +396,15 @@ void MaterialLibraryPanel::on_btnNormalColorTex_clicked()
if (material)
{
OnTextureButtonClicked(*material, eNormalTexture, ui->btnNormalColorTex);
+
+ QString qName = material->name.buf;
+ std::string strName = qName.toUtf8().data();
+ QString qTexture = material->normalTextureFilePath.buf;
+ std::string strTexture = qTexture.toUtf8().data();
+
+ BlastProject::ins().reloadNormalTexture(strName.c_str(), strTexture.c_str());
+
+ SampleManager::ins()->reloadRenderMaterial(strName, strTexture, RenderMaterial::TT_Normal);
}
}
@@ -431,6 +414,15 @@ void MaterialLibraryPanel::on_btnNormalColorTexReload_clicked()
if (material)
{
OnTextureReload(*material, eNormalTexture, ui->btnNormalColorTex);
+
+ QString qName = material->name.buf;
+ std::string strName = qName.toUtf8().data();
+ QString qTexture = material->normalTextureFilePath.buf;
+ std::string strTexture = qTexture.toUtf8().data();
+
+ SampleManager::ins()->reloadRenderMaterial(strName, "", RenderMaterial::TT_Normal);
+ ResourceManager::ins()->releaseTexture(strTexture.c_str());
+ SampleManager::ins()->reloadRenderMaterial(strName, strTexture, RenderMaterial::TT_Normal);
}
}
@@ -440,6 +432,13 @@ void MaterialLibraryPanel::on_btnNormalColorTexClear_clicked()
if (material)
{
OnTextureClear(*material, eNormalTexture, ui->btnNormalColorTex);
+
+ QString qName = material->name.buf;
+ std::string strName = qName.toUtf8().data();
+
+ BlastProject::ins().reloadNormalTexture(strName.c_str(), "");
+
+ SampleManager::ins()->reloadRenderMaterial(strName, "", RenderMaterial::TT_Normal);
}
}
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.h
index edf1df9..9012294 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.h
@@ -20,11 +20,6 @@ public:
void updateValues();
static MaterialLibraryPanel* ins();
- void addMaterial(std::string materialName, std::string diffuseTexture);
- void removeMaterial(std::string name);
- std::map<std::string, RenderMaterial*>& getRenderMaterials(){ return m_RenderMaterialMap; }
- void deleteMaterials();
- void deleteMaterialMap();
private slots:
void on_btnAddMat_clicked();
@@ -63,9 +58,6 @@ private:
void _refreshMaterialValues(int idx);
BPPGraphicsMaterial* _getSelectedMaterial();
- std::map<std::string, RenderMaterial*> m_RenderMaterialMap;
- std::vector<std::string> m_NeedDeleteRenderMaterials;
-
private:
Ui::MaterialLibraryPanel *ui;
};
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.cpp b/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.cpp
index db40407..9db55c2 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.cpp
@@ -2,18 +2,51 @@
#include "ui_SourceAssetOpenDlg.h"
#include <QtWidgets/QFileDialog>
#include "AppMainWindow.h"
+#include "GlobalSettings.h"
-SourceAssetOpenDlg::SourceAssetOpenDlg(bool bOpenBlastFile, QWidget *parent) :
+SourceAssetOpenDlg::SourceAssetOpenDlg(int usefor, QWidget *parent) :
QDialog(parent),
ui(new Ui::SourceAssetOpenDlg)
{
ui->setupUi(this);
- m_bOpenBlastFile = bOpenBlastFile;
+ m_usefor = usefor;
ui->buttonBox->button(QDialogButtonBox::Ok)->setFixedWidth(100);
ui->buttonBox->button(QDialogButtonBox::Cancel)->setFixedWidth(100);
ui->spinBoxDegree->setMaximum(180);
ui->spinBoxDegree->setMinimum(-180);
+
+ ui->spinBoxXPosition->setRange(-DBL_MAX, DBL_MAX);
+ ui->spinBoxYPosition->setRange(-DBL_MAX, DBL_MAX);
+ ui->spinBoxZPosition->setRange(-DBL_MAX, DBL_MAX);
+ ui->spinBoxXAxis->setRange(-DBL_MAX, DBL_MAX);
+ ui->spinBoxYAxis->setRange(-DBL_MAX, DBL_MAX);
+ ui->spinBoxZAxis->setRange(-DBL_MAX, DBL_MAX);
+
+ if (m_usefor == 2)
+ {
+ ui->fileLabel->setVisible(false);
+ ui->lineEditFile->setVisible(false);
+ ui->btnOpenFile->setVisible(false);
+
+ ui->skinnedLabel->setVisible(false);
+ ui->checkBoxSkinned->setVisible(false);
+
+ ui->appendLabel->setVisible(false);
+ ui->checkBoxAppend->setVisible(false);
+
+ ui->preFracturedLabel->setVisible(false);
+ ui->checkBoxPreFractured->setVisible(false);
+ }
+
+ GlobalSettings& globalSettings = GlobalSettings::Inst();
+ ui->cbSceneUnit->setCurrentIndex(globalSettings.m_sceneUnitIndex);
+
+ if (m_usefor != 0)
+ {
+ ui->autoComputeLabel->setVisible(false);
+ ui->checkBoxAutoCompute->setVisible(false);
+ }
}
SourceAssetOpenDlg::~SourceAssetOpenDlg()
@@ -21,6 +54,11 @@ SourceAssetOpenDlg::~SourceAssetOpenDlg()
delete ui;
}
+void SourceAssetOpenDlg::setDefaultFile(const QString& fn)
+{
+ ui->lineEditFile->setText(fn);
+}
+
QString SourceAssetOpenDlg::getFile()
{
return ui->lineEditFile->text();
@@ -46,20 +84,35 @@ double SourceAssetOpenDlg::getRotationDegree()
return ui->spinBoxDegree->value();
}
+int SourceAssetOpenDlg::sceneUnitIndex()
+{
+ return ui->cbSceneUnit->currentIndex();
+}
+
bool SourceAssetOpenDlg::isAppend()
{
return ui->checkBoxAppend->isChecked();
}
+bool SourceAssetOpenDlg::isPreFractured()
+{
+ return ui->checkBoxPreFractured->isChecked();
+}
+
+bool SourceAssetOpenDlg::isAutoCompute()
+{
+ return ui->checkBoxAutoCompute->isChecked();
+}
+
void SourceAssetOpenDlg::on_btnOpenFile_clicked()
{
QString lastDir = AppMainWindow::Inst()._lastFilePath;
QString titleStr = "Open Source Asset File";
QString filetype = "Source Asset (*.fbx)";
- if (m_bOpenBlastFile)
+ if (m_usefor == 1)
{
- filetype = "Source Asset (*.bpxa)";
+ filetype = "Source Asset (*.blast)";
}
QString fileName = QFileDialog::getOpenFileName(this, titleStr, lastDir, filetype);
if (!fileName.isEmpty())
@@ -80,3 +133,19 @@ void SourceAssetOpenDlg::on_buttonBox_rejected()
{
}
+
+void SourceAssetOpenDlg::on_checkBoxPreFractured_stateChanged(int arg1)
+{
+ if (!ui->checkBoxPreFractured->isChecked())
+ {
+ ui->checkBoxAutoCompute->setChecked(false);
+ }
+}
+
+void SourceAssetOpenDlg::on_checkBoxAutoCompute_stateChanged(int arg1)
+{
+ if (ui->checkBoxAutoCompute->isChecked())
+ {
+ ui->checkBoxPreFractured->setChecked(true);
+ }
+} \ No newline at end of file
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.h b/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.h
index ec03ee9..ed6da9c 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.h
+++ b/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.h
@@ -13,15 +13,19 @@ class SourceAssetOpenDlg : public QDialog
Q_OBJECT
public:
- explicit SourceAssetOpenDlg(bool bOpenBlastFile = true, QWidget *parent = 0);
+ explicit SourceAssetOpenDlg(int usefor, QWidget *parent = 0);
~SourceAssetOpenDlg();
+ void setDefaultFile(const QString& fn);
QString getFile();
bool getSkinned();
QVector3D getPosition();
QVector3D getRotationAxis();
double getRotationDegree();
bool isAppend();
+ bool isPreFractured();
+ bool isAutoCompute();
+ int sceneUnitIndex();
private slots:
void on_btnOpenFile_clicked();
@@ -30,9 +34,18 @@ private slots:
void on_buttonBox_rejected();
+ void on_checkBoxPreFractured_stateChanged(int arg1);
+ void on_checkBoxAutoCompute_stateChanged(int arg1);
+
private:
Ui::SourceAssetOpenDlg *ui;
- bool m_bOpenBlastFile;
+ /*
+ m_usefor:
+ 0 for open fbx file
+ 1 for open blast file
+ 2 for add BlastFamily
+ */
+ int m_usefor;
};
#endif // SOURCEASSETOPENDLG_H
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.cpp
index 424dbb3..556da33 100644
--- a/tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.cpp
+++ b/tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.cpp
@@ -7,6 +7,12 @@ SupportPanel::SupportPanel(QWidget *parent) :
{
ui->setupUi(this);
+ //ui->labelHealthMask->setEnabled(false);
+ //ui->comboBoxHealthMask->setEnabled(false);
+ //ui->btnAddHealthMask->setEnabled(false);
+ //ui->btnPen->setEnabled(false);
+ //ui->btnRemove->setEnabled(false);
+
_selectedBonds.clear();
}
@@ -23,15 +29,15 @@ void SupportPanel::updateValues()
{
BPPBond* bond = _selectedBonds[0];
- ui->comboBoxHealthMask->clear();
- ui->comboBoxHealthMask->addItem(bond->name.buf);
+ //ui->comboBoxHealthMask->clear();
+ //ui->comboBoxHealthMask->addItem(bond->name.buf);
ui->spinBoxBondStrength->setValue(bond->support.bondStrength);
ui->checkBoxEnableJoint->setChecked(bond->support.enableJoint);
}
else
{
- ui->comboBoxHealthMask->clear();
- ui->comboBoxHealthMask->addItem("None");
+ //ui->comboBoxHealthMask->clear();
+ //ui->comboBoxHealthMask->addItem("None");
ui->spinBoxBondStrength->setValue(1.0f);
ui->checkBoxEnableJoint->setChecked(false);
}