summaryrefslogtreecommitdiff
path: root/modules/csg/csg_shape.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/csg/csg_shape.cpp')
-rw-r--r--modules/csg/csg_shape.cpp72
1 files changed, 35 insertions, 37 deletions
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 1ed48a573c..d38ddf3f90 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -156,7 +156,7 @@ CSGBrush *CSGShape3D::_get_brush() {
if (brush) {
memdelete(brush);
}
- brush = NULL;
+ brush = nullptr;
CSGBrush *n = _build_brush();
@@ -296,20 +296,18 @@ void CSGShape3D::_update_shape() {
int mat = n->faces[i].material;
ERR_CONTINUE(mat < -1 || mat >= face_count.size());
int idx = mat == -1 ? face_count.size() - 1 : mat;
- if (n->faces[i].smooth) {
- Plane p(n->faces[i].vertices[0], n->faces[i].vertices[1], n->faces[i].vertices[2]);
+ Plane p(n->faces[i].vertices[0], n->faces[i].vertices[1], n->faces[i].vertices[2]);
- for (int j = 0; j < 3; j++) {
- Vector3 v = n->faces[i].vertices[j];
- Vector3 add;
- if (vec_map.lookup(v, add)) {
- add += p.normal;
- } else {
- add = p.normal;
- }
- vec_map.set(v, add);
+ for (int j = 0; j < 3; j++) {
+ Vector3 v = n->faces[i].vertices[j];
+ Vector3 add;
+ if (vec_map.lookup(v, add)) {
+ add += p.normal;
+ } else {
+ add = p.normal;
}
+ vec_map.set(v, add);
}
face_count.write[idx]++;
@@ -427,7 +425,7 @@ void CSGShape3D::_update_shape() {
mkif.m_getPosition = mikktGetPosition;
mkif.m_getTexCoord = mikktGetTexCoord;
mkif.m_setTSpace = mikktSetTSpaceDefault;
- mkif.m_setTSpaceBasic = NULL;
+ mkif.m_setTSpaceBasic = nullptr;
SMikkTSpaceContext msc;
msc.m_pInterface = &mkif;
@@ -536,7 +534,7 @@ void CSGShape3D::_notification(int p_what) {
if (parent)
parent->_make_dirty();
- parent = NULL;
+ parent = nullptr;
if (use_collision && is_root_shape() && root_collision_instance.is_valid()) {
PhysicsServer3D::get_singleton()->free(root_collision_instance);
@@ -636,8 +634,8 @@ void CSGShape3D::_bind_methods() {
CSGShape3D::CSGShape3D() {
operation = OPERATION_UNION;
- parent = NULL;
- brush = NULL;
+ parent = nullptr;
+ brush = nullptr;
dirty = false;
snap = 0.001;
use_collision = false;
@@ -650,14 +648,14 @@ CSGShape3D::CSGShape3D() {
CSGShape3D::~CSGShape3D() {
if (brush) {
memdelete(brush);
- brush = NULL;
+ brush = nullptr;
}
}
//////////////////////////////////
CSGBrush *CSGCombiner3D::_build_brush() {
- return NULL; //does not build anything
+ return nullptr; //does not build anything
}
CSGCombiner3D::CSGCombiner3D() {
@@ -713,7 +711,7 @@ CSGPrimitive3D::CSGPrimitive3D() {
CSGBrush *CSGMesh3D::_build_brush() {
if (!mesh.is_valid())
- return NULL;
+ return nullptr;
Vector<Vector3> vertices;
Vector<bool> smooth;
@@ -731,7 +729,7 @@ CSGBrush *CSGMesh3D::_build_brush() {
if (arrays.size() == 0) {
_make_dirty();
- ERR_FAIL_COND_V(arrays.size() == 0, NULL);
+ ERR_FAIL_COND_V(arrays.size() == 0, nullptr);
}
Vector<Vector3> avertices = arrays[Mesh::ARRAY_VERTEX];
@@ -741,13 +739,13 @@ CSGBrush *CSGMesh3D::_build_brush() {
const Vector3 *vr = avertices.ptr();
Vector<Vector3> anormals = arrays[Mesh::ARRAY_NORMAL];
- const Vector3 *nr = NULL;
+ const Vector3 *nr = nullptr;
if (anormals.size()) {
nr = anormals.ptr();
}
Vector<Vector2> auvs = arrays[Mesh::ARRAY_TEX_UV];
- const Vector2 *uvr = NULL;
+ const Vector2 *uvr = nullptr;
if (auvs.size()) {
uvr = auvs.ptr();
}
@@ -853,7 +851,7 @@ CSGBrush *CSGMesh3D::_build_brush() {
}
if (vertices.size() == 0)
- return NULL;
+ return nullptr;
return _create_brush_from_arrays(vertices, uvs, smooth, materials);
}
@@ -1535,7 +1533,7 @@ CSGBrush *CSGTorus3D::_build_brush() {
float max_radius = outer_radius;
if (min_radius == max_radius)
- return NULL; //sorry, can't
+ return nullptr; //sorry, can't
if (min_radius > max_radius) {
SWAP(min_radius, max_radius);
@@ -1760,7 +1758,7 @@ CSGBrush *CSGPolygon3D::_build_brush() {
// set our bounding box
if (polygon.size() < 3)
- return NULL;
+ return nullptr;
Vector<Point2> final_polygon = polygon;
@@ -1771,9 +1769,9 @@ CSGBrush *CSGPolygon3D::_build_brush() {
Vector<int> triangles = Geometry::triangulate_polygon(final_polygon);
if (triangles.size() < 3)
- return NULL;
+ return nullptr;
- Path3D *path = NULL;
+ Path3D *path = nullptr;
Ref<Curve3D> curve;
// get bounds for our polygon
@@ -1796,32 +1794,32 @@ CSGBrush *CSGPolygon3D::_build_brush() {
if (mode == MODE_PATH) {
if (!has_node(path_node))
- return NULL;
+ return nullptr;
Node *n = get_node(path_node);
if (!n)
- return NULL;
+ return nullptr;
path = Object::cast_to<Path3D>(n);
if (!path)
- return NULL;
+ return nullptr;
if (path != path_cache) {
if (path_cache) {
path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
- path_cache = NULL;
+ path_cache = nullptr;
}
path_cache = path;
path_cache->connect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
path_cache->connect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
- path_cache = NULL;
+ path_cache = nullptr;
}
curve = path->get_curve();
if (curve.is_null())
- return NULL;
+ return nullptr;
if (curve->get_baked_length() <= 0)
- return NULL;
+ return nullptr;
}
CSGBrush *brush = memnew(CSGBrush);
@@ -2232,7 +2230,7 @@ void CSGPolygon3D::_notification(int p_what) {
if (path_cache) {
path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
- path_cache = NULL;
+ path_cache = nullptr;
}
}
}
@@ -2257,7 +2255,7 @@ void CSGPolygon3D::_path_changed() {
}
void CSGPolygon3D::_path_exited() {
- path_cache = NULL;
+ path_cache = nullptr;
}
void CSGPolygon3D::_bind_methods() {
@@ -2483,5 +2481,5 @@ CSGPolygon3D::CSGPolygon3D() {
path_local = false;
path_continuous_u = false;
path_joined = false;
- path_cache = NULL;
+ path_cache = nullptr;
}