summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/csg/csg.cpp28
-rw-r--r--modules/csg/csg.h2
-rw-r--r--modules/csg/csg_shape.cpp255
-rw-r--r--modules/csg/csg_shape.h27
-rw-r--r--modules/gdnative/SCsub4
-rw-r--r--modules/gdscript/gdscript_editor.cpp26
-rw-r--r--modules/gdscript/gdscript_function.cpp2
-rw-r--r--modules/gdscript/gdscript_parser.cpp58
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp4
-rw-r--r--modules/mono/config.py4
-rw-r--r--modules/mono/csharp_script.cpp2
-rw-r--r--modules/mono/editor/bindings_generator.cpp167
-rw-r--r--modules/mono/editor/bindings_generator.h43
-rw-r--r--modules/mono/mono_reg_utils.py2
-rw-r--r--modules/mono/utils/mono_reg_utils.cpp2
-rw-r--r--modules/pvr/texture_loader_pvr.cpp4
-rw-r--r--modules/visual_script/register_types.cpp2
-rw-r--r--modules/visual_script/visual_script.cpp1
-rw-r--r--modules/visual_script/visual_script.h2
-rw-r--r--modules/visual_script/visual_script_expression.cpp7
-rw-r--r--modules/websocket/lws_peer.cpp9
21 files changed, 341 insertions, 310 deletions
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp
index f399466fe5..c1fe11d6aa 100644
--- a/modules/csg/csg.cpp
+++ b/modules/csg/csg.cpp
@@ -409,6 +409,9 @@ void CSGBrushOperation::BuildPoly::clip(const CSGBrush *p_brush, int p_face, Mes
//transform A points to 2D
+ if (segment[0].distance_to(segment[1]) < CMP_EPSILON)
+ return; //too small
+
_clip_segment(p_brush, p_face, segment, mesh_merge, p_for_B);
}
@@ -586,8 +589,6 @@ void CSGBrushOperation::_add_poly_points(const BuildPoly &p_poly, int p_edge, in
edge_stack.push_back(es);
}
- int limit = p_poly.points.size() * 4;
-
//attempt to empty the stack.
while (edge_stack.size()) {
@@ -608,7 +609,9 @@ void CSGBrushOperation::_add_poly_points(const BuildPoly &p_poly, int p_edge, in
edge_process[e.edge] = true; //mark as processed
- while (to_point != e.prev_point) {
+ int limit = p_poly.points.size() * 4; //avoid infinite recursion
+
+ while (to_point != e.prev_point && limit) {
Vector2 segment[2] = { p_poly.points[prev_point].point, p_poly.points[to_point].point };
@@ -618,6 +621,9 @@ void CSGBrushOperation::_add_poly_points(const BuildPoly &p_poly, int p_edge, in
t2d[1] = Vector2(-t2d[0].y, t2d[0].x); // use as tangent
t2d[2] = segment[1]; //origin
+ if (t2d.basis_determinant() == 0)
+ break; //abort poly
+
t2d.affine_invert();
//push all edges found here, they will be sorted by minimum angle later.
@@ -674,6 +680,8 @@ void CSGBrushOperation::_add_poly_points(const BuildPoly &p_poly, int p_edge, in
to_point = next_point;
edge_process[next_edge] = true; //mark this edge as processed
current_edge = next_edge;
+
+ limit--;
}
//if more than 2 points were added to the polygon, add it to the list of polygons.
@@ -696,7 +704,9 @@ void CSGBrushOperation::_add_poly_outline(const BuildPoly &p_poly, int p_from_po
int prev_point = p_from_point;
int to_point = p_to_point;
- while (to_point != p_from_point) {
+ int limit = p_poly.points.size() * 4; //avoid infinite recursion
+
+ while (to_point != p_from_point && limit) {
Vector2 segment[2] = { p_poly.points[prev_point].point, p_poly.points[to_point].point };
//again create a transform to compute the angle.
@@ -704,6 +714,10 @@ void CSGBrushOperation::_add_poly_outline(const BuildPoly &p_poly, int p_from_po
t2d[0] = (segment[1] - segment[0]).normalized(); //use as Y
t2d[1] = Vector2(-t2d[0].y, t2d[0].x); // use as tangent
t2d[2] = segment[1]; //origin
+
+ if (t2d.basis_determinant() == 0)
+ break; //abort poly
+
t2d.affine_invert();
float max_angle;
@@ -731,6 +745,8 @@ void CSGBrushOperation::_add_poly_outline(const BuildPoly &p_poly, int p_from_po
r_outline.push_back(to_point);
prev_point = to_point;
to_point = next_point_angle;
+
+ limit--;
}
}
@@ -1216,7 +1232,7 @@ void CSGBrushOperation::MeshMerge::mark_inside_faces() {
center /= 3.0;
Plane plane(points[faces[i].points[0]], points[faces[i].points[1]], points[faces[i].points[2]]);
- Vector3 target = center + plane.normal * max_distance;
+ Vector3 target = center + plane.normal * max_distance + Vector3(0.0001234, 0.000512, 0.00013423); //reduce chance of edge hits by doing a small increment
int intersections = _bvh_count_intersections(bvh, max_depth, max_alloc - 1, center, target, i);
@@ -1239,7 +1255,7 @@ void CSGBrushOperation::MeshMerge::add_face(const Vector3 &p_a, const Vector3 &p
vk.z = int((double(src_points[i].z) + double(vertex_snap) * 0.31234) / double(vertex_snap));
int res;
- if (snap_cache.lookup(vk, &res)) {
+ if (snap_cache.lookup(vk, res)) {
indices[i] = res;
} else {
indices[i] = points.size();
diff --git a/modules/csg/csg.h b/modules/csg/csg.h
index d89e542b5e..bb67e1fb36 100644
--- a/modules/csg/csg.h
+++ b/modules/csg/csg.h
@@ -108,7 +108,7 @@ struct CSGBrushOperation {
}
};
- OAHashMap<VertexKey, int, 64, VertexKeyHash> snap_cache;
+ OAHashMap<VertexKey, int, VertexKeyHash> snap_cache;
Vector<Vector3> points;
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 4da94c3baa..1f2f12f54d 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -34,6 +34,14 @@ bool CSGShape::is_root_shape() const {
return !parent;
}
+void CSGShape::set_snap(float p_snap) {
+ snap = p_snap;
+}
+
+float CSGShape::get_snap() const {
+ return snap;
+}
+
void CSGShape::_make_dirty() {
if (!is_inside_tree())
@@ -60,7 +68,61 @@ CSGBrush *CSGShape::_get_brush() {
memdelete(brush);
}
brush = NULL;
- brush = _build_brush(&node_aabb);
+
+ CSGBrush *n = _build_brush();
+
+ for (int i = 0; i < get_child_count(); i++) {
+
+ CSGShape *child = Object::cast_to<CSGShape>(get_child(i));
+ if (!child)
+ continue;
+ if (!child->is_visible_in_tree())
+ continue;
+
+ CSGBrush *n2 = child->_get_brush();
+ if (!n2)
+ continue;
+ if (!n) {
+ n = memnew(CSGBrush);
+
+ n->copy_from(*n2, child->get_transform());
+
+ } else {
+
+ CSGBrush *nn = memnew(CSGBrush);
+ CSGBrush *nn2 = memnew(CSGBrush);
+ nn2->copy_from(*n2, child->get_transform());
+
+ CSGBrushOperation bop;
+
+ switch (child->get_operation()) {
+ case CSGShape::OPERATION_UNION: bop.merge_brushes(CSGBrushOperation::OPERATION_UNION, *n, *nn2, *nn, snap); break;
+ case CSGShape::OPERATION_INTERSECTION: bop.merge_brushes(CSGBrushOperation::OPERATION_INTERSECTION, *n, *nn2, *nn, snap); break;
+ case CSGShape::OPERATION_SUBTRACTION: bop.merge_brushes(CSGBrushOperation::OPERATION_SUBSTRACTION, *n, *nn2, *nn, snap); break;
+ }
+ memdelete(n);
+ memdelete(nn2);
+ n = nn;
+ }
+ }
+
+ if (n) {
+ AABB aabb;
+ for (int i = 0; i < n->faces.size(); i++) {
+ for (int j = 0; j < 3; j++) {
+ if (i == 0 && j == 0)
+ aabb.position = n->faces[i].vertices[j];
+ else
+ aabb.expand_to(n->faces[i].vertices[j]);
+ }
+ }
+ node_aabb = aabb;
+ } else {
+ node_aabb = AABB();
+ }
+
+ brush = n;
+
dirty = false;
}
@@ -95,7 +157,7 @@ void CSGShape::_update_shape() {
for (int j = 0; j < 3; j++) {
Vector3 v = n->faces[i].vertices[j];
Vector3 add;
- if (vec_map.lookup(v, &add)) {
+ if (vec_map.lookup(v, add)) {
add += p.normal;
} else {
add = p.normal;
@@ -171,7 +233,7 @@ void CSGShape::_update_shape() {
Vector3 normal = p.normal;
- if (n->faces[i].smooth && vec_map.lookup(v, &normal)) {
+ if (n->faces[i].smooth && vec_map.lookup(v, normal)) {
normal.normalize();
}
@@ -226,6 +288,9 @@ AABB CSGShape::get_aabb() const {
PoolVector<Vector3> CSGShape::get_brush_faces() {
ERR_FAIL_COND_V(!is_inside_tree(), PoolVector<Vector3>());
CSGBrush *b = _get_brush();
+ if (!b) {
+ return PoolVector<Vector3>();
+ }
PoolVector<Vector3> faces;
int fc = b->faces.size();
@@ -304,23 +369,6 @@ void CSGShape::_validate_property(PropertyInfo &property) const {
//hide collision if not root
property.usage = PROPERTY_USAGE_NOEDITOR;
}
- if (is_inside_tree() && property.name.begins_with("operation")) {
- //hide operation for first node or root
- if (is_root_shape()) {
- property.usage = PROPERTY_USAGE_NOEDITOR;
- } else {
- for (int i = 0; i < get_parent()->get_child_count(); i++) {
- CSGShape *s = Object::cast_to<CSGShape>(get_parent()->get_child(i));
- if (!s)
- continue;
-
- if (s == this) {
- property.usage = PROPERTY_USAGE_NOEDITOR;
- }
- break;
- }
- }
- }
}
void CSGShape::_bind_methods() {
@@ -334,8 +382,12 @@ void CSGShape::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_collision", "operation"), &CSGShape::set_use_collision);
ClassDB::bind_method(D_METHOD("is_using_collision"), &CSGShape::is_using_collision);
+ ClassDB::bind_method(D_METHOD("set_snap", "snap"), &CSGShape::set_snap);
+ ClassDB::bind_method(D_METHOD("get_snap"), &CSGShape::get_snap);
+
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation", PROPERTY_HINT_ENUM, "Union,Intersection,Subtraction"), "set_operation", "get_operation");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_collision"), "set_use_collision", "is_using_collision");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "snap", PROPERTY_HINT_RANGE, "0.0001,1,0.001"), "set_snap", "get_snap");
BIND_CONSTANT(OPERATION_UNION);
BIND_CONSTANT(OPERATION_INTERSECTION);
@@ -349,6 +401,7 @@ CSGShape::CSGShape() {
parent = NULL;
use_collision = false;
operation = OPERATION_UNION;
+ snap = 0.001;
}
CSGShape::~CSGShape() {
@@ -359,79 +412,12 @@ CSGShape::~CSGShape() {
}
//////////////////////////////////
-CSGBrush *CSGCombiner::_build_brush(AABB *r_aabb) {
-
- CSGBrush *n = NULL;
-
- for (int i = 0; i < get_child_count(); i++) {
-
- CSGShape *child = Object::cast_to<CSGShape>(get_child(i));
- if (!child)
- continue;
- if (!child->is_visible_in_tree())
- continue;
-
- CSGBrush *n2 = child->_get_brush();
- if (!n2)
- continue;
- if (!n) {
- n = memnew(CSGBrush);
-
- n->copy_from(*n2, child->get_transform());
-
- } else {
-
- CSGBrush *nn = memnew(CSGBrush);
- CSGBrush *nn2 = memnew(CSGBrush);
- nn2->copy_from(*n2, child->get_transform());
-
- CSGBrushOperation bop;
-
- switch (child->get_operation()) {
- case CSGShape::OPERATION_UNION: bop.merge_brushes(CSGBrushOperation::OPERATION_UNION, *n, *nn2, *nn, snap); break;
- case CSGShape::OPERATION_INTERSECTION: bop.merge_brushes(CSGBrushOperation::OPERATION_INTERSECTION, *n, *nn2, *nn, snap); break;
- case CSGShape::OPERATION_SUBTRACTION: bop.merge_brushes(CSGBrushOperation::OPERATION_SUBSTRACTION, *n, *nn2, *nn, snap); break;
- }
- memdelete(n);
- memdelete(nn2);
- n = nn;
- }
- }
-
- if (n) {
- AABB aabb;
- for (int i = 0; i < n->faces.size(); i++) {
- for (int j = 0; j < 3; j++) {
- if (i == 0 && j == 0)
- aabb.position = n->faces[i].vertices[j];
- else
- aabb.expand_to(n->faces[i].vertices[j]);
- }
- }
- *r_aabb = aabb;
- } else {
- *r_aabb = AABB();
- }
- return n;
-}
-
-void CSGCombiner::set_snap(float p_snap) {
- snap = p_snap;
-}
-
-float CSGCombiner::get_snap() const {
- return snap;
-}
-
-void CSGCombiner::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_snap", "snap"), &CSGCombiner::set_snap);
- ClassDB::bind_method(D_METHOD("get_snap"), &CSGCombiner::get_snap);
+CSGBrush *CSGCombiner::_build_brush() {
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "snap", PROPERTY_HINT_RANGE, "0.0001,1,0.001"), "set_snap", "get_snap");
+ return NULL; //does not build anything
}
CSGCombiner::CSGCombiner() {
- snap = 0.001;
}
/////////////////////
@@ -481,7 +467,7 @@ CSGPrimitive::CSGPrimitive() {
/////////////////////
-CSGBrush *CSGMesh::_build_brush(AABB *r_aabb) {
+CSGBrush *CSGMesh::_build_brush() {
if (!mesh.is_valid())
return NULL;
@@ -491,8 +477,6 @@ CSGBrush *CSGMesh::_build_brush(AABB *r_aabb) {
PoolVector<Ref<Material> > materials;
PoolVector<Vector2> uvs;
- *r_aabb = AABB();
-
for (int i = 0; i < mesh->get_surface_count(); i++) {
if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
@@ -662,7 +646,7 @@ Ref<Mesh> CSGMesh::get_mesh() {
////////////////////////////////
-CSGBrush *CSGSphere::_build_brush(AABB *r_aabb) {
+CSGBrush *CSGSphere::_build_brush() {
// set our bounding box
@@ -778,9 +762,6 @@ CSGBrush *CSGSphere::_build_brush(AABB *r_aabb) {
brush->build_from_faces(faces, uvs, smooth, materials, invert);
- if (r_aabb) {
- *r_aabb = AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2, radius * 2, radius * 2));
- }
return brush;
}
@@ -867,7 +848,7 @@ CSGSphere::CSGSphere() {
///////////////
-CSGBrush *CSGBox::_build_brush(AABB *r_aabb) {
+CSGBrush *CSGBox::_build_brush() {
// set our bounding box
@@ -969,9 +950,6 @@ CSGBrush *CSGBox::_build_brush(AABB *r_aabb) {
brush->build_from_faces(faces, uvs, smooth, materials, invert);
- if (r_aabb) {
- *r_aabb = AABB(Vector3(-width / 2, -height / 2, -depth / 2), Vector3(width, height, depth));
- }
return brush;
}
@@ -1045,7 +1023,7 @@ CSGBox::CSGBox() {
///////////////
-CSGBrush *CSGCylinder::_build_brush(AABB *r_aabb) {
+CSGBrush *CSGCylinder::_build_brush() {
// set our bounding box
@@ -1178,9 +1156,6 @@ CSGBrush *CSGCylinder::_build_brush(AABB *r_aabb) {
brush->build_from_faces(faces, uvs, smooth, materials, invert);
- if (r_aabb) {
- *r_aabb = AABB(Vector3(-radius, -height / 2, -radius), Vector3(radius * 2, height, radius * 2));
- }
return brush;
}
@@ -1283,7 +1258,7 @@ CSGCylinder::CSGCylinder() {
///////////////
-CSGBrush *CSGTorus::_build_brush(AABB *r_aabb) {
+CSGBrush *CSGTorus::_build_brush() {
// set our bounding box
@@ -1406,10 +1381,6 @@ CSGBrush *CSGTorus::_build_brush(AABB *r_aabb) {
brush->build_from_faces(faces, uvs, smooth, materials, invert);
- if (r_aabb) {
- *r_aabb = AABB(Vector3(-max_radius, -radius, -max_radius), Vector3(max_radius * 2, radius * 2, max_radius * 2));
- }
-
return brush;
}
@@ -1513,14 +1484,20 @@ CSGTorus::CSGTorus() {
///////////////
-CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
+CSGBrush *CSGPolygon::_build_brush() {
// set our bounding box
if (polygon.size() < 3)
return NULL;
- Vector<int> triangles = Geometry::triangulate_polygon(polygon);
+ Vector<Point2> final_polygon = polygon;
+
+ if (Triangulate::get_area(final_polygon) > 0) {
+ final_polygon.invert();
+ }
+
+ Vector<int> triangles = Geometry::triangulate_polygon(final_polygon);
if (triangles.size() < 3)
return NULL;
@@ -1564,12 +1541,12 @@ CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
int face_count;
switch (mode) {
- case MODE_DEPTH: face_count = triangles.size() * 2 / 3 + (polygon.size()) * 2; break;
- case MODE_SPIN: face_count = (spin_degrees < 360 ? triangles.size() * 2 / 3 : 0) + (polygon.size()) * 2 * spin_sides; break;
+ case MODE_DEPTH: face_count = triangles.size() * 2 / 3 + (final_polygon.size()) * 2; break;
+ case MODE_SPIN: face_count = (spin_degrees < 360 ? triangles.size() * 2 / 3 : 0) + (final_polygon.size()) * 2 * spin_sides; break;
case MODE_PATH: {
float bl = curve->get_baked_length();
int splits = MAX(2, Math::ceil(bl / path_interval));
- face_count = triangles.size() * 2 / 3 + splits * polygon.size() * 2;
+ face_count = triangles.size() * 2 / 3 + splits * final_polygon.size() * 2;
} break;
}
@@ -1609,7 +1586,7 @@ CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
for (int j = 0; j < triangles.size(); j += 3) {
for (int k = 0; k < 3; k++) {
int src[3] = { 0, i == 0 ? 1 : 2, i == 0 ? 2 : 1 };
- Vector2 p = polygon[triangles[j + src[k]]];
+ Vector2 p = final_polygon[triangles[j + src[k]]];
Vector3 v = Vector3(p.x, p.y, 0);
if (i == 0) {
v.z -= depth;
@@ -1625,15 +1602,15 @@ CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
}
//add triangles for depth
- for (int i = 0; i < polygon.size(); i++) {
+ for (int i = 0; i < final_polygon.size(); i++) {
- int i_n = (i + 1) % polygon.size();
+ int i_n = (i + 1) % final_polygon.size();
Vector3 v[4] = {
- Vector3(polygon[i].x, polygon[i].y, -depth),
- Vector3(polygon[i_n].x, polygon[i_n].y, -depth),
- Vector3(polygon[i_n].x, polygon[i_n].y, 0),
- Vector3(polygon[i].x, polygon[i].y, 0),
+ Vector3(final_polygon[i].x, final_polygon[i].y, -depth),
+ Vector3(final_polygon[i_n].x, final_polygon[i_n].y, -depth),
+ Vector3(final_polygon[i_n].x, final_polygon[i_n].y, 0),
+ Vector3(final_polygon[i].x, final_polygon[i].y, 0),
};
Vector2 u[4] = {
@@ -1689,15 +1666,15 @@ CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
Vector3 normali_n = Vector3(Math::cos(angi_n), 0, Math::sin(angi_n));
//add triangles for depth
- for (int j = 0; j < polygon.size(); j++) {
+ for (int j = 0; j < final_polygon.size(); j++) {
- int j_n = (j + 1) % polygon.size();
+ int j_n = (j + 1) % final_polygon.size();
Vector3 v[4] = {
- Vector3(normali.x * polygon[j].x, polygon[j].y, normali.z * polygon[j].x),
- Vector3(normali.x * polygon[j_n].x, polygon[j_n].y, normali.z * polygon[j_n].x),
- Vector3(normali_n.x * polygon[j_n].x, polygon[j_n].y, normali_n.z * polygon[j_n].x),
- Vector3(normali_n.x * polygon[j].x, polygon[j].y, normali_n.z * polygon[j].x),
+ Vector3(normali.x * final_polygon[j].x, final_polygon[j].y, normali.z * final_polygon[j].x),
+ Vector3(normali.x * final_polygon[j_n].x, final_polygon[j_n].y, normali.z * final_polygon[j_n].x),
+ Vector3(normali_n.x * final_polygon[j_n].x, final_polygon[j_n].y, normali_n.z * final_polygon[j_n].x),
+ Vector3(normali_n.x * final_polygon[j].x, final_polygon[j].y, normali_n.z * final_polygon[j].x),
};
Vector2 u[4] = {
@@ -1743,7 +1720,7 @@ CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
for (int j = 0; j < triangles.size(); j += 3) {
for (int k = 0; k < 3; k++) {
int src[3] = { 0, 2, 1 };
- Vector2 p = polygon[triangles[j + src[k]]];
+ Vector2 p = final_polygon[triangles[j + src[k]]];
Vector3 v = Vector3(p.x, p.y, 0);
facesw[face * 3 + k] = v;
}
@@ -1760,7 +1737,7 @@ CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
for (int j = 0; j < triangles.size(); j += 3) {
for (int k = 0; k < 3; k++) {
int src[3] = { 0, 1, 2 };
- Vector2 p = polygon[triangles[j + src[k]]];
+ Vector2 p = final_polygon[triangles[j + src[k]]];
Vector3 v = Vector3(normali_n.x * p.x, p.y, normali_n.z * p.x);
facesw[face * 3 + k] = v;
}
@@ -1822,15 +1799,15 @@ CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
if (i > 0) {
//put triangles where they belong
//add triangles for depth
- for (int j = 0; j < polygon.size(); j++) {
+ for (int j = 0; j < final_polygon.size(); j++) {
- int j_n = (j + 1) % polygon.size();
+ int j_n = (j + 1) % final_polygon.size();
Vector3 v[4] = {
- prev_xf.xform(Vector3(polygon[j].x, polygon[j].y, 0)),
- prev_xf.xform(Vector3(polygon[j_n].x, polygon[j_n].y, 0)),
- xf.xform(Vector3(polygon[j_n].x, polygon[j_n].y, 0)),
- xf.xform(Vector3(polygon[j].x, polygon[j].y, 0)),
+ prev_xf.xform(Vector3(final_polygon[j].x, final_polygon[j].y, 0)),
+ prev_xf.xform(Vector3(final_polygon[j_n].x, final_polygon[j_n].y, 0)),
+ xf.xform(Vector3(final_polygon[j_n].x, final_polygon[j_n].y, 0)),
+ xf.xform(Vector3(final_polygon[j].x, final_polygon[j].y, 0)),
};
Vector2 u[4] = {
@@ -1877,7 +1854,7 @@ CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
for (int j = 0; j < triangles.size(); j += 3) {
for (int k = 0; k < 3; k++) {
int src[3] = { 0, 1, 2 };
- Vector2 p = polygon[triangles[j + src[k]]];
+ Vector2 p = final_polygon[triangles[j + src[k]]];
Vector3 v = Vector3(p.x, p.y, 0);
facesw[face * 3 + k] = xf.xform(v);
}
@@ -1894,7 +1871,7 @@ CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
for (int j = 0; j < triangles.size(); j += 3) {
for (int k = 0; k < 3; k++) {
int src[3] = { 0, 2, 1 };
- Vector2 p = polygon[triangles[j + src[k]]];
+ Vector2 p = final_polygon[triangles[j + src[k]]];
Vector3 v = Vector3(p.x, p.y, 0);
facesw[face * 3 + k] = xf.xform(v);
}
@@ -1926,10 +1903,6 @@ CSGBrush *CSGPolygon::_build_brush(AABB *r_aabb) {
brush->build_from_faces(faces, uvs, smooth, materials, invert);
- if (r_aabb) {
- *r_aabb = aabb;
- }
-
return brush;
}
diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h
index 24d5dfb29a..c1d2cce606 100644
--- a/modules/csg/csg_shape.h
+++ b/modules/csg/csg_shape.h
@@ -27,6 +27,7 @@ private:
AABB node_aabb;
bool dirty;
+ float snap;
bool use_collision;
Ref<ConcavePolygonShape> root_collision_shape;
@@ -59,7 +60,7 @@ private:
protected:
void _notification(int p_what);
- virtual CSGBrush *_build_brush(AABB *r_aabb) = 0;
+ virtual CSGBrush *_build_brush() = 0;
void _make_dirty();
static void _bind_methods();
@@ -81,6 +82,9 @@ public:
void set_use_collision(bool p_enable);
bool is_using_collision() const;
+ void set_snap(float p_snap);
+ float get_snap() const;
+
bool is_root_shape() const;
CSGShape();
~CSGShape();
@@ -91,16 +95,9 @@ VARIANT_ENUM_CAST(CSGShape::Operation)
class CSGCombiner : public CSGShape {
GDCLASS(CSGCombiner, CSGShape)
private:
- float snap;
- virtual CSGBrush *_build_brush(AABB *r_aabb);
-
-protected:
- static void _bind_methods();
+ virtual CSGBrush *_build_brush();
public:
- void set_snap(float p_snap);
- float get_snap() const;
-
CSGCombiner();
};
@@ -124,7 +121,7 @@ public:
class CSGMesh : public CSGPrimitive {
GDCLASS(CSGMesh, CSGPrimitive)
- virtual CSGBrush *_build_brush(AABB *r_aabb);
+ virtual CSGBrush *_build_brush();
Ref<Mesh> mesh;
@@ -141,7 +138,7 @@ public:
class CSGSphere : public CSGPrimitive {
GDCLASS(CSGSphere, CSGPrimitive)
- virtual CSGBrush *_build_brush(AABB *r_aabb);
+ virtual CSGBrush *_build_brush();
Ref<Material> material;
bool smooth_faces;
@@ -174,7 +171,7 @@ public:
class CSGBox : public CSGPrimitive {
GDCLASS(CSGBox, CSGPrimitive)
- virtual CSGBrush *_build_brush(AABB *r_aabb);
+ virtual CSGBrush *_build_brush();
Ref<Material> material;
float width;
@@ -203,7 +200,7 @@ public:
class CSGCylinder : public CSGPrimitive {
GDCLASS(CSGCylinder, CSGPrimitive)
- virtual CSGBrush *_build_brush(AABB *r_aabb);
+ virtual CSGBrush *_build_brush();
Ref<Material> material;
float radius;
@@ -240,7 +237,7 @@ public:
class CSGTorus : public CSGPrimitive {
GDCLASS(CSGTorus, CSGPrimitive)
- virtual CSGBrush *_build_brush(AABB *r_aabb);
+ virtual CSGBrush *_build_brush();
Ref<Material> material;
float inner_radius;
@@ -292,7 +289,7 @@ public:
};
private:
- virtual CSGBrush *_build_brush(AABB *r_aabb);
+ virtual CSGBrush *_build_brush();
Vector<Vector2> polygon;
Ref<Material> material;
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index acfb83bc10..8654ef3d82 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -275,8 +275,8 @@ if ARGUMENTS.get('gdnative_wrapper', False):
if gd_wrapper_env['use_lto']:
if not env.msvc:
- gd_wrapper_env.Append(CCFLAGS=['--no-lto'])
- gd_wrapper_env.Append(LINKFLAGS=['--no-lto'])
+ gd_wrapper_env.Append(CCFLAGS=['-fno-lto'])
+ gd_wrapper_env.Append(LINKFLAGS=['-fno-lto'])
else:
gd_wrapper_env.Append(CCFLAGS=['/GL-'])
gd_wrapper_env.Append(LINKFLAGS=['/LTCG:OFF'])
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 0d52f0a995..87e1276492 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -61,7 +61,7 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str
"# var b = \"textvar\"\n\n" +
"func _ready():\n" +
"%TS%# Called when the node is added to the scene for the first time.\n" +
- "%TS%# Initialization here\n" +
+ "%TS%# Initialization here.\n" +
"%TS%pass\n\n" +
"#func _process(delta):\n" +
"#%TS%# Called every frame. Delta is time since last frame.\n" +
@@ -430,6 +430,9 @@ struct GDScriptCompletionIdentifier {
Ref<GDScript> script;
Variant::Type type;
Variant value; //im case there is a value, also return it
+
+ GDScriptCompletionIdentifier() :
+ type(Variant::NIL) {}
};
static GDScriptCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) {
@@ -551,9 +554,7 @@ static Ref<Reference> _get_parent_class(GDScriptCompletionContext &context) {
static GDScriptCompletionIdentifier _get_native_class(GDScriptCompletionContext &context) {
- //eeh...
GDScriptCompletionIdentifier id;
- id.type = Variant::NIL;
REF pc = _get_parent_class(context);
if (!pc.is_valid()) {
@@ -1521,6 +1522,13 @@ static void _find_identifiers(GDScriptCompletionContext &context, int p_line, bo
result.insert(_type_names[i]);
}
+ List<String> reserved_words;
+ GDScriptLanguage::get_singleton()->get_reserved_words(&reserved_words);
+
+ for (List<String>::Element *E = reserved_words.front(); E; E = E->next()) {
+ result.insert(E->get());
+ }
+
//autoload singletons
List<PropertyInfo> props;
ProjectSettings::get_singleton()->get_property_list(&props);
@@ -2641,6 +2649,18 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
context.function = p.get_completion_function();
context.base = p_owner;
context.base_path = p_base_path;
+
+ if (context._class && context._class->extends_class.size() > 0) {
+ bool success = false;
+ ClassDB::get_integer_constant(context._class->extends_class[0], p_symbol, &success);
+ if (success) {
+ r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.class_name = context._class->extends_class[0];
+ r_result.class_member = p_symbol;
+ return OK;
+ }
+ }
+
bool isfunction = false;
switch (p.get_completion_type()) {
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index d32ce25d3c..1c5b8187ca 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -1311,9 +1311,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GDScriptLanguage::get_singleton()->script_frame_time += time_taken - function_call_time;
}
-#endif
if (ScriptDebugger::get_singleton())
GDScriptLanguage::get_singleton()->exit_function();
+#endif
if (_stack_size) {
//free stack
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 774e9e62ee..e7b0700e76 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -3440,6 +3440,22 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
tokenizer->advance();
+
+ String hint_prefix = "";
+ bool is_arrayed = false;
+
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE &&
+ tokenizer->get_token_type() == Variant::ARRAY &&
+ tokenizer->get_token(1) == GDScriptTokenizer::TK_COMMA) {
+ tokenizer->advance(); // Array
+ tokenizer->advance(); // Comma
+ if (is_arrayed) {
+ hint_prefix += itos(Variant::ARRAY) + ":";
+ } else {
+ is_arrayed = true;
+ }
+ }
+
if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
Variant::Type type = tokenizer->get_token_type();
@@ -3455,28 +3471,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
current_export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
tokenizer->advance();
- String hint_prefix = "";
-
- if (type == Variant::ARRAY && tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
- tokenizer->advance();
-
- while (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
- type = tokenizer->get_token_type();
-
- tokenizer->advance();
-
- if (type == Variant::ARRAY) {
- hint_prefix += itos(Variant::ARRAY) + ":";
- if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
- tokenizer->advance();
- }
- } else {
- hint_prefix += itos(type);
- break;
- }
- }
- }
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
// hint expected next!
tokenizer->advance();
@@ -3830,13 +3824,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
} break;
}
}
- if (current_export.type == Variant::ARRAY && !hint_prefix.empty()) {
- if (current_export.hint) {
- hint_prefix += "/" + itos(current_export.hint);
- }
- current_export.hint_string = hint_prefix + ":" + current_export.hint_string;
- current_export.hint = PROPERTY_HINT_NONE;
- }
} else {
@@ -3923,6 +3910,16 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
return;
}
+ if (is_arrayed) {
+ hint_prefix += itos(current_export.type);
+ if (current_export.hint) {
+ hint_prefix += "/" + itos(current_export.hint);
+ }
+ current_export.hint_string = hint_prefix + ":" + current_export.hint_string;
+ current_export.hint = PROPERTY_HINT_TYPE_STRING;
+ current_export.type = Variant::ARRAY;
+ }
+
tokenizer->advance();
}
@@ -4090,7 +4087,8 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
member._export.type=Variant::DICTIONARY;
- } else*/ {
+ } else*/
+ {
if (subexpr->type != Node::TYPE_CONSTANT) {
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index f523eef895..4b96824dca 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -1154,9 +1154,9 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
for (int k = 0; k < 3; k++) {
if (i < 3)
- face_points[j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1);
+ face_points[j][(i + k) % 3] = v[k];
else
- face_points[3 - j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1);
+ face_points[3 - j][(i + k) % 3] = -v[k];
}
}
diff --git a/modules/mono/config.py b/modules/mono/config.py
index 18da468bba..18d9c67795 100644
--- a/modules/mono/config.py
+++ b/modules/mono/config.py
@@ -85,7 +85,7 @@ def configure(env):
if not os.path.isfile(os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix)):
raise RuntimeError('Could not find static mono library in: ' + mono_lib_path)
- if os.getenv('VCINSTALLDIR'):
+ if env.msvc:
env.Append(LINKFLAGS=mono_static_lib_name + lib_suffix)
env.Append(LINKFLAGS='Mincore' + lib_suffix)
@@ -100,7 +100,7 @@ def configure(env):
if not mono_lib_name:
raise RuntimeError('Could not find mono library in: ' + mono_lib_path)
- if os.getenv('VCINSTALLDIR'):
+ if env.msvc:
env.Append(LINKFLAGS=mono_lib_name + Environment()['LIBSUFFIX'])
else:
env.Append(LIBS=mono_lib_name)
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index adc5f16f92..bbe245951e 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -305,7 +305,7 @@ Ref<Script> CSharpLanguage::get_template(const String &p_class_name, const Strin
" public override void _Ready()\n"
" {\n"
" // Called every time the node is added to the scene.\n"
- " // Initialization here\n"
+ " // Initialization here.\n"
" \n"
" }\n"
"\n"
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index fadcc4ef57..4c598d4f37 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -248,14 +248,14 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
if (imethod.is_virtual)
continue;
- const TypeInterface *return_type = _get_type_by_name_or_placeholder(imethod.return_type);
+ const TypeInterface *return_type = _get_type_or_placeholder(imethod.return_type);
String im_sig;
String im_unique_sig;
if (p_itype.is_object_type) {
im_sig += "IntPtr " CS_PARAM_METHODBIND ", ";
- im_unique_sig += imethod.return_type.operator String() + ",IntPtr,IntPtr";
+ im_unique_sig += imethod.return_type.cname.operator String() + ",IntPtr,IntPtr";
}
im_sig += "IntPtr " CS_PARAM_INSTANCE;
@@ -263,7 +263,7 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
// Get arguments information
int i = 0;
for (const List<ArgumentInterface>::Element *F = imethod.arguments.front(); F; F = F->next()) {
- const TypeInterface *arg_type = _get_type_by_name_or_placeholder(F->get().type);
+ const TypeInterface *arg_type = _get_type_or_placeholder(F->get().type);
im_sig += ", ";
im_sig += arg_type->im_type_in;
@@ -1069,12 +1069,12 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
}
if (getter && setter) {
- ERR_FAIL_COND_V(getter->return_type != setter->arguments.back()->get().type, ERR_BUG);
+ ERR_FAIL_COND_V(getter->return_type.cname != setter->arguments.back()->get().type.cname, ERR_BUG);
}
- StringName proptype_name = getter ? getter->return_type : setter->arguments.back()->get().type;
+ const TypeReference &proptype_name = getter ? getter->return_type : setter->arguments.back()->get().type;
- const TypeInterface *prop_itype = _get_type_by_name_or_null(proptype_name);
+ const TypeInterface *prop_itype = _get_type_or_null(proptype_name);
ERR_FAIL_NULL_V(prop_itype, ERR_BUG); // Property type not found
String prop_proxy_name = escape_csharp_keyword(snake_to_pascal_case(p_iprop.cname));
@@ -1122,9 +1122,9 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
p_output.push_back(getter->proxy_name + "(");
if (p_iprop.index != -1) {
const ArgumentInterface &idx_arg = getter->arguments.front()->get();
- if (idx_arg.type != name_cache.type_int) {
+ if (idx_arg.type.cname != name_cache.type_int) {
// Assume the index parameter is an enum
- const TypeInterface *idx_arg_type = _get_type_by_name_or_null(idx_arg.type);
+ const TypeInterface *idx_arg_type = _get_type_or_null(idx_arg.type);
CRASH_COND(idx_arg_type == NULL);
p_output.push_back("(" + idx_arg_type->proxy_name + ")" + itos(p_iprop.index));
} else {
@@ -1139,9 +1139,9 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
p_output.push_back(setter->proxy_name + "(");
if (p_iprop.index != -1) {
const ArgumentInterface &idx_arg = setter->arguments.front()->get();
- if (idx_arg.type != name_cache.type_int) {
+ if (idx_arg.type.cname != name_cache.type_int) {
// Assume the index parameter is an enum
- const TypeInterface *idx_arg_type = _get_type_by_name_or_null(idx_arg.type);
+ const TypeInterface *idx_arg_type = _get_type_or_null(idx_arg.type);
CRASH_COND(idx_arg_type == NULL);
p_output.push_back("(" + idx_arg_type->proxy_name + ")" + itos(p_iprop.index) + ", ");
} else {
@@ -1158,7 +1158,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterface &p_itype, const BindingsGenerator::MethodInterface &p_imethod, int &p_method_bind_count, List<String> &p_output) {
- const TypeInterface *return_type = _get_type_by_name_or_placeholder(p_imethod.return_type);
+ const TypeInterface *return_type = _get_type_or_placeholder(p_imethod.return_type);
String method_bind_field = "method_bind_" + itos(p_method_bind_count);
@@ -1175,7 +1175,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
// Retrieve information from the arguments
for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) {
const ArgumentInterface &iarg = F->get();
- const TypeInterface *arg_type = _get_type_by_name_or_placeholder(iarg.type);
+ const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type);
// Add the current arguments to the signature
// If the argument has a default value which is not a constant, we will make it Nullable
@@ -1328,21 +1328,19 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
const InternalCall *im_icall = match->value();
String im_call = im_icall->editor_only ? BINDINGS_CLASS_NATIVECALLS_EDITOR : BINDINGS_CLASS_NATIVECALLS;
- im_call += "." + im_icall->name + "(" + icall_params + ");\n";
+ im_call += "." + im_icall->name + "(" + icall_params + ")";
if (p_imethod.arguments.size())
p_output.push_back(cs_in_statements);
if (return_type->cname == name_cache.type_void) {
- p_output.push_back(im_call);
+ p_output.push_back(im_call + ";\n");
} else if (return_type->cs_out.empty()) {
- p_output.push_back("return " + im_call);
+ p_output.push_back("return " + im_call + ";\n");
} else {
- p_output.push_back(return_type->im_type_out);
- p_output.push_back(" " LOCAL_RET " = ");
- p_output.push_back(im_call);
p_output.push_back(INDENT3);
- p_output.push_back(sformat(return_type->cs_out, LOCAL_RET) + "\n");
+ p_output.push_back(sformat(return_type->cs_out, im_call, return_type->cs_type, return_type->im_type_out));
+ p_output.push_back("\n");
}
p_output.push_back(CLOSE_BLOCK_L2);
@@ -1540,9 +1538,9 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
if (p_imethod.is_virtual)
return OK; // Ignore
- bool ret_void = p_imethod.return_type == name_cache.type_void;
+ bool ret_void = p_imethod.return_type.cname == name_cache.type_void;
- const TypeInterface *return_type = _get_type_by_name_or_placeholder(p_imethod.return_type);
+ const TypeInterface *return_type = _get_type_or_placeholder(p_imethod.return_type);
String argc_str = itos(p_imethod.arguments.size());
@@ -1554,7 +1552,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
int i = 0;
for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) {
const ArgumentInterface &iarg = F->get();
- const TypeInterface *arg_type = _get_type_by_name_or_placeholder(iarg.type);
+ const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type);
String c_param_name = "arg" + itos(i + 1);
@@ -1695,42 +1693,49 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
return OK;
}
-const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_by_name_or_null(const StringName &p_cname) {
+const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_null(const TypeReference &p_typeref) {
- const Map<StringName, TypeInterface>::Element *builtin_type_match = builtin_types.find(p_cname);
+ const Map<StringName, TypeInterface>::Element *builtin_type_match = builtin_types.find(p_typeref.cname);
if (builtin_type_match)
return &builtin_type_match->get();
- const OrderedHashMap<StringName, TypeInterface>::Element obj_type_match = obj_types.find(p_cname);
+ const OrderedHashMap<StringName, TypeInterface>::Element obj_type_match = obj_types.find(p_typeref.cname);
if (obj_type_match)
return &obj_type_match.get();
- const Map<StringName, TypeInterface>::Element *enum_match = enum_types.find(p_cname);
+ if (p_typeref.is_enum) {
+ const Map<StringName, TypeInterface>::Element *enum_match = enum_types.find(p_typeref.cname);
- if (enum_match)
- return &enum_match->get();
+ if (enum_match)
+ return &enum_match->get();
+
+ // Enum not found. Most likely because none of its constants were bound, so it's empty. That's fine. Use int instead.
+ const Map<StringName, TypeInterface>::Element *int_match = builtin_types.find(name_cache.type_int);
+ ERR_FAIL_NULL_V(int_match, NULL);
+ return &int_match->get();
+ }
return NULL;
}
-const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_by_name_or_placeholder(const StringName &p_cname) {
+const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_placeholder(const TypeReference &p_typeref) {
- const TypeInterface *found = _get_type_by_name_or_null(p_cname);
+ const TypeInterface *found = _get_type_or_null(p_typeref);
if (found)
return found;
- ERR_PRINTS(String() + "Type not found. Creating placeholder: " + p_cname.operator String());
+ ERR_PRINTS(String() + "Type not found. Creating placeholder: " + p_typeref.cname.operator String());
- const Map<StringName, TypeInterface>::Element *match = placeholder_types.find(p_cname);
+ const Map<StringName, TypeInterface>::Element *match = placeholder_types.find(p_typeref.cname);
if (match)
return &match->get();
TypeInterface placeholder;
- TypeInterface::create_placeholder_type(placeholder, p_cname);
+ TypeInterface::create_placeholder_type(placeholder, p_typeref.cname);
return &placeholder_types.insert(placeholder.cname, placeholder)->get();
}
@@ -1874,7 +1879,7 @@ void BindingsGenerator::_populate_object_type_interfaces() {
// The method Object.free is registered as a virtual method, but without the virtual flag.
// This is because this method is not supposed to be overridden, but called.
// We assume the return type is void.
- imethod.return_type = name_cache.type_void;
+ imethod.return_type.cname = name_cache.type_void;
// Actually, more methods like this may be added in the future,
// which could actually will return something different.
@@ -1889,21 +1894,22 @@ void BindingsGenerator::_populate_object_type_interfaces() {
} else {
ERR_PRINTS("Missing MethodBind for non-virtual method: " + itype.name + "." + imethod.name);
}
- } else if (return_info.type == Variant::INT && return_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { // TODO redundant?
- imethod.return_type = return_info.class_name;
+ } else if (return_info.type == Variant::INT && return_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
+ imethod.return_type.cname = return_info.class_name;
+ imethod.return_type.is_enum = true;
} else if (return_info.class_name != StringName()) {
- imethod.return_type = return_info.class_name;
+ imethod.return_type.cname = return_info.class_name;
} else if (return_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
- imethod.return_type = return_info.hint_string;
+ imethod.return_type.cname = return_info.hint_string;
} else if (return_info.type == Variant::NIL && return_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
- imethod.return_type = name_cache.type_Variant;
+ imethod.return_type.cname = name_cache.type_Variant;
} else if (return_info.type == Variant::NIL) {
- imethod.return_type = name_cache.type_void;
+ imethod.return_type.cname = name_cache.type_void;
} else {
- imethod.return_type = Variant::get_type_name(return_info.type);
+ imethod.return_type.cname = Variant::get_type_name(return_info.type);
}
- if (!itype.requires_collections && imethod.return_type == name_cache.type_Dictionary)
+ if (!itype.requires_collections && imethod.return_type.cname == name_cache.type_Dictionary)
itype.requires_collections = true;
for (int i = 0; i < argc; i++) {
@@ -1912,21 +1918,22 @@ void BindingsGenerator::_populate_object_type_interfaces() {
ArgumentInterface iarg;
iarg.name = arginfo.name;
- if (arginfo.type == Variant::INT && arginfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { // TODO redundant?
- iarg.type = arginfo.class_name;
+ if (arginfo.type == Variant::INT && arginfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
+ iarg.type.cname = arginfo.class_name;
+ iarg.type.is_enum = true;
} else if (arginfo.class_name != StringName()) {
- iarg.type = arginfo.class_name;
+ iarg.type.cname = arginfo.class_name;
} else if (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) {
- iarg.type = arginfo.hint_string;
+ iarg.type.cname = arginfo.hint_string;
} else if (arginfo.type == Variant::NIL) {
- iarg.type = name_cache.type_Variant;
+ iarg.type.cname = name_cache.type_Variant;
} else {
- iarg.type = Variant::get_type_name(arginfo.type);
+ iarg.type.cname = Variant::get_type_name(arginfo.type);
}
iarg.name = escape_csharp_keyword(snake_to_camel_case(iarg.name));
- if (!itype.requires_collections && iarg.type == name_cache.type_Dictionary)
+ if (!itype.requires_collections && iarg.type.cname == name_cache.type_Dictionary)
itype.requires_collections = true;
if (m && m->has_default_argument(i)) {
@@ -1938,7 +1945,7 @@ void BindingsGenerator::_populate_object_type_interfaces() {
if (imethod.is_vararg) {
ArgumentInterface ivararg;
- ivararg.type = name_cache.type_VarArg;
+ ivararg.type.cname = name_cache.type_VarArg;
ivararg.name = "@args";
imethod.add_argument(ivararg);
}
@@ -2023,17 +2030,11 @@ void BindingsGenerator::_populate_object_type_interfaces() {
itype.enums.push_back(ienum);
TypeInterface enum_itype;
+ enum_itype.is_enum = true;
enum_itype.name = itype.name + "." + String(*k);
enum_itype.cname = StringName(enum_itype.name);
enum_itype.proxy_name = itype.proxy_name + "." + enum_proxy_name;
- enum_itype.c_arg_in = "&%s";
- enum_itype.c_type = "int";
- enum_itype.c_type_in = "int";
- enum_itype.c_type_out = "int";
- enum_itype.cs_type = enum_itype.proxy_name;
- enum_itype.im_type_in = enum_itype.proxy_name;
- enum_itype.im_type_out = enum_itype.proxy_name;
- enum_itype.class_doc = &EditorHelp::get_doc_data()->class_list[enum_itype.proxy_name];
+ TypeInterface::postsetup_enum_type(enum_itype);
enum_types.insert(enum_itype.cname, enum_itype);
}
@@ -2068,7 +2069,7 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg
switch (p_val.get_type()) {
case Variant::NIL:
- if (ClassDB::class_exists(r_iarg.type)) {
+ if (ClassDB::class_exists(r_iarg.type.cname)) {
// Object type
r_iarg.default_argument = "null";
} else {
@@ -2081,7 +2082,7 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg
r_iarg.default_argument = bool(p_val) ? "true" : "false";
break;
case Variant::INT:
- if (r_iarg.type != name_cache.type_int) {
+ if (r_iarg.type.cname != name_cache.type_int) {
r_iarg.default_argument = "(%s)" + r_iarg.default_argument;
}
break;
@@ -2142,7 +2143,7 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg
default: {}
}
- if (r_iarg.def_param_mode == ArgumentInterface::CONSTANT && r_iarg.type == name_cache.type_Variant && r_iarg.default_argument != "null")
+ if (r_iarg.def_param_mode == ArgumentInterface::CONSTANT && r_iarg.type.cname == name_cache.type_Variant && r_iarg.default_argument != "null")
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF;
}
@@ -2161,7 +2162,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.c_arg_in = "&%s_in"; \
itype.c_type_in = m_type_in; \
itype.cs_in = "ref %s"; \
- itype.cs_out = "return (" #m_type ")%0;"; \
+ itype.cs_out = "return (%1)%0;"; \
itype.im_type_out = "object"; \
builtin_types.insert(itype.cname, itype); \
}
@@ -2256,7 +2257,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.c_type_out = itype.c_type + "*";
itype.cs_type = itype.proxy_name;
itype.cs_in = "NodePath." CS_SMETHOD_GETINSTANCE "(%0)";
- itype.cs_out = "return new NodePath(%0);";
+ itype.cs_out = "return new %1(%0);";
itype.im_type_in = "IntPtr";
itype.im_type_out = "IntPtr";
_populate_builtin_type(itype, Variant::NODE_PATH);
@@ -2279,7 +2280,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.c_type_out = itype.c_type + "*";
itype.cs_type = itype.proxy_name;
itype.cs_in = "RID." CS_SMETHOD_GETINSTANCE "(%0)";
- itype.cs_out = "return new RID(%0);";
+ itype.cs_out = "return new %1(%0);";
itype.im_type_in = "IntPtr";
itype.im_type_out = "IntPtr";
_populate_builtin_type(itype, Variant::_RID);
@@ -2408,11 +2409,11 @@ void BindingsGenerator::_populate_builtin_type(TypeInterface &r_itype, Variant::
iarg.name = pi.name;
if (pi.type == Variant::NIL)
- iarg.type = name_cache.type_Variant;
+ iarg.type.cname = name_cache.type_Variant;
else
- iarg.type = Variant::get_type_name(pi.type);
+ iarg.type.cname = Variant::get_type_name(pi.type);
- if (!r_itype.requires_collections && iarg.type == name_cache.type_Dictionary)
+ if (!r_itype.requires_collections && iarg.type.cname == name_cache.type_Dictionary)
r_itype.requires_collections = true;
if ((mi.default_arguments.size() - mi.arguments.size() + i) >= 0)
@@ -2423,12 +2424,12 @@ void BindingsGenerator::_populate_builtin_type(TypeInterface &r_itype, Variant::
if (mi.return_val.type == Variant::NIL) {
if (mi.return_val.name != "")
- imethod.return_type = name_cache.type_Variant;
+ imethod.return_type.cname = name_cache.type_Variant;
} else {
- imethod.return_type = Variant::get_type_name(mi.return_val.type);
+ imethod.return_type.cname = Variant::get_type_name(mi.return_val.type);
}
- if (!r_itype.requires_collections && imethod.return_type == name_cache.type_Dictionary)
+ if (!r_itype.requires_collections && imethod.return_type.cname == name_cache.type_Dictionary)
r_itype.requires_collections = true;
if (r_itype.class_doc) {
@@ -2494,13 +2495,11 @@ void BindingsGenerator::_populate_global_constants() {
EnumInterface &ienum = E->get();
TypeInterface enum_itype;
- enum_itype = TypeInterface::create_value_type(ienum.cname);
- enum_itype.c_arg_in = "&%s";
- enum_itype.c_type = "int";
- enum_itype.c_type_in = "int";
- enum_itype.c_type_out = "int";
- enum_itype.im_type_in = enum_itype.name;
- enum_itype.im_type_out = enum_itype.name;
+ enum_itype.is_enum = true;
+ enum_itype.name = ienum.cname.operator String();
+ enum_itype.cname = ienum.cname;
+ enum_itype.proxy_name = enum_itype.name;
+ TypeInterface::postsetup_enum_type(enum_itype);
enum_types.insert(enum_itype.cname, enum_itype);
ienum.prefix = _determine_enum_prefix(ienum);
@@ -2521,15 +2520,13 @@ void BindingsGenerator::_populate_global_constants() {
hardcoded_enums.push_back("Vector3.Axis");
for (List<StringName>::Element *E = hardcoded_enums.front(); E; E = E->next()) {
// These enums are not generated and must be written manually (e.g.: Vector3.Axis)
- // Here, we are assuming core types do not begin with underscore
+ // Here, we assume core types do not begin with underscore
TypeInterface enum_itype;
- enum_itype = TypeInterface::create_value_type(E->get());
- enum_itype.c_arg_in = "&%s";
- enum_itype.c_type = "int";
- enum_itype.c_type_in = "int";
- enum_itype.c_type_out = "int";
- enum_itype.im_type_in = enum_itype.name;
- enum_itype.im_type_out = enum_itype.name;
+ enum_itype.is_enum = true;
+ enum_itype.name = E->get().operator String();
+ enum_itype.cname = E->get();
+ enum_itype.proxy_name = enum_itype.name;
+ TypeInterface::postsetup_enum_type(enum_itype);
enum_types.insert(enum_itype.cname, enum_itype);
}
}
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index f6194139af..5b33a0e53f 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -81,6 +81,15 @@ class BindingsGenerator {
const DocData::PropertyDoc *prop_doc;
};
+ struct TypeReference {
+ StringName cname;
+ bool is_enum;
+
+ TypeReference() {
+ is_enum = false;
+ }
+ };
+
struct ArgumentInterface {
enum DefaultParamMode {
CONSTANT,
@@ -88,7 +97,8 @@ class BindingsGenerator {
NULLABLE_REF
};
- StringName type;
+ TypeReference type;
+
String name;
String default_argument;
DefaultParamMode def_param_mode;
@@ -110,7 +120,7 @@ class BindingsGenerator {
/**
* [TypeInterface::name] of the return type
*/
- StringName return_type;
+ TypeReference return_type;
/**
* Determines if the method has a variable number of arguments (VarArg)
@@ -146,7 +156,7 @@ class BindingsGenerator {
}
MethodInterface() {
- return_type = BindingsGenerator::get_singleton()->name_cache.type_void;
+ return_type.cname = BindingsGenerator::get_singleton()->name_cache.type_void;
is_vararg = false;
is_virtual = false;
requires_object_call = false;
@@ -175,6 +185,7 @@ class BindingsGenerator {
ClassDB::APIType api_type;
+ bool is_enum;
bool is_object_type;
bool is_singleton;
bool is_reference;
@@ -276,7 +287,9 @@ class BindingsGenerator {
* One or more statements that determine how a variable of this type is returned from a method.
* It must contain the return statement(s).
* Formatting elements:
- * %0 or %s: name of the variable to be returned
+ * %0: internal method call statement
+ * %1: [cs_type] of the return type
+ * %2: [im_type_out] of the return type
*/
String cs_out;
@@ -293,8 +306,6 @@ class BindingsGenerator {
/**
* Type used for the return type of internal call methods.
- * If [cs_out] is not empty and the method return type is not void,
- * it is also used for the type of the return variable.
*/
String im_type_out;
@@ -379,10 +390,24 @@ class BindingsGenerator {
r_itype.im_type_out = r_itype.proxy_name;
}
+ static void postsetup_enum_type(TypeInterface &r_enum_itype) {
+ r_enum_itype.c_arg_in = "&%s";
+ r_enum_itype.c_type = "int";
+ r_enum_itype.c_type_in = "int";
+ r_enum_itype.c_type_out = "int";
+ r_enum_itype.cs_type = r_enum_itype.proxy_name;
+ r_enum_itype.cs_in = "(int)%s";
+ r_enum_itype.cs_out = "return (%1)%0;";
+ r_enum_itype.im_type_in = "int";
+ r_enum_itype.im_type_out = "int";
+ r_enum_itype.class_doc = &EditorHelp::get_doc_data()->class_list[r_enum_itype.proxy_name];
+ }
+
TypeInterface() {
api_type = ClassDB::API_NONE;
+ is_enum = false;
is_object_type = false;
is_singleton = false;
is_reference = false;
@@ -492,6 +517,8 @@ class BindingsGenerator {
return "Ref";
else if (p_type.is_object_type)
return "Obj";
+ else if (p_type.is_enum)
+ return "int";
return p_type.name;
}
@@ -501,8 +528,8 @@ class BindingsGenerator {
void _generate_header_icalls();
void _generate_method_icalls(const TypeInterface &p_itype);
- const TypeInterface *_get_type_by_name_or_null(const StringName &p_cname);
- const TypeInterface *_get_type_by_name_or_placeholder(const StringName &p_cname);
+ const TypeInterface *_get_type_or_null(const TypeReference &p_typeref);
+ const TypeInterface *_get_type_or_placeholder(const TypeReference &p_typeref);
void _default_argument_from_variant(const Variant &p_val, ArgumentInterface &r_iarg);
void _populate_builtin_type(TypeInterface &r_itype, Variant::Type vtype);
diff --git a/modules/mono/mono_reg_utils.py b/modules/mono/mono_reg_utils.py
index 8ddddb3a24..9c188d07a7 100644
--- a/modules/mono/mono_reg_utils.py
+++ b/modules/mono/mono_reg_utils.py
@@ -75,7 +75,7 @@ def find_msbuild_tools_path_reg():
vswhere = os.getenv('PROGRAMFILES')
vswhere += r'\Microsoft Visual Studio\Installer\vswhere.exe'
- vswhere_args = ['-latest', '-requires', 'Microsoft.Component.MSBuild']
+ vswhere_args = ['-latest', '-products', '*', '-requires', 'Microsoft.Component.MSBuild']
try:
lines = subprocess.check_output([vswhere] + vswhere_args).splitlines()
diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp
index 9bb8da8ac0..7b23cd7579 100644
--- a/modules/mono/utils/mono_reg_utils.cpp
+++ b/modules/mono/utils/mono_reg_utils.cpp
@@ -174,6 +174,8 @@ String find_msbuild_tools_path() {
List<String> vswhere_args;
vswhere_args.push_back("-latest");
+ vswhere_args.push_back("-products");
+ vswhere_args.push_back("*");
vswhere_args.push_back("-requires");
vswhere_args.push_back("Microsoft.Component.MSBuild");
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp
index 76c0b969d8..8174bccdb7 100644
--- a/modules/pvr/texture_loader_pvr.cpp
+++ b/modules/pvr/texture_loader_pvr.cpp
@@ -536,8 +536,8 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int
int p_x, p_y;
- int p_modulation[8][16];
- int p_modulation_modes[8][16];
+ int p_modulation[8][16] = { { 0 } };
+ int p_modulation_modes[8][16] = { { 0 } };
int Mod, DoPT;
diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp
index 2809cff362..11401c0460 100644
--- a/modules/visual_script/register_types.cpp
+++ b/modules/visual_script/register_types.cpp
@@ -112,7 +112,9 @@ void register_visual_script_types() {
register_visual_script_expression_node();
#ifdef TOOLS_ENABLED
+ ClassDB::set_current_api(ClassDB::API_EDITOR);
ClassDB::register_class<_VisualScriptEditor>();
+ ClassDB::set_current_api(ClassDB::API_CORE);
vs_editor_singleton = memnew(_VisualScriptEditor);
Engine::get_singleton()->add_singleton(Engine::Singleton("VisualScriptEditor", _VisualScriptEditor::get_singleton()));
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index ef680547ca..03bc4c114a 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -2028,6 +2028,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
function.flow_stack_size = 0;
function.pass_stack_size = 0;
function.node_count = 0;
+
Map<StringName, int> local_var_indices;
if (function.node < 0) {
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index 69bb522173..dad9c68312 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -374,12 +374,10 @@ class VisualScriptInstance : public ScriptInstance {
int node;
int max_stack;
int trash_pos;
- int return_pos;
int flow_stack_size;
int pass_stack_size;
int node_count;
int argument_count;
- bool valid;
};
Map<StringName, Function> functions;
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index 55e2cc5fb5..d5f9d21348 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -455,7 +455,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
break;
}
- if (cchar == '-' || (cchar >= '0' && cchar <= '9')) {
+ if (cchar >= '0' && cchar <= '9') {
//a number
String num;
@@ -466,11 +466,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
#define READING_DONE 4
int reading = READING_INT;
- if (cchar == '-') {
- num += '-';
- cchar = GET_CHAR();
- }
-
CharType c = cchar;
bool exp_sign = false;
bool exp_beg = false;
diff --git a/modules/websocket/lws_peer.cpp b/modules/websocket/lws_peer.cpp
index 8a064fb5a4..3855a39aef 100644
--- a/modules/websocket/lws_peer.cpp
+++ b/modules/websocket/lws_peer.cpp
@@ -35,6 +35,7 @@
// Needed for socket_helpers on Android at least. UNIXes has it, just include if not windows
#if !defined(WINDOWS_ENABLED)
#include <netinet/in.h>
+#include <sys/socket.h>
#endif
#include "drivers/unix/socket_helpers.h"
@@ -190,9 +191,11 @@ IP_Address LWSPeer::get_connected_host() const {
IP_Address ip;
int port = 0;
- socklen_t len;
+ socklen_t len = 0;
struct sockaddr_storage addr;
+
int fd = lws_get_socket_fd(wsi);
+ ERR_FAIL_COND_V(fd == -1, IP_Address());
int ret = getpeername(fd, (struct sockaddr *)&addr, &len);
ERR_FAIL_COND_V(ret != 0, IP_Address());
@@ -209,9 +212,11 @@ uint16_t LWSPeer::get_connected_port() const {
IP_Address ip;
int port = 0;
- socklen_t len;
+ socklen_t len = 0;
struct sockaddr_storage addr;
+
int fd = lws_get_socket_fd(wsi);
+ ERR_FAIL_COND_V(fd == -1, 0);
int ret = getpeername(fd, (struct sockaddr *)&addr, &len);
ERR_FAIL_COND_V(ret != 0, 0);