select entities with same mesh
This commit is contained in:
parent
fcd98d6678
commit
3011540749
8 changed files with 75 additions and 2 deletions
|
@ -562,18 +562,20 @@ void EntityList::setWorldEditor(Lumix::WorldEditor& editor)
|
|||
|
||||
void EntityList::onEntitySelected(const Lumix::Array<Lumix::Entity>& entities)
|
||||
{
|
||||
m_ui->entityList->selectionModel()->clear();
|
||||
QItemSelection* selection = new QItemSelection();
|
||||
for(int j = entities.size() - 1; j >= 0; --j)
|
||||
{
|
||||
for (int i = 0, c = m_filter->rowCount(); i < c; ++i)
|
||||
{
|
||||
if (m_filter->data(m_filter->index(i, 0), Qt::UserRole).toInt() == entities[j].index)
|
||||
{
|
||||
m_ui->entityList->selectionModel()->select(m_filter->index(i, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
selection->append(QItemSelectionRange(m_filter->index(i, 0)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_ui->entityList->selectionModel()->select(*selection, QItemSelectionModel::SelectionFlag::ClearAndSelect | QItemSelectionModel::SelectionFlag::Rows);
|
||||
delete selection;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -467,3 +467,8 @@ void MainWindow::on_actionPaste_triggered()
|
|||
{
|
||||
m_world_editor->pasteEntity();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSame_mesh_triggered()
|
||||
{
|
||||
m_world_editor->selectEntitiesWithSameMesh();
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ private slots:
|
|||
|
||||
void on_actionPaste_triggered();
|
||||
|
||||
void on_actionSame_mesh_triggered();
|
||||
|
||||
private:
|
||||
class DockInfo
|
||||
{
|
||||
|
|
|
@ -83,6 +83,12 @@
|
|||
<property name="title">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuSelect">
|
||||
<property name="title">
|
||||
<string>Select</string>
|
||||
</property>
|
||||
<addaction name="actionSame_mesh"/>
|
||||
</widget>
|
||||
<addaction name="actionUndo"/>
|
||||
<addaction name="actionRedo"/>
|
||||
<addaction name="separator"/>
|
||||
|
@ -91,6 +97,7 @@
|
|||
<addaction name="separator"/>
|
||||
<addaction name="actionCenter_Pivot"/>
|
||||
<addaction name="actionLocal_Global"/>
|
||||
<addaction name="menuSelect"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
|
@ -322,6 +329,11 @@
|
|||
<string>Ctrl+V</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSame_mesh">
|
||||
<property name="text">
|
||||
<string>Same mesh</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
|
|
@ -1786,6 +1786,33 @@ struct WorldEditorImpl : public WorldEditor
|
|||
}
|
||||
|
||||
|
||||
virtual void selectEntitiesWithSameMesh() override
|
||||
{
|
||||
if(!m_selected_entities.empty())
|
||||
{
|
||||
Component cmp = m_selected_entities[0].getComponent(RENDERABLE_HASH);
|
||||
if(cmp.isValid())
|
||||
{
|
||||
Array<Entity> entities;
|
||||
|
||||
RenderScene* scene = static_cast<RenderScene*>(cmp.scene);
|
||||
Model* model = scene->getRenderableModel(cmp);
|
||||
Component renderable = scene->getFirstRenderable();
|
||||
while(renderable.isValid())
|
||||
{
|
||||
if(model == scene->getRenderableModel(renderable))
|
||||
{
|
||||
entities.push(renderable.entity);
|
||||
}
|
||||
renderable = scene->getNextRenderable(renderable);
|
||||
}
|
||||
|
||||
selectEntities(&entities[0], entities.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void onComponentCreated(const Component& cmp)
|
||||
{
|
||||
for (int i = 0; i < m_editor_icons.size(); ++i)
|
||||
|
|
|
@ -78,6 +78,7 @@ namespace Lumix
|
|||
virtual Entity addEntity() = 0;
|
||||
virtual void destroyEntities(const Entity* entities, int count) = 0;
|
||||
virtual void selectEntities(const Entity* entities, int count) = 0;
|
||||
virtual void selectEntitiesWithSameMesh() = 0;
|
||||
virtual Entity addEntityAt(int camera_x, int camera_y) = 0;
|
||||
virtual void setEntitiesPositions(const Array<Entity>& entity, const Array<Vec3>& position) = 0;
|
||||
virtual void setEntityPositionAndRotaion(const Array<Entity>& entity, const Array<Vec3>& position, const Array<Quat>& rotation) = 0;
|
||||
|
|
|
@ -808,6 +808,28 @@ namespace Lumix
|
|||
}
|
||||
|
||||
|
||||
virtual Component getFirstRenderable() override
|
||||
{
|
||||
for(int i = 0; i < m_renderables.size(); ++i)
|
||||
{
|
||||
if(!m_renderables[i]->m_is_free)
|
||||
return Component(m_renderables[i]->m_entity, RENDERABLE_HASH, this, i);
|
||||
}
|
||||
return Component::INVALID;
|
||||
}
|
||||
|
||||
|
||||
virtual Component getNextRenderable(const Component& cmp) override
|
||||
{
|
||||
for(int i = cmp.index + 1; i < m_renderables.size(); ++i)
|
||||
{
|
||||
if(!m_renderables[i]->m_is_free)
|
||||
return Component(m_renderables[i]->m_entity, RENDERABLE_HASH, this, i);
|
||||
}
|
||||
return Component::INVALID;
|
||||
}
|
||||
|
||||
|
||||
virtual void getRenderableInfos(const Frustum& frustum, Array<RenderableInfo>& infos, int64_t layer_mask) override
|
||||
{
|
||||
PROFILE_FUNCTION();
|
||||
|
|
|
@ -102,6 +102,8 @@ namespace Lumix
|
|||
virtual void setRenderableScale(Component cmp, float scale) = 0;
|
||||
virtual void getRenderableInfos(const Frustum& frustum, Array<RenderableInfo>& infos, int64_t layer_mask) = 0;
|
||||
virtual void getRenderableInfos(Array<RenderableInfo>& infos, int64_t layer_mask) = 0;
|
||||
virtual Component getFirstRenderable() = 0;
|
||||
virtual Component getNextRenderable(const Component& cmp) = 0;
|
||||
virtual Model* getRenderableModel(Component cmp) = 0;
|
||||
|
||||
virtual void getGrassInfos(const Frustum& frustum, Array<GrassInfo>& infos, int64_t layer_mask) = 0;
|
||||
|
|
Loading…
Reference in a new issue