-
Notifications
You must be signed in to change notification settings - Fork 0
/
mudbox_deformers_util.cpp
62 lines (47 loc) · 1.47 KB
/
mudbox_deformers_util.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
59
60
61
62
#include "mudbox_deformers_util.h"
#include <Mudbox/mudbox.h>
using mudbox::Kernel;
using mudbox::SubdivisionLevel;
using mudbox::MeshRenderer;
using mudbox::Geometry;
using mudbox::Interface;
void markSubdivisionLevelDirty(SubdivisionLevel *subdivLevel)
{
MeshRenderer *renderer;
for (unsigned int i=0; renderer = subdivLevel->ChildByClass<MeshRenderer>(i); ++i) {
for (unsigned int f=0; f < subdivLevel->FaceCount(); ++f) {
for (int j=0; j < 4; ++j) {
renderer->OnVertexPositionChange(subdivLevel->QuadIndex(f, j), f);
}
}
}
}
void updateSubdivisionLevel(SubdivisionLevel *subdivLevel)
{
subdivLevel->ApplyChanges(true);
subdivLevel->RecalculateAdjacency();
subdivLevel->RecalculateNormals();
// NOTE: (sonictk) Mark the mesh components dirty and notify all the renderers
// to redraw the mesh
markSubdivisionLevelDirty(subdivLevel);
Kernel()->ViewPort()->Redraw();
}
void quickUpdateSubdivisionLevel(SubdivisionLevel *subdivLevel)
{
subdivLevel->ApplyChanges(true);
// NOTE: (sonictk) Mark the mesh components dirty and notify all the renderers
// to redraw the mesh
markSubdivisionLevelDirty(subdivLevel);
Kernel()->ViewPort()->Redraw();
}
bool checkIfNoGeometrySelectedAndDisplayWarning()
{
Geometry *currentActiveGeo = Kernel()->Scene()->ActiveGeometry();
if (!currentActiveGeo) {
Kernel()->Interface()->MessageBox(Interface::msgError,
"No mesh selected!",
"You need to select a mesh first!");
return false;
}
return true;
}