1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Rename CubeMesh BoxMesh

This commit is contained in:
Marcel Admiraal
2020-12-04 15:39:45 +00:00
parent eed484d054
commit df6b061dbb
11 changed files with 44 additions and 43 deletions

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="CubeMesh" inherits="PrimitiveMesh" version="4.0"> <class name="BoxMesh" inherits="PrimitiveMesh" version="4.0">
<brief_description> <brief_description>
Generate an axis-aligned cuboid [PrimitiveMesh]. Generate an axis-aligned box [PrimitiveMesh].
</brief_description> </brief_description>
<description> <description>
Generate an axis-aligned cuboid [PrimitiveMesh]. Generate an axis-aligned box [PrimitiveMesh].
The cube's UV layout is arranged in a 3×2 layout that allows texturing each face individually. To apply the same texture on all faces, change the material's UV property to [code]Vector3(3, 2, 1)[/code]. The box's UV layout is arranged in a 3×2 layout that allows texturing each face individually. To apply the same texture on all faces, change the material's UV property to [code]Vector3(3, 2, 1)[/code].
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@@ -13,7 +13,7 @@
</methods> </methods>
<members> <members>
<member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )"> <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )">
Size of the cuboid mesh. Size of the box mesh.
</member> </member>
<member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" default="0"> <member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" default="0">
Number of extra edge loops inserted along the Z axis. Number of extra edge loops inserted along the Z axis.

View File

@@ -10,7 +10,7 @@
[codeblocks] [codeblocks]
[gdscript] [gdscript]
var mesh = ArrayMesh.new() var mesh = ArrayMesh.new()
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, CubeMesh.new().get_mesh_arrays()) mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, BoxMesh.new().get_mesh_arrays())
var mdt = MeshDataTool.new() var mdt = MeshDataTool.new()
mdt.create_from_surface(mesh, 0) mdt.create_from_surface(mesh, 0)
for i in range(mdt.get_vertex_count()): for i in range(mdt.get_vertex_count()):
@@ -27,7 +27,7 @@
[/gdscript] [/gdscript]
[csharp] [csharp]
var mesh = new ArrayMesh(); var mesh = new ArrayMesh();
mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, new CubeMesh().GetMeshArrays()); mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, new BoxMesh().GetMeshArrays());
var mdt = new MeshDataTool(); var mdt = new MeshDataTool();
mdt.CreateFromSurface(mesh, 0); mdt.CreateFromSurface(mesh, 0);
for (var i = 0; i &lt; mdt.GetVertexCount(); i++) for (var i = 0; i &lt; mdt.GetVertexCount(); i++)

View File

@@ -4,7 +4,7 @@
Base class for all primitive meshes. Handles applying a [Material] to a primitive mesh. Base class for all primitive meshes. Handles applying a [Material] to a primitive mesh.
</brief_description> </brief_description>
<description> <description>
Base class for all primitive meshes. Handles applying a [Material] to a primitive mesh. Examples include [CapsuleMesh], [CubeMesh], [CylinderMesh], [PlaneMesh], [PrismMesh], [QuadMesh], and [SphereMesh]. Base class for all primitive meshes. Handles applying a [Material] to a primitive mesh. Examples include [BoxMesh], [CapsuleMesh], [CylinderMesh], [PlaneMesh], [PrismMesh], [QuadMesh], and [SphereMesh].
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@@ -873,7 +873,7 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOp
tex = get_theme_icon("MemberMethod", "EditorIcons"); tex = get_theme_icon("MemberMethod", "EditorIcons");
break; break;
case ScriptCodeCompletionOption::KIND_PLAIN_TEXT: case ScriptCodeCompletionOption::KIND_PLAIN_TEXT:
tex = get_theme_icon("CubeMesh", "EditorIcons"); tex = get_theme_icon("BoxMesh", "EditorIcons");
break; break;
default: default:
tex = get_theme_icon("String", "EditorIcons"); tex = get_theme_icon("String", "EditorIcons");

View File

Before

Width:  |  Height:  |  Size: 334 B

After

Width:  |  Height:  |  Size: 334 B

View File

@@ -398,10 +398,10 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<
void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position) { void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position) {
ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(!spatial_node);
CubeMesh cubem; BoxMesh box_mesh;
cubem.set_size(p_size); box_mesh.set_size(p_size);
Array arrays = cubem.surface_get_arrays(0); Array arrays = box_mesh.surface_get_arrays(0);
PackedVector3Array vertex = arrays[RS::ARRAY_VERTEX]; PackedVector3Array vertex = arrays[RS::ARRAY_VERTEX];
Vector3 *w = vertex.ptrw(); Vector3 *w = vertex.ptrw();
@@ -412,7 +412,7 @@ void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size,
arrays[RS::ARRAY_VERTEX] = vertex; arrays[RS::ARRAY_VERTEX] = vertex;
Ref<ArrayMesh> m = memnew(ArrayMesh); Ref<ArrayMesh> m = memnew(ArrayMesh);
m->add_surface_from_arrays(cubem.surface_get_primitive_type(0), arrays); m->add_surface_from_arrays(box_mesh.surface_get_primitive_type(0), arrays);
m->surface_set_material(0, p_material); m->surface_set_material(0, p_material);
add_mesh(m); add_mesh(m);
} }

View File

@@ -55,7 +55,7 @@ class MaterialEditor : public Control {
Camera3D *camera; Camera3D *camera;
Ref<SphereMesh> sphere_mesh; Ref<SphereMesh> sphere_mesh;
Ref<CubeMesh> box_mesh; Ref<BoxMesh> box_mesh;
TextureButton *sphere_switch; TextureButton *sphere_switch;
TextureButton *box_switch; TextureButton *box_switch;

View File

@@ -176,10 +176,10 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
BoxShape3D *box = Object::cast_to<BoxShape3D>(*s); BoxShape3D *box = Object::cast_to<BoxShape3D>(*s);
if (box) { if (box) {
Ref<CubeMesh> cube_mesh; Ref<BoxMesh> box_mesh;
cube_mesh.instance(); box_mesh.instance();
cube_mesh->set_size(box->get_extents() * 2.0); box_mesh->set_size(box->get_extents() * 2.0);
mesh = cube_mesh; mesh = box_mesh;
} }
CapsuleShape3D *capsule = Object::cast_to<CapsuleShape3D>(*s); CapsuleShape3D *capsule = Object::cast_to<CapsuleShape3D>(*s);

View File

@@ -670,8 +670,8 @@ void register_scene_types() {
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
ClassDB::register_virtual_class<PrimitiveMesh>(); ClassDB::register_virtual_class<PrimitiveMesh>();
ClassDB::register_class<BoxMesh>();
ClassDB::register_class<CapsuleMesh>(); ClassDB::register_class<CapsuleMesh>();
ClassDB::register_class<CubeMesh>();
ClassDB::register_class<CylinderMesh>(); ClassDB::register_class<CylinderMesh>();
ClassDB::register_class<PlaneMesh>(); ClassDB::register_class<PlaneMesh>();
ClassDB::register_class<PrismMesh>(); ClassDB::register_class<PrismMesh>();
@@ -835,6 +835,7 @@ void register_scene_types() {
ClassDB::add_compatibility_class("CSGShape", "CSGShape3D"); ClassDB::add_compatibility_class("CSGShape", "CSGShape3D");
ClassDB::add_compatibility_class("CSGSphere", "CSGSphere3D"); ClassDB::add_compatibility_class("CSGSphere", "CSGSphere3D");
ClassDB::add_compatibility_class("CSGTorus", "CSGTorus3D"); ClassDB::add_compatibility_class("CSGTorus", "CSGTorus3D");
ClassDB::add_compatibility_class("CubeMesh", "BoxMesh");
ClassDB::add_compatibility_class("CylinderShape", "CylinderShape3D"); ClassDB::add_compatibility_class("CylinderShape", "CylinderShape3D");
ClassDB::add_compatibility_class("DirectionalLight", "DirectionalLight3D"); ClassDB::add_compatibility_class("DirectionalLight", "DirectionalLight3D");
ClassDB::add_compatibility_class("EditorSpatialGizmo", "EditorNode3DGizmo"); ClassDB::add_compatibility_class("EditorSpatialGizmo", "EditorNode3DGizmo");

View File

@@ -477,10 +477,10 @@ CapsuleMesh::CapsuleMesh() {
} }
/** /**
CubeMesh BoxMesh
*/ */
void CubeMesh::_create_mesh_array(Array &p_arr) const { void BoxMesh::_create_mesh_array(Array &p_arr) const {
int i, j, prevrow, thisrow, point; int i, j, prevrow, thisrow, point;
float x, y, z; float x, y, z;
float onethird = 1.0 / 3.0; float onethird = 1.0 / 3.0;
@@ -672,16 +672,16 @@ void CubeMesh::_create_mesh_array(Array &p_arr) const {
p_arr[RS::ARRAY_INDEX] = indices; p_arr[RS::ARRAY_INDEX] = indices;
} }
void CubeMesh::_bind_methods() { void BoxMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_size", "size"), &CubeMesh::set_size); ClassDB::bind_method(D_METHOD("set_size", "size"), &BoxMesh::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &CubeMesh::get_size); ClassDB::bind_method(D_METHOD("get_size"), &BoxMesh::get_size);
ClassDB::bind_method(D_METHOD("set_subdivide_width", "subdivide"), &CubeMesh::set_subdivide_width); ClassDB::bind_method(D_METHOD("set_subdivide_width", "subdivide"), &BoxMesh::set_subdivide_width);
ClassDB::bind_method(D_METHOD("get_subdivide_width"), &CubeMesh::get_subdivide_width); ClassDB::bind_method(D_METHOD("get_subdivide_width"), &BoxMesh::get_subdivide_width);
ClassDB::bind_method(D_METHOD("set_subdivide_height", "divisions"), &CubeMesh::set_subdivide_height); ClassDB::bind_method(D_METHOD("set_subdivide_height", "divisions"), &BoxMesh::set_subdivide_height);
ClassDB::bind_method(D_METHOD("get_subdivide_height"), &CubeMesh::get_subdivide_height); ClassDB::bind_method(D_METHOD("get_subdivide_height"), &BoxMesh::get_subdivide_height);
ClassDB::bind_method(D_METHOD("set_subdivide_depth", "divisions"), &CubeMesh::set_subdivide_depth); ClassDB::bind_method(D_METHOD("set_subdivide_depth", "divisions"), &BoxMesh::set_subdivide_depth);
ClassDB::bind_method(D_METHOD("get_subdivide_depth"), &CubeMesh::get_subdivide_depth); ClassDB::bind_method(D_METHOD("get_subdivide_depth"), &BoxMesh::get_subdivide_depth);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size"), "set_size", "get_size"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "subdivide_width", PROPERTY_HINT_RANGE, "0,100,1,or_greater"), "set_subdivide_width", "get_subdivide_width"); ADD_PROPERTY(PropertyInfo(Variant::INT, "subdivide_width", PROPERTY_HINT_RANGE, "0,100,1,or_greater"), "set_subdivide_width", "get_subdivide_width");
@@ -689,43 +689,43 @@ void CubeMesh::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "subdivide_depth", PROPERTY_HINT_RANGE, "0,100,1,or_greater"), "set_subdivide_depth", "get_subdivide_depth"); ADD_PROPERTY(PropertyInfo(Variant::INT, "subdivide_depth", PROPERTY_HINT_RANGE, "0,100,1,or_greater"), "set_subdivide_depth", "get_subdivide_depth");
} }
void CubeMesh::set_size(const Vector3 &p_size) { void BoxMesh::set_size(const Vector3 &p_size) {
size = p_size; size = p_size;
_request_update(); _request_update();
} }
Vector3 CubeMesh::get_size() const { Vector3 BoxMesh::get_size() const {
return size; return size;
} }
void CubeMesh::set_subdivide_width(const int p_divisions) { void BoxMesh::set_subdivide_width(const int p_divisions) {
subdivide_w = p_divisions > 0 ? p_divisions : 0; subdivide_w = p_divisions > 0 ? p_divisions : 0;
_request_update(); _request_update();
} }
int CubeMesh::get_subdivide_width() const { int BoxMesh::get_subdivide_width() const {
return subdivide_w; return subdivide_w;
} }
void CubeMesh::set_subdivide_height(const int p_divisions) { void BoxMesh::set_subdivide_height(const int p_divisions) {
subdivide_h = p_divisions > 0 ? p_divisions : 0; subdivide_h = p_divisions > 0 ? p_divisions : 0;
_request_update(); _request_update();
} }
int CubeMesh::get_subdivide_height() const { int BoxMesh::get_subdivide_height() const {
return subdivide_h; return subdivide_h;
} }
void CubeMesh::set_subdivide_depth(const int p_divisions) { void BoxMesh::set_subdivide_depth(const int p_divisions) {
subdivide_d = p_divisions > 0 ? p_divisions : 0; subdivide_d = p_divisions > 0 ? p_divisions : 0;
_request_update(); _request_update();
} }
int CubeMesh::get_subdivide_depth() const { int BoxMesh::get_subdivide_depth() const {
return subdivide_d; return subdivide_d;
} }
CubeMesh::CubeMesh() { BoxMesh::BoxMesh() {
// defaults // defaults
size = Vector3(2.0, 2.0, 2.0); size = Vector3(2.0, 2.0, 2.0);
subdivide_w = 0; subdivide_w = 0;

View File

@@ -130,10 +130,10 @@ public:
}; };
/** /**
Similar to test cube but with subdivision support and different texture coordinates A box
*/ */
class CubeMesh : public PrimitiveMesh { class BoxMesh : public PrimitiveMesh {
GDCLASS(CubeMesh, PrimitiveMesh); GDCLASS(BoxMesh, PrimitiveMesh);
private: private:
Vector3 size; Vector3 size;
@@ -158,7 +158,7 @@ public:
void set_subdivide_depth(const int p_divisions); void set_subdivide_depth(const int p_divisions);
int get_subdivide_depth() const; int get_subdivide_depth() const;
CubeMesh(); BoxMesh();
}; };
/** /**