-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayerCleaner.cpp
58 lines (50 loc) · 1.59 KB
/
LayerCleaner.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <QtCore/QObject> // include this before mudbox headers.
#include <Mudbox/mudbox.h>
#include "LayerCleaner.h"
using namespace mudbox;
void CleanSculptLayers()
{
// traver all the geometries.
for (unsigned int iG = 0; iG < Kernel()->Scene()->GeometryCount(); ++iG)
{
Geometry *pG = Kernel()->Scene()->Geometry(iG);
if (!pG)
continue;
Store<Mesh *> aMeshes;
Store<LayerMeshData *> aLayers;
// go through all the sculpt layers of this geometry,
// they may lock to different levels though.
const unsigned int iLayerCount = pG->LayerCount();
for (unsigned int iL = 0; iL < iLayerCount; ++iL)
{
LayerMeshData *pLayer = pG->LayerData(iL);
if (!pLayer)
continue;
Mesh *pMesh = pLayer->Mesh(); pMesh;
aMeshes.Add(pLayer->Mesh());
aLayers.Add(pLayer);
}
SubdivisionLevel *pActiveLevel = pG->ActiveLevel();
for (unsigned int i = 0; i < aLayers.ItemCount(); ++i)
{
if (!aMeshes[i])
continue;
// sculpt layer can only be removed from the active level
// and this active level is the layer locked to.
pG->ChangeActiveLevel(dynamic_cast<SubdivisionLevel *>(aMeshes[i]));
aMeshes[i]->RemoveLayer(aLayers[i]);
// update the mesh renderer.
aMeshes[i]->ContentChanged();
MeshRenderer *pR = NULL;
for (unsigned int r = 0; pR = aMeshes[i]->ChildByClass<MeshRenderer>(r); ++r)
{
pR->OnMeshChange(MeshRenderer::changeVertexPosition);
pR->OnVertexPositionChange(-1, -1);
}
}
pG->ChangeActiveLevel(pActiveLevel);
pG->ContentChanged();
}
Kernel()->ViewPort()->Redraw();
Kernel()->Interface()->RefreshUI();
}