-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlandscapesculpttool.cpp
More file actions
73 lines (55 loc) · 1.53 KB
/
landscapesculpttool.cpp
File metadata and controls
73 lines (55 loc) · 1.53 KB
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
63
64
65
66
67
68
69
70
71
#include "landscapesculpttool.h"
bool LandscapeSculptTool::InsideCircleChecker::isInside(const QVector3D &pos) const
{
return m_squaredToolRadius >=
//qPow(pos.x() - m_toolCenter.x(), 2) +
//qPow(pos.z() - m_toolCenter.y(), 2);
(QVector2D(pos.x(), pos.z()) - m_toolCenter).lengthSquared();
}
void LandscapeSculptTool::updateLandscapeSculptToolCenter(QVector2D center)
{
m_center = center;
}
LandscapeSculptTool &LandscapeSculptTool::Instance()
{
static LandscapeSculptTool landscapeSculptTool;
return landscapeSculptTool;
}
QVector2D LandscapeSculptTool::getCenter() const
{
return m_center;
}
float LandscapeSculptTool::getRadius() const
{
return m_radius;
}
void LandscapeSculptTool::setCenter(QVector2D center)
{
m_center = center;
}
void LandscapeSculptTool::setRadius(float size)
{
m_radius = size;
}
float LandscapeSculptTool::getToolStrength() const
{
return m_toolStrenght;
}
void LandscapeSculptTool::setToolStrength(float toolStrength)
{
m_toolStrenght = toolStrength;
}
float LandscapeSculptTool::getBrushFalloff() const
{
return m_brushFalloff;
}
void LandscapeSculptTool::setBryshFalloff(float brushFalloff)
{
m_brushFalloff = brushFalloff;
}
float LandscapeSculptTool::getKoefDependsFromLen(const QVector3D & pos) const
{
float falloffRadius = m_radius * m_brushFalloff;
float lenFromPointToCenter = (QVector2D(pos.x(), pos.z()) - m_center).length();
return 1.0f - qMax(lenFromPointToCenter - falloffRadius, 0.0f) / (m_radius - falloffRadius);
}