diff options
Diffstat (limited to 'modules/csg')
-rw-r--r-- | modules/csg/SCsub | 2 | ||||
-rw-r--r-- | modules/csg/csg.h | 1 | ||||
-rw-r--r-- | modules/csg/csg_shape.cpp | 110 | ||||
-rw-r--r-- | modules/csg/doc_classes/CSGShape3D.xml | 5 | ||||
-rw-r--r-- | modules/csg/editor/csg_gizmos.cpp | 10 |
5 files changed, 64 insertions, 64 deletions
diff --git a/modules/csg/SCsub b/modules/csg/SCsub index 55f859db11..1cf9974fc1 100644 --- a/modules/csg/SCsub +++ b/modules/csg/SCsub @@ -7,5 +7,5 @@ env_csg = env_modules.Clone() # Godot source files env_csg.add_source_files(env.modules_sources, "*.cpp") -if env["tools"]: +if env.editor_build: env_csg.add_source_files(env.modules_sources, "editor/*.cpp") diff --git a/modules/csg/csg.h b/modules/csg/csg.h index 738e3d68ea..aae99c52a3 100644 --- a/modules/csg/csg.h +++ b/modules/csg/csg.h @@ -39,7 +39,6 @@ #include "core/object/ref_counted.h" #include "core/templates/list.h" #include "core/templates/oa_hash_map.h" -#include "core/templates/rb_map.h" #include "core/templates/vector.h" #include "scene/resources/material.h" diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 3932c2377f..461960ab26 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -92,13 +92,13 @@ uint32_t CSGShape3D::get_collision_mask() const { void CSGShape3D::set_collision_layer_value(int p_layer_number, bool p_value) { ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive."); - uint32_t collision_layer = get_collision_layer(); + uint32_t layer = get_collision_layer(); if (p_value) { - collision_layer |= 1 << (p_layer_number - 1); + layer |= 1 << (p_layer_number - 1); } else { - collision_layer &= ~(1 << (p_layer_number - 1)); + layer &= ~(1 << (p_layer_number - 1)); } - set_collision_layer(collision_layer); + set_collision_layer(layer); } bool CSGShape3D::get_collision_layer_value(int p_layer_number) const { @@ -690,7 +690,7 @@ CSGCombiner3D::CSGCombiner3D() { ///////////////////// CSGBrush *CSGPrimitive3D::_create_brush_from_arrays(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uv, const Vector<bool> &p_smooth, const Vector<Ref<Material>> &p_materials) { - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); Vector<bool> invert; invert.resize(p_vertices.size() / 3); @@ -701,9 +701,9 @@ CSGBrush *CSGPrimitive3D::_create_brush_from_arrays(const Vector<Vector3> &p_ver w[i] = flip_faces; } } - brush->build_from_faces(p_vertices, p_uv, p_smooth, p_materials, invert); + new_brush->build_from_faces(p_vertices, p_uv, p_smooth, p_materials, invert); - return brush; + return new_brush; } void CSGPrimitive3D::_bind_methods() { @@ -742,7 +742,7 @@ CSGBrush *CSGMesh3D::_build_brush() { Vector<bool> smooth; Vector<Ref<Material>> materials; Vector<Vector2> uvs; - Ref<Material> material = get_material(); + Ref<Material> base_material = get_material(); for (int i = 0; i < mesh->get_surface_count(); i++) { if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { @@ -776,8 +776,8 @@ CSGBrush *CSGMesh3D::_build_brush() { } Ref<Material> mat; - if (material.is_valid()) { - mat = material; + if (base_material.is_valid()) { + mat = base_material; } else { mat = mesh->surface_get_material(i); } @@ -933,12 +933,12 @@ Ref<Mesh> CSGMesh3D::get_mesh() { CSGBrush *CSGSphere3D::_build_brush() { // set our bounding box - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); int face_count = rings * radial_segments * 2 - radial_segments * 2; bool invert_val = get_flip_faces(); - Ref<Material> material = get_material(); + Ref<Material> base_material = get_material(); Vector<Vector3> faces; Vector<Vector2> uvs; @@ -1019,7 +1019,7 @@ CSGBrush *CSGSphere3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } @@ -1036,7 +1036,7 @@ CSGBrush *CSGSphere3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } @@ -1048,9 +1048,9 @@ CSGBrush *CSGSphere3D::_build_brush() { } } - brush->build_from_faces(faces, uvs, smooth, materials, invert); + new_brush->build_from_faces(faces, uvs, smooth, materials, invert); - return brush; + return new_brush; } void CSGSphere3D::_bind_methods() { @@ -1137,12 +1137,12 @@ CSGSphere3D::CSGSphere3D() { CSGBrush *CSGBox3D::_build_brush() { // set our bounding box - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); int face_count = 12; //it's a cube.. bool invert_val = get_flip_faces(); - Ref<Material> material = get_material(); + Ref<Material> base_material = get_material(); Vector<Vector3> faces; Vector<Vector2> uvs; @@ -1204,7 +1204,7 @@ CSGBrush *CSGBox3D::_build_brush() { smoothw[face] = false; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; //face 2 @@ -1218,7 +1218,7 @@ CSGBrush *CSGBox3D::_build_brush() { smoothw[face] = false; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } @@ -1229,9 +1229,9 @@ CSGBrush *CSGBox3D::_build_brush() { } } - brush->build_from_faces(faces, uvs, smooth, materials, invert); + new_brush->build_from_faces(faces, uvs, smooth, materials, invert); - return brush; + return new_brush; } void CSGBox3D::_bind_methods() { @@ -1270,12 +1270,12 @@ Ref<Material> CSGBox3D::get_material() const { CSGBrush *CSGCylinder3D::_build_brush() { // set our bounding box - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); int face_count = sides * (cone ? 1 : 2) + sides + (cone ? 0 : sides); bool invert_val = get_flip_faces(); - Ref<Material> material = get_material(); + Ref<Material> base_material = get_material(); Vector<Vector3> faces; Vector<Vector2> uvs; @@ -1312,14 +1312,14 @@ CSGBrush *CSGCylinder3D::_build_brush() { float ang = inc * Math_TAU; float ang_n = inc_n * Math_TAU; - Vector3 base(Math::cos(ang), 0, Math::sin(ang)); - Vector3 base_n(Math::cos(ang_n), 0, Math::sin(ang_n)); + Vector3 face_base(Math::cos(ang), 0, Math::sin(ang)); + Vector3 face_base_n(Math::cos(ang_n), 0, Math::sin(ang_n)); Vector3 face_points[4] = { - base + Vector3(0, -1, 0), - base_n + Vector3(0, -1, 0), - base_n * (cone ? 0.0 : 1.0) + Vector3(0, 1, 0), - base * (cone ? 0.0 : 1.0) + Vector3(0, 1, 0), + face_base + Vector3(0, -1, 0), + face_base_n + Vector3(0, -1, 0), + face_base_n * (cone ? 0.0 : 1.0) + Vector3(0, 1, 0), + face_base * (cone ? 0.0 : 1.0) + Vector3(0, 1, 0), }; Vector2 u[4] = { @@ -1340,7 +1340,7 @@ CSGBrush *CSGCylinder3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; @@ -1356,7 +1356,7 @@ CSGBrush *CSGCylinder3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } @@ -1371,7 +1371,7 @@ CSGBrush *CSGCylinder3D::_build_brush() { smoothw[face] = false; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; if (!cone) { @@ -1386,7 +1386,7 @@ CSGBrush *CSGCylinder3D::_build_brush() { smoothw[face] = false; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } } @@ -1397,9 +1397,9 @@ CSGBrush *CSGCylinder3D::_build_brush() { } } - brush->build_from_faces(faces, uvs, smooth, materials, invert); + new_brush->build_from_faces(faces, uvs, smooth, materials, invert); - return brush; + return new_brush; } void CSGCylinder3D::_bind_methods() { @@ -1515,12 +1515,12 @@ CSGBrush *CSGTorus3D::_build_brush() { float radius = (max_radius - min_radius) * 0.5; - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); int face_count = ring_sides * sides * 2; bool invert_val = get_flip_faces(); - Ref<Material> material = get_material(); + Ref<Material> base_material = get_material(); Vector<Vector3> faces; Vector<Vector2> uvs; @@ -1596,7 +1596,7 @@ CSGBrush *CSGTorus3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; @@ -1611,7 +1611,7 @@ CSGBrush *CSGTorus3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } } @@ -1622,9 +1622,9 @@ CSGBrush *CSGTorus3D::_build_brush() { } } - brush->build_from_faces(faces, uvs, smooth, materials, invert); + new_brush->build_from_faces(faces, uvs, smooth, materials, invert); - return brush; + return new_brush; } void CSGTorus3D::_bind_methods() { @@ -1726,10 +1726,10 @@ CSGTorus3D::CSGTorus3D() { /////////////// CSGBrush *CSGPolygon3D::_build_brush() { - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); if (polygon.size() < 3) { - return brush; + return new_brush; } // Triangulate polygon shape. @@ -1739,7 +1739,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { } int shape_sides = shape_polygon.size(); Vector<int> shape_faces = Geometry2D::triangulate_polygon(shape_polygon); - ERR_FAIL_COND_V_MSG(shape_faces.size() < 3, brush, "Failed to triangulate CSGPolygon. Make sure the polygon doesn't have any intersecting edges."); + ERR_FAIL_COND_V_MSG(shape_faces.size() < 3, new_brush, "Failed to triangulate CSGPolygon. Make sure the polygon doesn't have any intersecting edges."); // Get polygon enclosing Rect2. Rect2 shape_rect(shape_polygon[0], Vector2()); @@ -1764,12 +1764,12 @@ CSGBrush *CSGPolygon3D::_build_brush() { } if (!path) { - return brush; + return new_brush; } curve = path->get_curve(); if (curve.is_null() || curve->get_point_count() < 2) { - return brush; + return new_brush; } } @@ -1806,7 +1806,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { int face_count = extrusions * extrusion_face_count + end_count * shape_face_count; // Initialize variables used to create the mesh. - Ref<Material> material = get_material(); + Ref<Material> base_material = get_material(); Vector<Vector3> faces; Vector<Vector2> uvs; @@ -1896,7 +1896,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { } smoothw[face] = false; - materialsw[face] = material; + materialsw[face] = base_material; invertw[face] = flip_faces; face++; } @@ -2003,7 +2003,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = flip_faces; - materialsw[face] = material; + materialsw[face] = base_material; face++; @@ -2018,7 +2018,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = flip_faces; - materialsw[face] = material; + materialsw[face] = base_material; face++; } @@ -2041,14 +2041,14 @@ CSGBrush *CSGPolygon3D::_build_brush() { } smoothw[face] = false; - materialsw[face] = material; + materialsw[face] = base_material; invertw[face] = flip_faces; face++; } } face_count -= faces_removed; - ERR_FAIL_COND_V_MSG(face != face_count, brush, "Bug: Failed to create the CSGPolygon mesh correctly."); + ERR_FAIL_COND_V_MSG(face != face_count, new_brush, "Bug: Failed to create the CSGPolygon mesh correctly."); } if (faces_removed > 0) { @@ -2059,9 +2059,9 @@ CSGBrush *CSGPolygon3D::_build_brush() { invert.resize(face_count); } - brush->build_from_faces(faces, uvs, smooth, materials, invert); + new_brush->build_from_faces(faces, uvs, smooth, materials, invert); - return brush; + return new_brush; } void CSGPolygon3D::_notification(int p_what) { diff --git a/modules/csg/doc_classes/CSGShape3D.xml b/modules/csg/doc_classes/CSGShape3D.xml index 7e92d667b3..06f8f5a403 100644 --- a/modules/csg/doc_classes/CSGShape3D.xml +++ b/modules/csg/doc_classes/CSGShape3D.xml @@ -64,9 +64,10 @@ A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> - The physics layers this CSG shape scans for collisions. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. + The physics layers this CSG shape scans for collisions. Only effective if [member use_collision] is [code]true[/code]. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> <member name="collision_priority" type="float" setter="set_collision_priority" getter="get_collision_priority" default="1.0"> + The priority used to solve colliding when occurring penetration. Only effective if [member use_collision] is [code]true[/code]. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level. </member> <member name="operation" type="int" setter="set_operation" getter="get_operation" enum="CSGShape3D.Operation" default="0"> The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent. @@ -75,7 +76,7 @@ Snap makes the mesh snap to a given distance so that the faces of two meshes can be perfectly aligned. A lower value results in greater precision but may be harder to adjust. </member> <member name="use_collision" type="bool" setter="set_use_collision" getter="is_using_collision" default="false"> - Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden. + Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden. See also [member collision_mask] and [member collision_priority]. </member> </members> <constants> diff --git a/modules/csg/editor/csg_gizmos.cpp b/modules/csg/editor/csg_gizmos.cpp index ba9b96db74..73771b3639 100644 --- a/modules/csg/editor/csg_gizmos.cpp +++ b/modules/csg/editor/csg_gizmos.cpp @@ -57,7 +57,7 @@ CSGShape3DGizmoPlugin::CSGShape3DGizmoPlugin() { } String CSGShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const { - CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node()); + CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_node_3d()); if (Object::cast_to<CSGSphere3D>(cs)) { return "Radius"; @@ -79,7 +79,7 @@ String CSGShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, } Variant CSGShape3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const { - CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node()); + CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_node_3d()); if (Object::cast_to<CSGSphere3D>(cs)) { CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs); @@ -105,7 +105,7 @@ Variant CSGShape3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo } void CSGShape3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) { - CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node()); + CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_node_3d()); Transform3D gt = cs->get_global_transform(); //gt.orthonormalize(); @@ -208,7 +208,7 @@ void CSGShape3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_i } void CSGShape3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) { - CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node()); + CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_node_3d()); if (Object::cast_to<CSGSphere3D>(cs)) { CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs); @@ -308,7 +308,7 @@ bool CSGShape3DGizmoPlugin::is_selectable_when_hidden() const { void CSGShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); - CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node()); + CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_node_3d()); Vector<Vector3> faces = cs->get_brush_faces(); |